diff --git a/sdk/signalr/azure-mgmt-signalr/README.md b/sdk/signalr/azure-mgmt-signalr/README.md index 892dddde68af..c6dfcbc835cd 100644 --- a/sdk/signalr/azure-mgmt-signalr/README.md +++ b/sdk/signalr/azure-mgmt-signalr/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure SignalR Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package diff --git a/sdk/signalr/azure-mgmt-signalr/_meta.json b/sdk/signalr/azure-mgmt-signalr/_meta.json index 13b2a3955370..0f39a9a43f5b 100644 --- a/sdk/signalr/azure-mgmt-signalr/_meta.json +++ b/sdk/signalr/azure-mgmt-signalr/_meta.json @@ -1,11 +1,11 @@ { - "commit": "c280892951a9e45c059132c05aace25a9c752d48", + "commit": "dd7041c33d40e3097d7e8c2dffb92fc986f7357d", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.7", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.7.1", - "@autorest/modelerfour@4.26.2" + "@autorest/python@6.19.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/signalr/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", + "autorest_command": "autorest specification/signalr/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/signalr/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_configuration.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_configuration.py index 2ff46ccc038c..2b7ec58737c4 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_configuration.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class SignalRManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class SignalRManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for SignalRManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class SignalRManagementClientConfiguration(Configuration): # pylint: disable=to :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-08-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(SignalRManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-08-01-preview") + api_version: str = kwargs.pop("api_version", "2024-10-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-signalr/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_patch.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_patch.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_serialization.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_serialization.py index 4bae2292227b..8139854b97bb 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_serialization.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +143,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -170,13 +172,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -295,7 +290,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[Dict[str, Any]] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -340,7 +335,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,7 +346,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, @@ -390,7 +385,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -415,7 +410,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -445,7 +440,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -545,7 +540,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -561,7 +556,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -649,7 +644,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -668,7 +663,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -710,7 +705,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -730,6 +725,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -744,7 +740,7 @@ def query(self, name, data, data_type, **kwargs): :param str data_type: The type to be serialized from. :keyword bool skip_quote: Whether to skip quote the serialized result. Defaults to False. - :rtype: str + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -753,7 +749,7 @@ def query(self, name, data, data_type, **kwargs): if data_type.startswith("["): internal_data_type = data_type[1:-1] do_quote = not kwargs.get("skip_quote", False) - return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -804,7 +800,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -824,7 +820,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -993,7 +989,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1170,10 +1166,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1209,7 +1205,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1230,7 +1225,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1371,7 +1365,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1391,7 +1385,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1444,12 +1438,12 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore @@ -1481,7 +1475,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1515,14 +1509,14 @@ def _classify_target(self, target, data): if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1578,7 +1572,7 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1652,7 +1646,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1700,7 +1694,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1757,7 +1751,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1808,7 +1802,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1862,10 +1855,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1893,7 +1886,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1910,7 +1903,7 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1945,7 +1938,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1982,7 +1975,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1998,9 +1991,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_signal_rmanagement_client.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_signal_rmanagement_client.py index c7173fa40d2d..a08c43efa02a 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_signal_rmanagement_client.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_signal_rmanagement_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from ._configuration import SignalRManagementClientConfiguration @@ -22,6 +25,7 @@ SignalROperations, SignalRPrivateEndpointConnectionsOperations, SignalRPrivateLinkResourcesOperations, + SignalRReplicaSharedPrivateLinkResourcesOperations, SignalRReplicasOperations, SignalRSharedPrivateLinkResourcesOperations, UsagesOperations, @@ -55,6 +59,10 @@ class SignalRManagementClient: # pylint: disable=client-accepts-api-version-key azure.mgmt.signalr.operations.SignalRPrivateLinkResourcesOperations :ivar signal_rreplicas: SignalRReplicasOperations operations :vartype signal_rreplicas: azure.mgmt.signalr.operations.SignalRReplicasOperations + :ivar signal_rreplica_shared_private_link_resources: + SignalRReplicaSharedPrivateLinkResourcesOperations operations + :vartype signal_rreplica_shared_private_link_resources: + azure.mgmt.signalr.operations.SignalRReplicaSharedPrivateLinkResourcesOperations :ivar signal_rshared_private_link_resources: SignalRSharedPrivateLinkResourcesOperations operations :vartype signal_rshared_private_link_resources: @@ -65,7 +73,7 @@ class SignalRManagementClient: # pylint: disable=client-accepts-api-version-key :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-08-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -82,7 +90,25 @@ def __init__( self._config = SignalRManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -106,11 +132,14 @@ def __init__( self.signal_rreplicas = SignalRReplicasOperations( self._client, self._config, self._serialize, self._deserialize ) + self.signal_rreplica_shared_private_link_resources = SignalRReplicaSharedPrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.signal_rshared_private_link_resources = SignalRSharedPrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -130,12 +159,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "SignalRManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_vendor.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_version.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_version.py index 2eda20789583..e5754a47ce68 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_version.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0b2" +VERSION = "1.0.0b1" diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_configuration.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_configuration.py index 0dc64cb72302..9dd673f94209 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_configuration.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class SignalRManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class SignalRManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for SignalRManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class SignalRManagementClientConfiguration(Configuration): # pylint: disable=to :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-08-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(SignalRManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-08-01-preview") + api_version: str = kwargs.pop("api_version", "2024-10-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-signalr/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_patch.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_patch.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_signal_rmanagement_client.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_signal_rmanagement_client.py index 569ddba1f4b7..024cd62ee631 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_signal_rmanagement_client.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_signal_rmanagement_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from .._serialization import Deserializer, Serializer @@ -22,6 +25,7 @@ SignalROperations, SignalRPrivateEndpointConnectionsOperations, SignalRPrivateLinkResourcesOperations, + SignalRReplicaSharedPrivateLinkResourcesOperations, SignalRReplicasOperations, SignalRSharedPrivateLinkResourcesOperations, UsagesOperations, @@ -56,6 +60,10 @@ class SignalRManagementClient: # pylint: disable=client-accepts-api-version-key azure.mgmt.signalr.aio.operations.SignalRPrivateLinkResourcesOperations :ivar signal_rreplicas: SignalRReplicasOperations operations :vartype signal_rreplicas: azure.mgmt.signalr.aio.operations.SignalRReplicasOperations + :ivar signal_rreplica_shared_private_link_resources: + SignalRReplicaSharedPrivateLinkResourcesOperations operations + :vartype signal_rreplica_shared_private_link_resources: + azure.mgmt.signalr.aio.operations.SignalRReplicaSharedPrivateLinkResourcesOperations :ivar signal_rshared_private_link_resources: SignalRSharedPrivateLinkResourcesOperations operations :vartype signal_rshared_private_link_resources: @@ -66,7 +74,7 @@ class SignalRManagementClient: # pylint: disable=client-accepts-api-version-key :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-08-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -83,7 +91,25 @@ def __init__( self._config = SignalRManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -107,11 +133,16 @@ def __init__( self.signal_rreplicas = SignalRReplicasOperations( self._client, self._config, self._serialize, self._deserialize ) + self.signal_rreplica_shared_private_link_resources = SignalRReplicaSharedPrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.signal_rshared_private_link_resources = SignalRSharedPrivateLinkResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -131,12 +162,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "SignalRManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/__init__.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/__init__.py index e15b22bc07ac..8119c1158f2d 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/__init__.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/__init__.py @@ -14,6 +14,9 @@ from ._signal_rprivate_endpoint_connections_operations import SignalRPrivateEndpointConnectionsOperations from ._signal_rprivate_link_resources_operations import SignalRPrivateLinkResourcesOperations from ._signal_rreplicas_operations import SignalRReplicasOperations +from ._signal_rreplica_shared_private_link_resources_operations import ( + SignalRReplicaSharedPrivateLinkResourcesOperations, +) from ._signal_rshared_private_link_resources_operations import SignalRSharedPrivateLinkResourcesOperations from ._patch import __all__ as _patch_all @@ -29,6 +32,7 @@ "SignalRPrivateEndpointConnectionsOperations", "SignalRPrivateLinkResourcesOperations", "SignalRReplicasOperations", + "SignalRReplicaSharedPrivateLinkResourcesOperations", "SignalRSharedPrivateLinkResourcesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_operations.py index 0bc414843400..37028b5377a0 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available REST API operations of the Microsoft.SignalRService provider. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -67,7 +69,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -78,14 +80,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -97,13 +97,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationList", pipeline_response) @@ -113,11 +112,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -129,5 +128,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.SignalRService/operations"} diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_r_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_r_operations.py index 09caf728ef87..92a3948d43df 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_r_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_r_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._signal_r_operations import ( build_check_name_availability_request, build_create_or_update_request, @@ -46,6 +47,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -80,14 +85,13 @@ async def check_name_availability( ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. Required. + :param location: The region. Required. :type location: str :param parameters: Parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.signalr.models.NameAvailabilityParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: @@ -95,18 +99,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, location: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. Required. + :param location: The region. Required. :type location: str :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: @@ -114,24 +117,20 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, location: str, parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + self, location: str, parameters: Union[_models.NameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. Required. + :param location: The region. Required. :type location: str :param parameters: Parameters supplied to the operation. Is either a NameAvailabilityParameters - type or a IO type. Required. - :type parameters: ~azure.mgmt.signalr.models.NameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.NameAvailabilityParameters or IO[bytes] :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -154,23 +153,21 @@ async def check_name_availability( else: _json = self._serialize.body(parameters, "NameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -180,22 +177,17 @@ 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("NameAvailability", pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SignalRResource"]: """Handles requests to list all resources in a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SignalRResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.SignalRResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -206,7 +198,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SignalRR api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SignalRResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -217,15 +209,13 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SignalRR def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -237,13 +227,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SignalRResourceList", pipeline_response) @@ -253,11 +242,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -270,10 +259,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/signalR" - } - @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any @@ -283,7 +268,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SignalRResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.SignalRResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -294,7 +278,7 @@ def list_by_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SignalRResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -305,16 +289,14 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -326,13 +308,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SignalRResourceList", pipeline_response) @@ -342,11 +323,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -359,10 +340,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR" - } - @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.SignalRResource: """Get the resource and its properties. @@ -372,12 +349,11 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SignalRResource or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SignalRResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -391,21 +367,19 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SignalRResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -415,25 +389,21 @@ async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SignalRResource", pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - parameters: Union[_models.SignalRResource, IO], + parameters: Union[_models.SignalRResource, IO[bytes]], **kwargs: Any - ) -> Optional[_models.SignalRResource]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -446,7 +416,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.SignalRResource]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -456,7 +426,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "SignalRResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -464,40 +434,34 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("SignalRResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SignalRResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -521,14 +485,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either SignalRResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRResource] @@ -540,7 +496,7 @@ async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -553,18 +509,10 @@ async def begin_create_or_update( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: Parameters for the create or update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either SignalRResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRResource] @@ -576,7 +524,7 @@ async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - parameters: Union[_models.SignalRResource, IO], + parameters: Union[_models.SignalRResource, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.SignalRResource]: """Create or update a resource. @@ -587,19 +535,8 @@ async def begin_create_or_update( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: Parameters for the create or update operation. Is either a SignalRResource - type or a IO type. Required. - :type parameters: ~azure.mgmt.signalr.models.SignalRResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.SignalRResource or IO[bytes] :return: An instance of AsyncLROPoller that returns either SignalRResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRResource] @@ -626,12 +563,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SignalRResource", pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -644,22 +582,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SignalRResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}" - } + return AsyncLROPoller[_models.SignalRResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -671,38 +607,41 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -713,14 +652,6 @@ async def begin_delete(self, resource_group_name: str, resource_name: str, **kwa :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -734,7 +665,7 @@ async def begin_delete(self, resource_group_name: str, resource_name: str, **kwa lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, resource_name=resource_name, api_version=api_version, @@ -743,11 +674,12 @@ async def begin_delete(self, resource_group_name: str, resource_name: str, **kwa params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -758,26 +690,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _update_initial( self, resource_group_name: str, resource_name: str, - parameters: Union[_models.SignalRResource, IO], + parameters: Union[_models.SignalRResource, IO[bytes]], **kwargs: Any - ) -> Optional[_models.SignalRResource]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -790,7 +718,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.SignalRResource]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -800,7 +728,7 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "SignalRResource") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -808,41 +736,38 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SignalRResource", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -866,14 +791,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either SignalRResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRResource] @@ -885,7 +802,7 @@ async def begin_update( self, resource_group_name: str, resource_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -898,18 +815,10 @@ async def begin_update( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: Parameters for the update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either SignalRResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRResource] @@ -921,7 +830,7 @@ async def begin_update( self, resource_group_name: str, resource_name: str, - parameters: Union[_models.SignalRResource, IO], + parameters: Union[_models.SignalRResource, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.SignalRResource]: """Operation to update an exiting resource. @@ -932,19 +841,8 @@ async def begin_update( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: Parameters for the update operation. Is either a SignalRResource type or a - IO type. Required. - :type parameters: ~azure.mgmt.signalr.models.SignalRResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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. + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.SignalRResource or IO[bytes] :return: An instance of AsyncLROPoller that returns either SignalRResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRResource] @@ -971,12 +869,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SignalRResource", pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -988,17 +887,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SignalRResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}" - } + return AsyncLROPoller[_models.SignalRResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def list_keys(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.SignalRKeys: @@ -1009,12 +906,11 @@ async def list_keys(self, resource_group_name: str, resource_name: str, **kwargs :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SignalRKeys or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SignalRKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1028,21 +924,19 @@ async def list_keys(self, resource_group_name: str, resource_name: str, **kwargs api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SignalRKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1052,25 +946,21 @@ async def list_keys(self, resource_group_name: str, resource_name: str, **kwargs error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SignalRKeys", pipeline_response) + deserialized = self._deserialize("SignalRKeys", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/listKeys" - } + return deserialized # type: ignore async def _regenerate_key_initial( self, resource_group_name: str, resource_name: str, - parameters: Union[_models.RegenerateKeyParameters, IO], + parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], **kwargs: Any - ) -> _models.SignalRKeys: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1083,7 +973,7 @@ async def _regenerate_key_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SignalRKeys] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1093,7 +983,7 @@ async def _regenerate_key_initial( else: _json = self._serialize.body(parameters, "RegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -1101,43 +991,39 @@ async def _regenerate_key_initial( content_type=content_type, json=_json, content=_content, - template_url=self._regenerate_key_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SignalRKeys", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("SignalRKeys", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _regenerate_key_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/regenerateKey" - } - @overload async def begin_regenerate_key( self, @@ -1161,14 +1047,6 @@ async def begin_regenerate_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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either SignalRKeys or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRKeys] @@ -1180,7 +1058,7 @@ async def begin_regenerate_key( self, resource_group_name: str, resource_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1194,18 +1072,10 @@ async def begin_regenerate_key( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: Parameter that describes the Regenerate Key Operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either SignalRKeys or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRKeys] @@ -1217,7 +1087,7 @@ async def begin_regenerate_key( self, resource_group_name: str, resource_name: str, - parameters: Union[_models.RegenerateKeyParameters, IO], + parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.SignalRKeys]: """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated @@ -1229,19 +1099,8 @@ async def begin_regenerate_key( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: Parameter that describes the Regenerate Key Operation. Is either a - RegenerateKeyParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.signalr.models.RegenerateKeyParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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. + RegenerateKeyParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.RegenerateKeyParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either SignalRKeys or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRKeys] @@ -1268,12 +1127,13 @@ async def begin_regenerate_key( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SignalRKeys", pipeline_response) + deserialized = self._deserialize("SignalRKeys", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1285,17 +1145,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SignalRKeys].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/regenerateKey" - } + return AsyncLROPoller[_models.SignalRKeys]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def list_replica_skus( @@ -1310,12 +1168,11 @@ async def list_replica_skus( :type resource_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SkuList or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SkuList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1329,22 +1186,20 @@ async def list_replica_skus( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SkuList] = kwargs.pop("cls", None) - request = build_list_replica_skus_request( + _request = build_list_replica_skus_request( resource_group_name=resource_group_name, resource_name=resource_name, replica_name=replica_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_replica_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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1354,21 +1209,17 @@ async def list_replica_skus( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SkuList", pipeline_response) + deserialized = self._deserialize("SkuList", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_replica_skus.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}/skus" - } + return deserialized # type: ignore - async def _restart_initial( # pylint: disable=inconsistent-return-statements + async def _restart_initial( self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1380,28 +1231,31 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_restart_request( + _request = build_restart_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1410,12 +1264,12 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _restart_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/restart" - } + return deserialized # type: ignore @distributed_trace_async async def begin_restart(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1426,14 +1280,6 @@ async def begin_restart(self, resource_group_name: str, resource_name: str, **kw :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1447,7 +1293,7 @@ async def begin_restart(self, resource_group_name: str, resource_name: str, **kw lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._restart_initial( # type: ignore + raw_result = await self._restart_initial( resource_group_name=resource_group_name, resource_name=resource_name, api_version=api_version, @@ -1456,11 +1302,12 @@ async def begin_restart(self, resource_group_name: str, resource_name: str, **kw params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -1471,17 +1318,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_restart.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/restart" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def list_skus(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.SkuList: @@ -1492,12 +1335,11 @@ async def list_skus(self, resource_group_name: str, resource_name: str, **kwargs :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SkuList or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SkuList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1511,21 +1353,19 @@ async def list_skus(self, resource_group_name: str, resource_name: str, **kwargs api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SkuList] = kwargs.pop("cls", None) - request = build_list_skus_request( + _request = build_list_skus_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_skus.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1535,13 +1375,9 @@ async def list_skus(self, resource_group_name: str, resource_name: str, **kwargs error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SkuList", pipeline_response) + deserialized = self._deserialize("SkuList", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_skus.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/skus" - } + return deserialized # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rcustom_certificates_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rcustom_certificates_operations.py index d3b53c5c1824..8040519b2149 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rcustom_certificates_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rcustom_certificates_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._signal_rcustom_certificates_operations import ( build_create_or_update_request, build_delete_request, @@ -38,6 +39,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,7 +77,6 @@ def list( :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CustomCertificate or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.CustomCertificate] :raises ~azure.core.exceptions.HttpResponseError: @@ -83,7 +87,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomCertificateList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,17 +98,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -116,13 +118,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("CustomCertificateList", pipeline_response) @@ -132,11 +133,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -149,10 +150,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates" - } - @distributed_trace_async async def get( self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any @@ -166,12 +163,11 @@ async def get( :type resource_name: str :param certificate_name: Custom certificate name. Required. :type certificate_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CustomCertificate or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.CustomCertificate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -185,22 +181,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomCertificate] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -210,26 +204,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CustomCertificate", pipeline_response) + deserialized = self._deserialize("CustomCertificate", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, certificate_name: str, - parameters: Union[_models.CustomCertificate, IO], + parameters: Union[_models.CustomCertificate, IO[bytes]], **kwargs: Any - ) -> _models.CustomCertificate: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -242,7 +232,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomCertificate] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -252,7 +242,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "CustomCertificate") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, @@ -261,40 +251,35 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("CustomCertificate", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CustomCertificate", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}" - } - @overload async def begin_create_or_update( self, @@ -320,14 +305,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either CustomCertificate or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.CustomCertificate] @@ -340,7 +317,7 @@ async def begin_create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -355,18 +332,10 @@ async def begin_create_or_update( :param certificate_name: Custom certificate name. Required. :type certificate_name: str :param parameters: Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either CustomCertificate or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.CustomCertificate] @@ -379,7 +348,7 @@ async def begin_create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - parameters: Union[_models.CustomCertificate, IO], + parameters: Union[_models.CustomCertificate, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.CustomCertificate]: """Create or update a custom certificate. @@ -391,19 +360,8 @@ async def begin_create_or_update( :type resource_name: str :param certificate_name: Custom certificate name. Required. :type certificate_name: str - :param parameters: Is either a CustomCertificate type or a IO type. Required. - :type parameters: ~azure.mgmt.signalr.models.CustomCertificate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param parameters: Is either a CustomCertificate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.CustomCertificate or IO[bytes] :return: An instance of AsyncLROPoller that returns either CustomCertificate or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.CustomCertificate] @@ -431,12 +389,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomCertificate", pipeline_response) + deserialized = self._deserialize("CustomCertificate", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -449,17 +408,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.CustomCertificate].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}" - } + return AsyncLROPoller[_models.CustomCertificate]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -474,12 +431,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_name: str :param certificate_name: Custom certificate name. Required. :type certificate_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -493,22 +449,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -519,8 +473,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rcustom_domains_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rcustom_domains_operations.py index 8ed93026b225..84f7f9d3a710 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rcustom_domains_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rcustom_domains_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._signal_rcustom_domains_operations import ( build_create_or_update_request, build_delete_request, @@ -38,6 +39,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,7 +77,6 @@ def list( :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CustomDomain or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.CustomDomain] :raises ~azure.core.exceptions.HttpResponseError: @@ -83,7 +87,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomDomainList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,17 +98,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -116,13 +118,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("CustomDomainList", pipeline_response) @@ -132,11 +133,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -149,10 +150,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains" - } - @distributed_trace_async async def get(self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any) -> _models.CustomDomain: """Get a custom domain. @@ -164,12 +161,11 @@ async def get(self, resource_group_name: str, resource_name: str, name: str, **k :type resource_name: str :param name: Custom domain name. Required. :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CustomDomain or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.CustomDomain :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -183,22 +179,20 @@ async def get(self, resource_group_name: str, resource_name: str, name: str, **k api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, name=name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -208,26 +202,22 @@ async def get(self, resource_group_name: str, resource_name: str, name: str, **k error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, name: str, - parameters: Union[_models.CustomDomain, IO], + parameters: Union[_models.CustomDomain, IO[bytes]], **kwargs: Any - ) -> _models.CustomDomain: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -240,7 +230,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -250,7 +240,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "CustomDomain") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, name=name, @@ -259,35 +249,34 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -314,14 +303,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.CustomDomain] @@ -334,7 +315,7 @@ async def begin_create_or_update( resource_group_name: str, resource_name: str, name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -349,18 +330,10 @@ async def begin_create_or_update( :param name: Custom domain name. Required. :type name: str :param parameters: Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.CustomDomain] @@ -373,7 +346,7 @@ async def begin_create_or_update( resource_group_name: str, resource_name: str, name: str, - parameters: Union[_models.CustomDomain, IO], + parameters: Union[_models.CustomDomain, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.CustomDomain]: """Create or update a custom domain. @@ -385,19 +358,8 @@ async def begin_create_or_update( :type resource_name: str :param name: Custom domain name. Required. :type name: str - :param parameters: Is either a CustomDomain type or a IO type. Required. - :type parameters: ~azure.mgmt.signalr.models.CustomDomain or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param parameters: Is either a CustomDomain type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.CustomDomain or IO[bytes] :return: An instance of AsyncLROPoller that returns either CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.CustomDomain] @@ -425,12 +387,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -443,22 +406,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.CustomDomain].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}" - } + return AsyncLROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -470,39 +431,42 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, name=name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -517,14 +481,6 @@ async def begin_delete( :type resource_name: str :param name: Custom domain name. Required. :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -538,7 +494,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, resource_name=resource_name, name=name, @@ -548,11 +504,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -563,14 +520,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rprivate_endpoint_connections_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rprivate_endpoint_connections_operations.py index 1dd1c28a0327..69501ca05fca 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rprivate_endpoint_connections_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rprivate_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._signal_rprivate_endpoint_connections_operations import ( build_delete_request, build_get_request, @@ -38,11 +39,15 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SignalRPrivateEndpointConnectionsOperations: +class SignalRPrivateEndpointConnectionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -72,7 +77,6 @@ def list( :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -85,7 +89,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,17 +100,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,13 +120,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionList", pipeline_response) @@ -134,11 +135,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,10 +152,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any @@ -169,12 +166,11 @@ async def get( :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,22 +184,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( private_endpoint_connection_name=private_endpoint_connection_name, resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -213,16 +207,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload async def update( @@ -250,7 +240,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -262,7 +251,7 @@ async def update( private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -278,11 +267,10 @@ async def update( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: The resource of private endpoint and its properties. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -294,7 +282,7 @@ async def update( private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection. @@ -308,17 +296,13 @@ async def update( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: The resource of private endpoint and its properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type parameters: ~azure.mgmt.signalr.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 + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,7 +325,7 @@ async def update( else: _json = self._serialize.body(parameters, "PrivateEndpointConnection") - request = build_update_request( + _request = build_update_request( private_endpoint_connection_name=private_endpoint_connection_name, resource_group_name=resource_group_name, resource_name=resource_name, @@ -350,16 +334,14 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,21 +351,17 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -395,39 +373,42 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( private_endpoint_connection_name=private_endpoint_connection_name, resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -443,14 +424,6 @@ async def begin_delete( :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -464,7 +437,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( private_endpoint_connection_name=private_endpoint_connection_name, resource_group_name=resource_group_name, resource_name=resource_name, @@ -474,11 +447,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -489,14 +463,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rprivate_link_resources_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rprivate_link_resources_operations.py index 32214e77a57e..22f4ad48a875 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rprivate_link_resources_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rprivate_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._signal_rprivate_link_resources_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,7 +66,6 @@ def list( :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.PrivateLinkResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -74,7 +76,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -85,17 +87,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -107,13 +107,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceList", pipeline_response) @@ -123,11 +122,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -139,7 +138,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateLinkResources" - } diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rreplica_shared_private_link_resources_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rreplica_shared_private_link_resources_operations.py new file mode 100644 index 000000000000..25bb4d5d9c1f --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rreplica_shared_private_link_resources_operations.py @@ -0,0 +1,451 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._signal_rreplica_shared_private_link_resources_operations import ( + build_create_or_update_request, + build_get_request, + build_list_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SignalRReplicaSharedPrivateLinkResourcesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.aio.SignalRManagementClient`'s + :attr:`signal_rreplica_shared_private_link_resources` attribute. + """ + + models = _models + + 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, resource_name: str, replica_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedPrivateLinkResource"]: + """List shared private link resources. + + :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 resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :return: An iterator like instance of either SharedPrivateLinkResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SharedPrivateLinkResourceList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SharedPrivateLinkResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + **kwargs: Any + ) -> _models.SharedPrivateLinkResource: + """Get the specified shared private link resource. + + :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 resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :return: SharedPrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.signalr.models.SharedPrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + shared_private_link_resource_name=shared_private_link_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: Union[_models.SharedPrivateLinkResource, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SharedPrivateLinkResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + shared_private_link_resource_name=shared_private_link_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: _models.SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :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 resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: ~azure.mgmt.signalr.models.SharedPrivateLinkResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either SharedPrivateLinkResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :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 resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either SharedPrivateLinkResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: Union[_models.SharedPrivateLinkResource, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :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 resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param parameters: The shared private link resource. Is either a SharedPrivateLinkResource type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.SharedPrivateLinkResource or IO[bytes] + :return: An instance of AsyncLROPoller that returns either SharedPrivateLinkResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + shared_private_link_resource_name=shared_private_link_resource_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SharedPrivateLinkResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SharedPrivateLinkResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rreplicas_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rreplicas_operations.py index 24aa2cadfd49..04c92045fed5 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rreplicas_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rreplicas_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._signal_rreplicas_operations import ( build_create_or_update_request, build_delete_request, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,7 +77,6 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> A :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Replica or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.Replica] :raises ~azure.core.exceptions.HttpResponseError: @@ -83,7 +87,7 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> A api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReplicaList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,17 +98,15 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> A def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -116,13 +118,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ReplicaList", pipeline_response) @@ -132,11 +133,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -149,10 +150,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas" - } - @distributed_trace_async async def get( self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any @@ -166,12 +163,11 @@ async def get( :type resource_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Replica or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.Replica :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -185,22 +181,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Replica] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, replica_name=replica_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -210,26 +204,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = self._deserialize("Replica", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, replica_name: str, - parameters: Union[_models.Replica, IO], + parameters: Union[_models.Replica, IO[bytes]], **kwargs: Any - ) -> _models.Replica: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -242,7 +232,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -252,7 +242,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "Replica") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, replica_name=replica_name, @@ -261,40 +251,35 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Replica", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}" - } - @overload async def begin_create_or_update( self, @@ -320,14 +305,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.Replica] @@ -340,7 +317,7 @@ async def begin_create_or_update( resource_group_name: str, resource_name: str, replica_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -355,18 +332,10 @@ async def begin_create_or_update( :param replica_name: The name of the replica. Required. :type replica_name: str :param parameters: Parameters for the create or update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.Replica] @@ -379,7 +348,7 @@ async def begin_create_or_update( resource_group_name: str, resource_name: str, replica_name: str, - parameters: Union[_models.Replica, IO], + parameters: Union[_models.Replica, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Replica]: """Create or update a replica. @@ -392,19 +361,8 @@ async def begin_create_or_update( :param replica_name: The name of the replica. Required. :type replica_name: str :param parameters: Parameters for the create or update operation. Is either a Replica type or a - IO type. Required. - :type parameters: ~azure.mgmt.signalr.models.Replica or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/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. + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.Replica or IO[bytes] :return: An instance of AsyncLROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.Replica] @@ -432,12 +390,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = self._deserialize("Replica", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -450,17 +409,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Replica].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}" - } + return AsyncLROPoller[_models.Replica]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -475,12 +432,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -494,22 +450,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, replica_name=replica_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -520,21 +474,17 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}" - } + return cls(pipeline_response, None, {}) # type: ignore async def _update_initial( self, resource_group_name: str, resource_name: str, replica_name: str, - parameters: Union[_models.Replica, IO], + parameters: Union[_models.Replica, IO[bytes]], **kwargs: Any - ) -> _models.Replica: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -547,7 +497,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -557,7 +507,7 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "Replica") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, replica_name=replica_name, @@ -566,43 +516,39 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Replica", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}" - } - @overload async def begin_update( self, @@ -628,14 +574,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.Replica] @@ -648,7 +586,7 @@ async def begin_update( resource_group_name: str, resource_name: str, replica_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -663,18 +601,10 @@ async def begin_update( :param replica_name: The name of the replica. Required. :type replica_name: str :param parameters: Parameters for the update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.Replica] @@ -687,7 +617,7 @@ async def begin_update( resource_group_name: str, resource_name: str, replica_name: str, - parameters: Union[_models.Replica, IO], + parameters: Union[_models.Replica, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Replica]: """Operation to update an exiting replica. @@ -699,20 +629,9 @@ async def begin_update( :type resource_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :param parameters: Parameters for the update operation. Is either a Replica type or a IO type. - Required. - :type parameters: ~azure.mgmt.signalr.models.Replica or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param parameters: Parameters for the update operation. Is either a Replica type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.signalr.models.Replica or IO[bytes] :return: An instance of AsyncLROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.Replica] @@ -740,12 +659,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = self._deserialize("Replica", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -757,22 +677,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Replica].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}" - } + return AsyncLROPoller[_models.Replica]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _restart_initial( # pylint: disable=inconsistent-return-statements + async def _restart_initial( self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -784,29 +702,32 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_restart_request( + _request = build_restart_request( resource_group_name=resource_group_name, resource_name=resource_name, replica_name=replica_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -815,12 +736,12 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _restart_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}/restart" - } + return deserialized # type: ignore @distributed_trace_async async def begin_restart( @@ -835,14 +756,6 @@ async def begin_restart( :type resource_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -856,7 +769,7 @@ async def begin_restart( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._restart_initial( # type: ignore + raw_result = await self._restart_initial( resource_group_name=resource_group_name, resource_name=resource_name, replica_name=replica_name, @@ -866,11 +779,12 @@ async def begin_restart( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -881,14 +795,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_restart.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}/restart" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rshared_private_link_resources_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rshared_private_link_resources_operations.py index 097819335c21..8830e4e66248 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rshared_private_link_resources_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rshared_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._signal_rshared_private_link_resources_operations import ( build_create_or_update_request, build_delete_request, @@ -38,11 +39,15 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SignalRSharedPrivateLinkResourcesOperations: +class SignalRSharedPrivateLinkResourcesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -72,7 +77,6 @@ def list( :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SharedPrivateLinkResource or the result of cls(response) :rtype: @@ -85,7 +89,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SharedPrivateLinkResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,17 +100,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,13 +120,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SharedPrivateLinkResourceList", pipeline_response) @@ -134,11 +135,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,10 +152,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources" - } - @distributed_trace_async async def get( self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any @@ -169,12 +166,11 @@ async def get( :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedPrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SharedPrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,22 +184,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( shared_private_link_resource_name=shared_private_link_resource_name, resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -213,26 +207,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, - parameters: Union[_models.SharedPrivateLinkResource, IO], + parameters: Union[_models.SharedPrivateLinkResource, IO[bytes]], **kwargs: Any - ) -> _models.SharedPrivateLinkResource: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,7 +235,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -255,7 +245,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "SharedPrivateLinkResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( shared_private_link_resource_name=shared_private_link_resource_name, resource_group_name=resource_group_name, resource_name=resource_name, @@ -264,40 +254,35 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}" - } - @overload async def begin_create_or_update( self, @@ -324,14 +309,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either SharedPrivateLinkResource or the result of cls(response) :rtype: @@ -345,7 +322,7 @@ async def begin_create_or_update( shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -361,18 +338,10 @@ async def begin_create_or_update( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: The shared private link resource. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either SharedPrivateLinkResource or the result of cls(response) :rtype: @@ -386,7 +355,7 @@ async def begin_create_or_update( shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, - parameters: Union[_models.SharedPrivateLinkResource, IO], + parameters: Union[_models.SharedPrivateLinkResource, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: """Create or update a shared private link resource. @@ -400,19 +369,8 @@ async def begin_create_or_update( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: The shared private link resource. Is either a SharedPrivateLinkResource type - or a IO type. Required. - :type parameters: ~azure.mgmt.signalr.models.SharedPrivateLinkResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.SharedPrivateLinkResource or IO[bytes] :return: An instance of AsyncLROPoller that returns either SharedPrivateLinkResource or the result of cls(response) :rtype: @@ -441,12 +399,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -459,22 +418,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SharedPrivateLinkResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}" - } + return AsyncLROPoller[_models.SharedPrivateLinkResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -486,39 +443,42 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( shared_private_link_resource_name=shared_private_link_resource_name, resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -534,14 +494,6 @@ async def begin_delete( :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -555,7 +507,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( shared_private_link_resource_name=shared_private_link_resource_name, resource_group_name=resource_group_name, resource_name=resource_name, @@ -565,11 +517,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -580,14 +533,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_usages_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_usages_operations.py index d3bc85e39902..b76f845352e5 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_usages_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_usages_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._usages_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,7 +61,6 @@ def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.SignalRUs :param location: the location like "eastus". Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SignalRUsage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.SignalRUsage] :raises ~azure.core.exceptions.HttpResponseError: @@ -69,7 +71,7 @@ def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.SignalRUs api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SignalRUsageList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,16 +82,14 @@ def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.SignalRUs def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -101,13 +101,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SignalRUsageList", pipeline_response) @@ -117,11 +116,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,7 +132,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/usages" - } diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/__init__.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/__init__.py index 13eac9151693..8795a9914fe5 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/__init__.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/__init__.py @@ -6,6 +6,9 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._models_py3 import ApplicationFirewallSettings +from ._models_py3 import ClientConnectionCountRule +from ._models_py3 import ClientTrafficControlRule from ._models_py3 import CustomCertificate from ._models_py3 import CustomCertificateList from ._models_py3 import CustomDomain @@ -65,12 +68,20 @@ from ._models_py3 import SkuCapacity from ._models_py3 import SkuList from ._models_py3 import SystemData +from ._models_py3 import ThrottleByJwtCustomClaimRule +from ._models_py3 import ThrottleByJwtSignatureRule +from ._models_py3 import ThrottleByUserIdRule from ._models_py3 import TrackedResource +from ._models_py3 import TrafficThrottleByJwtCustomClaimRule +from ._models_py3 import TrafficThrottleByJwtSignatureRule +from ._models_py3 import TrafficThrottleByUserIdRule from ._models_py3 import UpstreamAuthSettings from ._models_py3 import UpstreamTemplate from ._models_py3 import UserAssignedIdentityProperty from ._signal_rmanagement_client_enums import ACLAction +from ._signal_rmanagement_client_enums import ClientConnectionCountRuleDiscriminator +from ._signal_rmanagement_client_enums import ClientTrafficControlRuleDiscriminator from ._signal_rmanagement_client_enums import CreatedByType from ._signal_rmanagement_client_enums import FeatureFlags from ._signal_rmanagement_client_enums import KeyType @@ -88,6 +99,9 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ + "ApplicationFirewallSettings", + "ClientConnectionCountRule", + "ClientTrafficControlRule", "CustomCertificate", "CustomCertificateList", "CustomDomain", @@ -147,11 +161,19 @@ "SkuCapacity", "SkuList", "SystemData", + "ThrottleByJwtCustomClaimRule", + "ThrottleByJwtSignatureRule", + "ThrottleByUserIdRule", "TrackedResource", + "TrafficThrottleByJwtCustomClaimRule", + "TrafficThrottleByJwtSignatureRule", + "TrafficThrottleByUserIdRule", "UpstreamAuthSettings", "UpstreamTemplate", "UserAssignedIdentityProperty", "ACLAction", + "ClientConnectionCountRuleDiscriminator", + "ClientTrafficControlRuleDiscriminator", "CreatedByType", "FeatureFlags", "KeyType", diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_models_py3.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_models_py3.py index c6b07d939cc1..48e8e2712fb3 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_models_py3.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_models_py3.py @@ -17,13 +17,125 @@ from .. import models as _models +class ApplicationFirewallSettings(_serialization.Model): + """Application firewall settings for the resource. + + :ivar client_connection_count_rules: Rules to control the client connection count. + :vartype client_connection_count_rules: + list[~azure.mgmt.signalr.models.ClientConnectionCountRule] + :ivar client_traffic_control_rules: Rules to control the client traffic. + :vartype client_traffic_control_rules: + list[~azure.mgmt.signalr.models.ClientTrafficControlRule] + """ + + _validation = { + "client_connection_count_rules": {"max_items": 10, "min_items": 0}, + "client_traffic_control_rules": {"max_items": 10, "min_items": 0}, + } + + _attribute_map = { + "client_connection_count_rules": {"key": "clientConnectionCountRules", "type": "[ClientConnectionCountRule]"}, + "client_traffic_control_rules": {"key": "clientTrafficControlRules", "type": "[ClientTrafficControlRule]"}, + } + + def __init__( + self, + *, + client_connection_count_rules: Optional[List["_models.ClientConnectionCountRule"]] = None, + client_traffic_control_rules: Optional[List["_models.ClientTrafficControlRule"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword client_connection_count_rules: Rules to control the client connection count. + :paramtype client_connection_count_rules: + list[~azure.mgmt.signalr.models.ClientConnectionCountRule] + :keyword client_traffic_control_rules: Rules to control the client traffic. + :paramtype client_traffic_control_rules: + list[~azure.mgmt.signalr.models.ClientTrafficControlRule] + """ + super().__init__(**kwargs) + self.client_connection_count_rules = client_connection_count_rules + self.client_traffic_control_rules = client_traffic_control_rules + + +class ClientConnectionCountRule(_serialization.Model): + """A base class for client connection count rules. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ThrottleByJwtCustomClaimRule, ThrottleByJwtSignatureRule, ThrottleByUserIdRule + + All required parameters must be populated in order to send to server. + + :ivar type: Required. Known values are: "ThrottleByJwtSignatureRule", "ThrottleByUserIdRule", + and "ThrottleByJwtCustomClaimRule". + :vartype type: str or ~azure.mgmt.signalr.models.ClientConnectionCountRuleDiscriminator + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + _subtype_map = { + "type": { + "ThrottleByJwtCustomClaimRule": "ThrottleByJwtCustomClaimRule", + "ThrottleByJwtSignatureRule": "ThrottleByJwtSignatureRule", + "ThrottleByUserIdRule": "ThrottleByUserIdRule", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type: Optional[str] = None + + +class ClientTrafficControlRule(_serialization.Model): + """A base class for client traffic control rules. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + TrafficThrottleByJwtCustomClaimRule, TrafficThrottleByJwtSignatureRule, + TrafficThrottleByUserIdRule + + All required parameters must be populated in order to send to server. + + :ivar type: Required. Known values are: "TrafficThrottleByJwtSignatureRule", + "TrafficThrottleByUserIdRule", and "TrafficThrottleByJwtCustomClaimRule". + :vartype type: str or ~azure.mgmt.signalr.models.ClientTrafficControlRuleDiscriminator + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + _subtype_map = { + "type": { + "TrafficThrottleByJwtCustomClaimRule": "TrafficThrottleByJwtCustomClaimRule", + "TrafficThrottleByJwtSignatureRule": "TrafficThrottleByJwtSignatureRule", + "TrafficThrottleByUserIdRule": "TrafficThrottleByUserIdRule", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type: Optional[str] = None + + 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. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -65,7 +177,7 @@ class ProxyResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -77,34 +189,16 @@ class ProxyResource(Resource): :vartype system_data: ~azure.mgmt.signalr.models.SystemData """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - class CustomCertificate(ProxyResource): """A custom certificate. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -209,10 +303,10 @@ class CustomDomain(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -767,7 +861,7 @@ def __init__( class NameAvailabilityParameters(_serialization.Model): """Data POST-ed to the nameAvailability action. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type: The resource type. Can be "Microsoft.SignalRService/SignalR", "Microsoft.SignalRService/WebPubSub", "Microsoft.SignalRService/SignalR/replicas" or @@ -1014,7 +1108,7 @@ def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylin class PrivateEndpointACL(NetworkACL): """ACL for a private endpoint. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar allow: Allowed request types. The value can be one or more of: ClientConnection, ServerConnection, RESTAPI. @@ -1064,7 +1158,7 @@ class PrivateEndpointConnection(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1174,7 +1268,7 @@ class PrivateLinkResource(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1350,10 +1444,10 @@ class TrackedResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1403,10 +1497,10 @@ class Replica(TrackedResource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1601,11 +1695,11 @@ class ResourceSku(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the SKU. Required. - Allowed values: Standard_S1, Free_F1, Premium_P1. Required. + Allowed values: Standard_S1, Free_F1, Premium_P1, Premium_P2. Required. :vartype name: str :ivar tier: Optional tier of this particular SKU. 'Standard' or 'Free'. @@ -1616,12 +1710,14 @@ class ResourceSku(_serialization.Model): :vartype size: str :ivar family: Not used. Retained for future use. :vartype family: str - :ivar capacity: Optional, integer. The unit count of the resource. 1 by default. + :ivar capacity: Optional, integer. The unit count of the resource. + 1 for Free_F1/Standard_S1/Premium_P1, 100 for Premium_P2 by default. If present, following values are allowed: - Free: 1; - Standard: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; - Premium: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100;. + Free_F1: 1; + Standard_S1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; + Premium_P1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; + Premium_P2: 100,200,300,400,500,600,700,800,900,1000;. :vartype capacity: int """ @@ -1650,19 +1746,21 @@ def __init__( """ :keyword name: The name of the SKU. Required. - Allowed values: Standard_S1, Free_F1, Premium_P1. Required. + Allowed values: Standard_S1, Free_F1, Premium_P1, Premium_P2. Required. :paramtype name: str :keyword tier: Optional tier of this particular SKU. 'Standard' or 'Free'. ``Basic`` is deprecated, use ``Standard`` instead. Known values are: "Free", "Basic", "Standard", and "Premium". :paramtype tier: str or ~azure.mgmt.signalr.models.SignalRSkuTier - :keyword capacity: Optional, integer. The unit count of the resource. 1 by default. + :keyword capacity: Optional, integer. The unit count of the resource. + 1 for Free_F1/Standard_S1/Premium_P1, 100 for Premium_P2 by default. If present, following values are allowed: - Free: 1; - Standard: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; - Premium: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100;. + Free_F1: 1; + Standard_S1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; + Premium_P1: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; + Premium_P2: 100,200,300,400,500,600,700,800,900,1000;. :paramtype capacity: int """ super().__init__(**kwargs) @@ -1689,17 +1787,37 @@ class ServerlessSettings(_serialization.Model): The service considers the client disconnected if it hasn't received a message (including keep-alive) in this interval. :vartype connection_timeout_in_seconds: int + :ivar keep_alive_interval_in_seconds: Gets or sets the Keep-Alive Interval. Optional to set. + Value is in seconds. + The default value is 15 seconds. + Customers should set this value to a shorter period if they want the service to send + keep-alive messages more frequently, + ensuring timely checks of the connection status. + Conversely, customers can set this value to a longer period if they want the service to send + keep-alive messages less frequently, + reducing network traffic, but note that it may take longer to detect a disconnection. + This interval ensures that the connection is maintained by sending periodic keep-alive + messages to the client. + :vartype keep_alive_interval_in_seconds: int """ _validation = { "connection_timeout_in_seconds": {"maximum": 120, "minimum": 1}, + "keep_alive_interval_in_seconds": {"maximum": 120, "minimum": 1}, } _attribute_map = { "connection_timeout_in_seconds": {"key": "connectionTimeoutInSeconds", "type": "int"}, + "keep_alive_interval_in_seconds": {"key": "keepAliveIntervalInSeconds", "type": "int"}, } - def __init__(self, *, connection_timeout_in_seconds: int = 30, **kwargs: Any) -> None: + def __init__( + self, + *, + connection_timeout_in_seconds: int = 30, + keep_alive_interval_in_seconds: Optional[int] = None, + **kwargs: Any + ) -> None: """ :keyword connection_timeout_in_seconds: Gets or sets Client Connection Timeout. Optional to be set. @@ -1714,9 +1832,22 @@ def __init__(self, *, connection_timeout_in_seconds: int = 30, **kwargs: Any) -> The service considers the client disconnected if it hasn't received a message (including keep-alive) in this interval. :paramtype connection_timeout_in_seconds: int + :keyword keep_alive_interval_in_seconds: Gets or sets the Keep-Alive Interval. Optional to set. + Value is in seconds. + The default value is 15 seconds. + Customers should set this value to a shorter period if they want the service to send + keep-alive messages more frequently, + ensuring timely checks of the connection status. + Conversely, customers can set this value to a longer period if they want the service to send + keep-alive messages less frequently, + reducing network traffic, but note that it may take longer to detect a disconnection. + This interval ensures that the connection is maintained by sending periodic keep-alive + messages to the client. + :paramtype keep_alive_interval_in_seconds: int """ super().__init__(**kwargs) self.connection_timeout_in_seconds = connection_timeout_in_seconds + self.keep_alive_interval_in_seconds = keep_alive_interval_in_seconds class ServerlessUpstreamSettings(_serialization.Model): @@ -1858,7 +1989,7 @@ class SharedPrivateLinkResource(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1880,6 +2011,8 @@ class SharedPrivateLinkResource(ProxyResource): :ivar request_message: The request message for requesting approval of the shared private link resource. :vartype request_message: str + :ivar fqdns: A list of FQDNs for third party private link service. + :vartype fqdns: list[str] :ivar status: Status of the shared private link resource. Known values are: "Pending", "Approved", "Rejected", "Disconnected", and "Timeout". :vartype status: str or ~azure.mgmt.signalr.models.SharedPrivateLinkResourceStatus @@ -1903,6 +2036,7 @@ class SharedPrivateLinkResource(ProxyResource): "private_link_resource_id": {"key": "properties.privateLinkResourceId", "type": "str"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, "request_message": {"key": "properties.requestMessage", "type": "str"}, + "fqdns": {"key": "properties.fqdns", "type": "[str]"}, "status": {"key": "properties.status", "type": "str"}, } @@ -1912,6 +2046,7 @@ def __init__( group_id: Optional[str] = None, private_link_resource_id: Optional[str] = None, request_message: Optional[str] = None, + fqdns: Optional[List[str]] = None, **kwargs: Any ) -> None: """ @@ -1924,12 +2059,15 @@ def __init__( :keyword request_message: The request message for requesting approval of the shared private link resource. :paramtype request_message: str + :keyword fqdns: A list of FQDNs for third party private link service. + :paramtype fqdns: list[str] """ super().__init__(**kwargs) self.group_id = group_id self.private_link_resource_id = private_link_resource_id self.provisioning_state = None self.request_message = request_message + self.fqdns = fqdns self.status = None @@ -1996,7 +2134,7 @@ def __init__(self, *, allowed_origins: Optional[List[str]] = None, **kwargs: Any class SignalRFeature(_serialization.Model): """Feature of a resource, which controls the runtime behavior. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar flag: FeatureFlags is the supported features of Azure SignalR service. @@ -2174,10 +2312,10 @@ class SignalRResource(TrackedResource): # pylint: disable=too-many-instance-att Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -2246,6 +2384,8 @@ class SignalRResource(TrackedResource): # pylint: disable=too-many-instance-att :vartype upstream: ~azure.mgmt.signalr.models.ServerlessUpstreamSettings :ivar network_ac_ls: Network ACLs for the resource. :vartype network_ac_ls: ~azure.mgmt.signalr.models.SignalRNetworkACLs + :ivar application_firewall: Application firewall settings for the resource. + :vartype application_firewall: ~azure.mgmt.signalr.models.ApplicationFirewallSettings :ivar public_network_access: Enable or disable public network access. Default to "Enabled". When it's Enabled, network ACLs still apply. When it's Disabled, public network access is always disabled no matter what you set in network @@ -2324,6 +2464,7 @@ class SignalRResource(TrackedResource): # pylint: disable=too-many-instance-att "serverless": {"key": "properties.serverless", "type": "ServerlessSettings"}, "upstream": {"key": "properties.upstream", "type": "ServerlessUpstreamSettings"}, "network_ac_ls": {"key": "properties.networkACLs", "type": "SignalRNetworkACLs"}, + "application_firewall": {"key": "properties.applicationFirewall", "type": "ApplicationFirewallSettings"}, "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, "disable_aad_auth": {"key": "properties.disableAadAuth", "type": "bool"}, @@ -2347,6 +2488,7 @@ def __init__( # pylint: disable=too-many-locals serverless: Optional["_models.ServerlessSettings"] = None, upstream: Optional["_models.ServerlessUpstreamSettings"] = None, network_ac_ls: Optional["_models.SignalRNetworkACLs"] = None, + application_firewall: Optional["_models.ApplicationFirewallSettings"] = None, public_network_access: str = "Enabled", disable_local_auth: bool = False, disable_aad_auth: bool = False, @@ -2390,6 +2532,8 @@ def __init__( # pylint: disable=too-many-locals :paramtype upstream: ~azure.mgmt.signalr.models.ServerlessUpstreamSettings :keyword network_ac_ls: Network ACLs for the resource. :paramtype network_ac_ls: ~azure.mgmt.signalr.models.SignalRNetworkACLs + :keyword application_firewall: Application firewall settings for the resource. + :paramtype application_firewall: ~azure.mgmt.signalr.models.ApplicationFirewallSettings :keyword public_network_access: Enable or disable public network access. Default to "Enabled". When it's Enabled, network ACLs still apply. When it's Disabled, public network access is always disabled no matter what you set in network @@ -2436,6 +2580,7 @@ def __init__( # pylint: disable=too-many-locals self.serverless = serverless self.upstream = upstream self.network_ac_ls = network_ac_ls + self.application_firewall = application_firewall self.public_network_access = public_network_access self.disable_local_auth = disable_local_auth self.disable_aad_auth = disable_aad_auth @@ -2780,6 +2925,286 @@ def __init__( self.last_modified_at = last_modified_at +class ThrottleByJwtCustomClaimRule(ClientConnectionCountRule): + """Throttle the client connection by a custom JWT claim. + + All required parameters must be populated in order to send to server. + + :ivar type: Required. Known values are: "ThrottleByJwtSignatureRule", "ThrottleByUserIdRule", + and "ThrottleByJwtCustomClaimRule". + :vartype type: str or ~azure.mgmt.signalr.models.ClientConnectionCountRuleDiscriminator + :ivar claim_name: The name of the claim in the JWT token. The client connection with the same + claim value will be aggregated. If the claim is not found in the token, the connection will be + allowed. Required. + :vartype claim_name: str + :ivar max_count: Maximum connection count allowed for the same Jwt claim value. Clients with + the same Jwt claim will get rejected if the connection count exceeds this value. Default value + is 20. + :vartype max_count: int + """ + + _validation = { + "type": {"required": True}, + "claim_name": {"required": True}, + "max_count": {"maximum": 2147483647, "minimum": 0}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "claim_name": {"key": "claimName", "type": "str"}, + "max_count": {"key": "maxCount", "type": "int"}, + } + + def __init__(self, *, claim_name: str, max_count: int = 20, **kwargs: Any) -> None: + """ + :keyword claim_name: The name of the claim in the JWT token. The client connection with the + same claim value will be aggregated. If the claim is not found in the token, the connection + will be allowed. Required. + :paramtype claim_name: str + :keyword max_count: Maximum connection count allowed for the same Jwt claim value. Clients with + the same Jwt claim will get rejected if the connection count exceeds this value. Default value + is 20. + :paramtype max_count: int + """ + super().__init__(**kwargs) + self.type: str = "ThrottleByJwtCustomClaimRule" + self.claim_name = claim_name + self.max_count = max_count + + +class ThrottleByJwtSignatureRule(ClientConnectionCountRule): + """Throttle the client connection by the JWT signature. + + All required parameters must be populated in order to send to server. + + :ivar type: Required. Known values are: "ThrottleByJwtSignatureRule", "ThrottleByUserIdRule", + and "ThrottleByJwtCustomClaimRule". + :vartype type: str or ~azure.mgmt.signalr.models.ClientConnectionCountRuleDiscriminator + :ivar max_count: Maximum connection count allowed for the same JWT signature. Clients with the + same JWT signature will get rejected if the connection count exceeds this value. Default value + is 20. + :vartype max_count: int + """ + + _validation = { + "type": {"required": True}, + "max_count": {"maximum": 2147483647, "minimum": 0}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "max_count": {"key": "maxCount", "type": "int"}, + } + + def __init__(self, *, max_count: int = 20, **kwargs: Any) -> None: + """ + :keyword max_count: Maximum connection count allowed for the same JWT signature. Clients with + the same JWT signature will get rejected if the connection count exceeds this value. Default + value is 20. + :paramtype max_count: int + """ + super().__init__(**kwargs) + self.type: str = "ThrottleByJwtSignatureRule" + self.max_count = max_count + + +class ThrottleByUserIdRule(ClientConnectionCountRule): + """Throttle the client connection by the user ID. + + All required parameters must be populated in order to send to server. + + :ivar type: Required. Known values are: "ThrottleByJwtSignatureRule", "ThrottleByUserIdRule", + and "ThrottleByJwtCustomClaimRule". + :vartype type: str or ~azure.mgmt.signalr.models.ClientConnectionCountRuleDiscriminator + :ivar max_count: Maximum connection count allowed for the same user ID. Clients with the same + user ID will get rejected if the connection count exceeds this value. Default value is 20. + :vartype max_count: int + """ + + _validation = { + "type": {"required": True}, + "max_count": {"maximum": 2147483647, "minimum": 0}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "max_count": {"key": "maxCount", "type": "int"}, + } + + def __init__(self, *, max_count: int = 20, **kwargs: Any) -> None: + """ + :keyword max_count: Maximum connection count allowed for the same user ID. Clients with the + same user ID will get rejected if the connection count exceeds this value. Default value is 20. + :paramtype max_count: int + """ + super().__init__(**kwargs) + self.type: str = "ThrottleByUserIdRule" + self.max_count = max_count + + +class TrafficThrottleByJwtCustomClaimRule(ClientTrafficControlRule): + """Throttle the client traffic by a custom JWT claim. + + All required parameters must be populated in order to send to server. + + :ivar type: Required. Known values are: "TrafficThrottleByJwtSignatureRule", + "TrafficThrottleByUserIdRule", and "TrafficThrottleByJwtCustomClaimRule". + :vartype type: str or ~azure.mgmt.signalr.models.ClientTrafficControlRuleDiscriminator + :ivar claim_name: The name of the claim in the JWT token. The message bytes with the same claim + value will be aggregated. If the claim is not found in the token, the rule will be skipped. + Required. + :vartype claim_name: str + :ivar max_inbound_message_bytes: Maximum accumulated inbound message bytes allowed for the same + JWT signature within a time window. Clients with the same JWT claim will get disconnected if + the message bytes exceeds this value. Default value is 1GB. + :vartype max_inbound_message_bytes: int + :ivar aggregation_window_in_seconds: The aggregation window for the message bytes. The message + bytes will be aggregated in this window and be reset after the window. Default value is 60 + seconds. + :vartype aggregation_window_in_seconds: int + """ + + _validation = { + "type": {"required": True}, + "claim_name": {"required": True}, + "max_inbound_message_bytes": {"minimum": 0}, + "aggregation_window_in_seconds": {"maximum": 3600, "minimum": 10}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "claim_name": {"key": "claimName", "type": "str"}, + "max_inbound_message_bytes": {"key": "maxInboundMessageBytes", "type": "int"}, + "aggregation_window_in_seconds": {"key": "aggregationWindowInSeconds", "type": "int"}, + } + + def __init__( + self, + *, + claim_name: str, + max_inbound_message_bytes: Optional[int] = None, + aggregation_window_in_seconds: int = 60, + **kwargs: Any + ) -> None: + """ + :keyword claim_name: The name of the claim in the JWT token. The message bytes with the same + claim value will be aggregated. If the claim is not found in the token, the rule will be + skipped. Required. + :paramtype claim_name: str + :keyword max_inbound_message_bytes: Maximum accumulated inbound message bytes allowed for the + same JWT signature within a time window. Clients with the same JWT claim will get disconnected + if the message bytes exceeds this value. Default value is 1GB. + :paramtype max_inbound_message_bytes: int + :keyword aggregation_window_in_seconds: The aggregation window for the message bytes. The + message bytes will be aggregated in this window and be reset after the window. Default value is + 60 seconds. + :paramtype aggregation_window_in_seconds: int + """ + super().__init__(**kwargs) + self.type: str = "TrafficThrottleByJwtCustomClaimRule" + self.claim_name = claim_name + self.max_inbound_message_bytes = max_inbound_message_bytes + self.aggregation_window_in_seconds = aggregation_window_in_seconds + + +class TrafficThrottleByJwtSignatureRule(ClientTrafficControlRule): + """Throttle the client traffic by the JWT signature. + + All required parameters must be populated in order to send to server. + + :ivar type: Required. Known values are: "TrafficThrottleByJwtSignatureRule", + "TrafficThrottleByUserIdRule", and "TrafficThrottleByJwtCustomClaimRule". + :vartype type: str or ~azure.mgmt.signalr.models.ClientTrafficControlRuleDiscriminator + :ivar max_inbound_message_bytes: Maximum accumulated inbound message bytes allowed for the same + JWT signature within a time window. Clients with the same JWT signature will get disconnected + if the message bytes exceeds this value. Default value is 1GB. + :vartype max_inbound_message_bytes: int + :ivar aggregation_window_in_seconds: The aggregation window for the message bytes. The message + bytes will be aggregated in this window and be reset after the window. Default value is 60 + seconds. + :vartype aggregation_window_in_seconds: int + """ + + _validation = { + "type": {"required": True}, + "max_inbound_message_bytes": {"minimum": 0}, + "aggregation_window_in_seconds": {"maximum": 3600, "minimum": 10}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "max_inbound_message_bytes": {"key": "maxInboundMessageBytes", "type": "int"}, + "aggregation_window_in_seconds": {"key": "aggregationWindowInSeconds", "type": "int"}, + } + + def __init__( + self, *, max_inbound_message_bytes: Optional[int] = None, aggregation_window_in_seconds: int = 60, **kwargs: Any + ) -> None: + """ + :keyword max_inbound_message_bytes: Maximum accumulated inbound message bytes allowed for the + same JWT signature within a time window. Clients with the same JWT signature will get + disconnected if the message bytes exceeds this value. Default value is 1GB. + :paramtype max_inbound_message_bytes: int + :keyword aggregation_window_in_seconds: The aggregation window for the message bytes. The + message bytes will be aggregated in this window and be reset after the window. Default value is + 60 seconds. + :paramtype aggregation_window_in_seconds: int + """ + super().__init__(**kwargs) + self.type: str = "TrafficThrottleByJwtSignatureRule" + self.max_inbound_message_bytes = max_inbound_message_bytes + self.aggregation_window_in_seconds = aggregation_window_in_seconds + + +class TrafficThrottleByUserIdRule(ClientTrafficControlRule): + """Throttle the client traffic by the user ID. + + All required parameters must be populated in order to send to server. + + :ivar type: Required. Known values are: "TrafficThrottleByJwtSignatureRule", + "TrafficThrottleByUserIdRule", and "TrafficThrottleByJwtCustomClaimRule". + :vartype type: str or ~azure.mgmt.signalr.models.ClientTrafficControlRuleDiscriminator + :ivar max_inbound_message_bytes: Maximum accumulated inbound message bytes allowed for the same + user ID within a time window. Clients with the same user ID will get disconnected if the + message bytes exceeds this value. Default value is 1GB. + :vartype max_inbound_message_bytes: int + :ivar aggregation_window_in_seconds: The aggregation window for the message bytes. The message + bytes will be aggregated in this window and be reset after the window. Default value is 60 + seconds. + :vartype aggregation_window_in_seconds: int + """ + + _validation = { + "type": {"required": True}, + "max_inbound_message_bytes": {"minimum": 0}, + "aggregation_window_in_seconds": {"maximum": 3600, "minimum": 10}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "max_inbound_message_bytes": {"key": "maxInboundMessageBytes", "type": "int"}, + "aggregation_window_in_seconds": {"key": "aggregationWindowInSeconds", "type": "int"}, + } + + def __init__( + self, *, max_inbound_message_bytes: Optional[int] = None, aggregation_window_in_seconds: int = 60, **kwargs: Any + ) -> None: + """ + :keyword max_inbound_message_bytes: Maximum accumulated inbound message bytes allowed for the + same user ID within a time window. Clients with the same user ID will get disconnected if the + message bytes exceeds this value. Default value is 1GB. + :paramtype max_inbound_message_bytes: int + :keyword aggregation_window_in_seconds: The aggregation window for the message bytes. The + message bytes will be aggregated in this window and be reset after the window. Default value is + 60 seconds. + :paramtype aggregation_window_in_seconds: int + """ + super().__init__(**kwargs) + self.type: str = "TrafficThrottleByUserIdRule" + self.max_inbound_message_bytes = max_inbound_message_bytes + self.aggregation_window_in_seconds = aggregation_window_in_seconds + + class UpstreamAuthSettings(_serialization.Model): """Upstream auth settings. If not set, no auth is used for upstream messages. @@ -2817,7 +3242,7 @@ class UpstreamTemplate(_serialization.Model): The template defines the pattern of the event, the hub or the category of the incoming request that matches current URL template. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar hub_pattern: Gets or sets the matching pattern for hub names. If not set, it matches any hub. @@ -2855,7 +3280,7 @@ class UpstreamTemplate(_serialization.Model): :ivar url_template: Gets or sets the Upstream URL template. You can use 3 predefined parameters {hub}, {category} {event} inside the template, the value of the Upstream URL is dynamically calculated when the client request comes in. - For example, if the urlTemplate is ``http://example.com/{hub}/api/{event}``\ , with a client + For example, if the urlTemplate is ``http://example.com/{hub}/api/{event}``\\ , with a client request from hub ``chat`` connects, it will first POST to this URL: ``http://example.com/chat/api/connect``. Required. :vartype url_template: str @@ -2922,7 +3347,7 @@ def __init__( :keyword url_template: Gets or sets the Upstream URL template. You can use 3 predefined parameters {hub}, {category} {event} inside the template, the value of the Upstream URL is dynamically calculated when the client request comes in. - For example, if the urlTemplate is ``http://example.com/{hub}/api/{event}``\ , with a client + For example, if the urlTemplate is ``http://example.com/{hub}/api/{event}``\\ , with a client request from hub ``chat`` connects, it will first POST to this URL: ``http://example.com/chat/api/connect``. Required. :paramtype url_template: str diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_signal_rmanagement_client_enums.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_signal_rmanagement_client_enums.py index 9a33fb791794..d89df6e2c1e4 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_signal_rmanagement_client_enums.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_signal_rmanagement_client_enums.py @@ -17,6 +17,22 @@ class ACLAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): DENY = "Deny" +class ClientConnectionCountRuleDiscriminator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ClientConnectionCountRuleDiscriminator.""" + + THROTTLE_BY_JWT_SIGNATURE_RULE = "ThrottleByJwtSignatureRule" + THROTTLE_BY_USER_ID_RULE = "ThrottleByUserIdRule" + THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE = "ThrottleByJwtCustomClaimRule" + + +class ClientTrafficControlRuleDiscriminator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ClientTrafficControlRuleDiscriminator.""" + + TRAFFIC_THROTTLE_BY_JWT_SIGNATURE_RULE = "TrafficThrottleByJwtSignatureRule" + TRAFFIC_THROTTLE_BY_USER_ID_RULE = "TrafficThrottleByUserIdRule" + TRAFFIC_THROTTLE_BY_JWT_CUSTOM_CLAIM_RULE = "TrafficThrottleByJwtCustomClaimRule" + + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource.""" diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/__init__.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/__init__.py index e15b22bc07ac..8119c1158f2d 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/__init__.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/__init__.py @@ -14,6 +14,9 @@ from ._signal_rprivate_endpoint_connections_operations import SignalRPrivateEndpointConnectionsOperations from ._signal_rprivate_link_resources_operations import SignalRPrivateLinkResourcesOperations from ._signal_rreplicas_operations import SignalRReplicasOperations +from ._signal_rreplica_shared_private_link_resources_operations import ( + SignalRReplicaSharedPrivateLinkResourcesOperations, +) from ._signal_rshared_private_link_resources_operations import SignalRSharedPrivateLinkResourcesOperations from ._patch import __all__ as _patch_all @@ -29,6 +32,7 @@ "SignalRPrivateEndpointConnectionsOperations", "SignalRPrivateLinkResourcesOperations", "SignalRReplicasOperations", + "SignalRReplicaSharedPrivateLinkResourcesOperations", "SignalRSharedPrivateLinkResourcesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_operations.py index 95ca3c13e0da..d9f5874bfd50 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +81,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available REST API operations of the Microsoft.SignalRService provider. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -89,7 +91,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,14 +102,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,13 +119,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationList", pipeline_response) @@ -135,11 +134,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,5 +150,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.SignalRService/operations"} diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_r_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_r_operations.py index c9e4108a6c81..1da66f0ed26d 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_r_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_r_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +48,7 @@ def build_check_name_availability_request(location: str, subscription_id: str, * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -74,7 +79,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,7 +103,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -128,7 +133,7 @@ def build_get_request(resource_group_name: str, resource_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -168,7 +173,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -211,7 +216,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -251,7 +256,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -294,7 +299,7 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -334,7 +339,7 @@ def build_regenerate_key_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -377,7 +382,7 @@ def build_list_replica_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -425,7 +430,7 @@ def build_restart_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -465,7 +470,7 @@ def build_list_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -529,14 +534,13 @@ def check_name_availability( ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. Required. + :param location: The region. Required. :type location: str :param parameters: Parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.signalr.models.NameAvailabilityParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: @@ -544,18 +548,17 @@ def check_name_availability( @overload def check_name_availability( - self, location: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. Required. + :param location: The region. Required. :type location: str :param parameters: Parameters supplied to the operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: @@ -563,24 +566,20 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, location: str, parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + self, location: str, parameters: Union[_models.NameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. Required. + :param location: The region. Required. :type location: str :param parameters: Parameters supplied to the operation. Is either a NameAvailabilityParameters - type or a IO type. Required. - :type parameters: ~azure.mgmt.signalr.models.NameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.NameAvailabilityParameters or IO[bytes] :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -603,23 +602,21 @@ def check_name_availability( else: _json = self._serialize.body(parameters, "NameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -629,22 +626,17 @@ 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("NameAvailability", pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SignalRResource"]: """Handles requests to list all resources in a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SignalRResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.SignalRResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -655,7 +647,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SignalRResour api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SignalRResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -666,15 +658,13 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SignalRResour def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -686,13 +676,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SignalRResourceList", pipeline_response) @@ -702,11 +691,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -719,10 +708,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/signalR" - } - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SignalRResource"]: """Handles requests to list all resources in a resource group. @@ -730,7 +715,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SignalRResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.SignalRResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -741,7 +725,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SignalRResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -752,16 +736,14 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -773,13 +755,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SignalRResourceList", pipeline_response) @@ -789,11 +770,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -806,10 +787,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR" - } - @distributed_trace def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.SignalRResource: """Get the resource and its properties. @@ -819,12 +796,11 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SignalRResource or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SignalRResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -838,21 +814,19 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SignalRResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -862,25 +836,21 @@ def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _m error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SignalRResource", pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - parameters: Union[_models.SignalRResource, IO], + parameters: Union[_models.SignalRResource, IO[bytes]], **kwargs: Any - ) -> Optional[_models.SignalRResource]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -893,7 +863,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.SignalRResource]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -903,7 +873,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "SignalRResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -911,40 +881,34 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("SignalRResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SignalRResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -968,14 +932,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either SignalRResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRResource] @@ -987,7 +943,7 @@ def begin_create_or_update( self, resource_group_name: str, resource_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1000,18 +956,10 @@ def begin_create_or_update( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: Parameters for the create or update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either SignalRResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRResource] @@ -1023,7 +971,7 @@ def begin_create_or_update( self, resource_group_name: str, resource_name: str, - parameters: Union[_models.SignalRResource, IO], + parameters: Union[_models.SignalRResource, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SignalRResource]: """Create or update a resource. @@ -1034,19 +982,8 @@ def begin_create_or_update( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: Parameters for the create or update operation. Is either a SignalRResource - type or a IO type. Required. - :type parameters: ~azure.mgmt.signalr.models.SignalRResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.SignalRResource or IO[bytes] :return: An instance of LROPoller that returns either SignalRResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRResource] @@ -1073,12 +1010,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SignalRResource", pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1090,22 +1028,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SignalRResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}" - } + return LROPoller[_models.SignalRResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1117,38 +1051,41 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1159,14 +1096,6 @@ def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: A :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1180,7 +1109,7 @@ def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: A lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, resource_name=resource_name, api_version=api_version, @@ -1189,11 +1118,12 @@ def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: A params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -1204,26 +1134,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _update_initial( self, resource_group_name: str, resource_name: str, - parameters: Union[_models.SignalRResource, IO], + parameters: Union[_models.SignalRResource, IO[bytes]], **kwargs: Any - ) -> Optional[_models.SignalRResource]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1236,7 +1162,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.SignalRResource]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1246,7 +1172,7 @@ def _update_initial( else: _json = self._serialize.body(parameters, "SignalRResource") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -1254,41 +1180,38 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SignalRResource", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -1312,14 +1235,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either SignalRResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRResource] @@ -1331,7 +1246,7 @@ def begin_update( self, resource_group_name: str, resource_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1344,18 +1259,10 @@ def begin_update( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: Parameters for the update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either SignalRResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRResource] @@ -1367,7 +1274,7 @@ def begin_update( self, resource_group_name: str, resource_name: str, - parameters: Union[_models.SignalRResource, IO], + parameters: Union[_models.SignalRResource, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SignalRResource]: """Operation to update an exiting resource. @@ -1378,19 +1285,8 @@ def begin_update( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: Parameters for the update operation. Is either a SignalRResource type or a - IO type. Required. - :type parameters: ~azure.mgmt.signalr.models.SignalRResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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. + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.SignalRResource or IO[bytes] :return: An instance of LROPoller that returns either SignalRResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRResource] @@ -1417,12 +1313,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SignalRResource", pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1434,17 +1331,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SignalRResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}" - } + return LROPoller[_models.SignalRResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_keys(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.SignalRKeys: @@ -1455,12 +1350,11 @@ def list_keys(self, resource_group_name: str, resource_name: str, **kwargs: Any) :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SignalRKeys or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SignalRKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1474,21 +1368,19 @@ def list_keys(self, resource_group_name: str, resource_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SignalRKeys] = kwargs.pop("cls", None) - request = build_list_keys_request( + _request = build_list_keys_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1498,25 +1390,21 @@ def list_keys(self, resource_group_name: str, resource_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SignalRKeys", pipeline_response) + deserialized = self._deserialize("SignalRKeys", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/listKeys" - } + return deserialized # type: ignore def _regenerate_key_initial( self, resource_group_name: str, resource_name: str, - parameters: Union[_models.RegenerateKeyParameters, IO], + parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], **kwargs: Any - ) -> _models.SignalRKeys: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1529,7 +1417,7 @@ def _regenerate_key_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SignalRKeys] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1539,7 +1427,7 @@ def _regenerate_key_initial( else: _json = self._serialize.body(parameters, "RegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, @@ -1547,43 +1435,39 @@ def _regenerate_key_initial( content_type=content_type, json=_json, content=_content, - template_url=self._regenerate_key_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SignalRKeys", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("SignalRKeys", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _regenerate_key_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/regenerateKey" - } - @overload def begin_regenerate_key( self, @@ -1607,14 +1491,6 @@ def begin_regenerate_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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either SignalRKeys or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRKeys] @@ -1626,7 +1502,7 @@ def begin_regenerate_key( self, resource_group_name: str, resource_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1640,18 +1516,10 @@ def begin_regenerate_key( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: Parameter that describes the Regenerate Key Operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either SignalRKeys or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRKeys] @@ -1663,7 +1531,7 @@ def begin_regenerate_key( self, resource_group_name: str, resource_name: str, - parameters: Union[_models.RegenerateKeyParameters, IO], + parameters: Union[_models.RegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SignalRKeys]: """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated @@ -1675,19 +1543,8 @@ def begin_regenerate_key( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: Parameter that describes the Regenerate Key Operation. Is either a - RegenerateKeyParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.signalr.models.RegenerateKeyParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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. + RegenerateKeyParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.RegenerateKeyParameters or IO[bytes] :return: An instance of LROPoller that returns either SignalRKeys or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRKeys] @@ -1714,12 +1571,13 @@ def begin_regenerate_key( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SignalRKeys", pipeline_response) + deserialized = self._deserialize("SignalRKeys", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1731,17 +1589,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SignalRKeys].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/regenerateKey" - } + return LROPoller[_models.SignalRKeys]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_replica_skus( @@ -1756,12 +1612,11 @@ def list_replica_skus( :type resource_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SkuList or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SkuList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1775,22 +1630,20 @@ def list_replica_skus( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SkuList] = kwargs.pop("cls", None) - request = build_list_replica_skus_request( + _request = build_list_replica_skus_request( resource_group_name=resource_group_name, resource_name=resource_name, replica_name=replica_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_replica_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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1800,21 +1653,15 @@ def list_replica_skus( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SkuList", pipeline_response) + deserialized = self._deserialize("SkuList", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_replica_skus.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}/skus" - } + return deserialized # type: ignore - def _restart_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: - error_map = { + def _restart_initial(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1826,28 +1673,31 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_restart_request( + _request = build_restart_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1856,12 +1706,12 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _restart_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/restart" - } + return deserialized # type: ignore @distributed_trace def begin_restart(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1872,14 +1722,6 @@ def begin_restart(self, resource_group_name: str, resource_name: str, **kwargs: :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1893,7 +1735,7 @@ def begin_restart(self, resource_group_name: str, resource_name: str, **kwargs: lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._restart_initial( # type: ignore + raw_result = self._restart_initial( resource_group_name=resource_group_name, resource_name=resource_name, api_version=api_version, @@ -1902,11 +1744,12 @@ def begin_restart(self, resource_group_name: str, resource_name: str, **kwargs: params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -1917,17 +1760,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_restart.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/restart" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_skus(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.SkuList: @@ -1938,12 +1777,11 @@ def list_skus(self, resource_group_name: str, resource_name: str, **kwargs: Any) :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SkuList or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SkuList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1957,21 +1795,19 @@ def list_skus(self, resource_group_name: str, resource_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SkuList] = kwargs.pop("cls", None) - request = build_list_skus_request( + _request = build_list_skus_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_skus.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1981,13 +1817,9 @@ def list_skus(self, resource_group_name: str, resource_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SkuList", pipeline_response) + deserialized = self._deserialize("SkuList", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_skus.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/skus" - } + return deserialized # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rcustom_certificates_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rcustom_certificates_operations.py index e62034b88d75..b033ec299e1f 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rcustom_certificates_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rcustom_certificates_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -85,7 +90,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -126,7 +131,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -170,7 +175,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -235,7 +240,6 @@ def list( :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CustomCertificate or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.CustomCertificate] :raises ~azure.core.exceptions.HttpResponseError: @@ -246,7 +250,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomCertificateList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -257,17 +261,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -279,13 +281,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("CustomCertificateList", pipeline_response) @@ -295,11 +296,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -312,10 +313,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates" - } - @distributed_trace def get( self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any @@ -329,12 +326,11 @@ def get( :type resource_name: str :param certificate_name: Custom certificate name. Required. :type certificate_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CustomCertificate or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.CustomCertificate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -348,22 +344,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomCertificate] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -373,26 +367,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CustomCertificate", pipeline_response) + deserialized = self._deserialize("CustomCertificate", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, certificate_name: str, - parameters: Union[_models.CustomCertificate, IO], + parameters: Union[_models.CustomCertificate, IO[bytes]], **kwargs: Any - ) -> _models.CustomCertificate: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -405,7 +395,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomCertificate] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -415,7 +405,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "CustomCertificate") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, @@ -424,40 +414,35 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("CustomCertificate", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CustomCertificate", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}" - } - @overload def begin_create_or_update( self, @@ -483,14 +468,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either CustomCertificate or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.CustomCertificate] @@ -503,7 +480,7 @@ def begin_create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -518,18 +495,10 @@ def begin_create_or_update( :param certificate_name: Custom certificate name. Required. :type certificate_name: str :param parameters: Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either CustomCertificate or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.CustomCertificate] @@ -542,7 +511,7 @@ def begin_create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - parameters: Union[_models.CustomCertificate, IO], + parameters: Union[_models.CustomCertificate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.CustomCertificate]: """Create or update a custom certificate. @@ -554,19 +523,8 @@ def begin_create_or_update( :type resource_name: str :param certificate_name: Custom certificate name. Required. :type certificate_name: str - :param parameters: Is either a CustomCertificate type or a IO type. Required. - :type parameters: ~azure.mgmt.signalr.models.CustomCertificate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param parameters: Is either a CustomCertificate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.CustomCertificate or IO[bytes] :return: An instance of LROPoller that returns either CustomCertificate or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.CustomCertificate] @@ -594,12 +552,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomCertificate", pipeline_response) + deserialized = self._deserialize("CustomCertificate", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -611,17 +570,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.CustomCertificate].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}" - } + return LROPoller[_models.CustomCertificate]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -636,12 +593,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_name: str :param certificate_name: Custom certificate name. Required. :type certificate_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -655,22 +611,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -681,8 +635,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rcustom_domains_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rcustom_domains_operations.py index 9662b6e18f26..14003eeb7ff4 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rcustom_domains_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rcustom_domains_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -85,7 +90,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -126,7 +131,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -170,7 +175,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -233,7 +238,6 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> I :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CustomDomain or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.CustomDomain] :raises ~azure.core.exceptions.HttpResponseError: @@ -244,7 +248,7 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> I api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomDomainList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,17 +259,15 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> I def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -277,13 +279,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("CustomDomainList", pipeline_response) @@ -293,11 +294,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -310,10 +311,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains" - } - @distributed_trace def get(self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any) -> _models.CustomDomain: """Get a custom domain. @@ -325,12 +322,11 @@ def get(self, resource_group_name: str, resource_name: str, name: str, **kwargs: :type resource_name: str :param name: Custom domain name. Required. :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CustomDomain or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.CustomDomain :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -344,22 +340,20 @@ def get(self, resource_group_name: str, resource_name: str, name: str, **kwargs: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, name=name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,26 +363,22 @@ def get(self, resource_group_name: str, resource_name: str, name: str, **kwargs: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, name: str, - parameters: Union[_models.CustomDomain, IO], + parameters: Union[_models.CustomDomain, IO[bytes]], **kwargs: Any - ) -> _models.CustomDomain: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -401,7 +391,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -411,7 +401,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "CustomDomain") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, name=name, @@ -420,35 +410,34 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -475,14 +464,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.CustomDomain] @@ -495,7 +476,7 @@ def begin_create_or_update( resource_group_name: str, resource_name: str, name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -510,18 +491,10 @@ def begin_create_or_update( :param name: Custom domain name. Required. :type name: str :param parameters: Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.CustomDomain] @@ -534,7 +507,7 @@ def begin_create_or_update( resource_group_name: str, resource_name: str, name: str, - parameters: Union[_models.CustomDomain, IO], + parameters: Union[_models.CustomDomain, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.CustomDomain]: """Create or update a custom domain. @@ -546,19 +519,8 @@ def begin_create_or_update( :type resource_name: str :param name: Custom domain name. Required. :type name: str - :param parameters: Is either a CustomDomain type or a IO type. Required. - :type parameters: ~azure.mgmt.signalr.models.CustomDomain or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param parameters: Is either a CustomDomain type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.CustomDomain or IO[bytes] :return: An instance of LROPoller that returns either CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.CustomDomain] @@ -586,12 +548,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -603,22 +566,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.CustomDomain].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}" - } + return LROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -630,39 +591,42 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, name=name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any) -> LROPoller[None]: @@ -675,14 +639,6 @@ def begin_delete(self, resource_group_name: str, resource_name: str, name: str, :type resource_name: str :param name: Custom domain name. Required. :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -696,7 +652,7 @@ def begin_delete(self, resource_group_name: str, resource_name: str, name: str, lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, resource_name=resource_name, name=name, @@ -706,11 +662,12 @@ def begin_delete(self, resource_group_name: str, resource_name: str, name: str, params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -721,14 +678,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rprivate_endpoint_connections_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rprivate_endpoint_connections_operations.py index 305559f8e82f..1722ee8eb04f 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rprivate_endpoint_connections_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rprivate_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +94,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -136,7 +141,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -186,7 +191,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -223,7 +228,7 @@ def build_delete_request( return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -class SignalRPrivateEndpointConnectionsOperations: +class SignalRPrivateEndpointConnectionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -253,7 +258,6 @@ def list( :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.PrivateEndpointConnection] @@ -265,7 +269,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -276,17 +280,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -298,13 +300,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionList", pipeline_response) @@ -314,11 +315,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -331,10 +332,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections" - } - @distributed_trace def get( self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any @@ -349,12 +346,11 @@ def get( :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -368,22 +364,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( private_endpoint_connection_name=private_endpoint_connection_name, resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -393,16 +387,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload def update( @@ -430,7 +420,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -442,7 +431,7 @@ def update( private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -458,11 +447,10 @@ def update( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: The resource of private endpoint and its properties. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -474,7 +462,7 @@ def update( private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection. @@ -488,17 +476,13 @@ def update( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: The resource of private endpoint and its properties. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type parameters: ~azure.mgmt.signalr.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 + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.PrivateEndpointConnection or IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -521,7 +505,7 @@ def update( else: _json = self._serialize.body(parameters, "PrivateEndpointConnection") - request = build_update_request( + _request = build_update_request( private_endpoint_connection_name=private_endpoint_connection_name, resource_group_name=resource_group_name, resource_name=resource_name, @@ -530,16 +514,14 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -549,21 +531,17 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -575,39 +553,42 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( private_endpoint_connection_name=private_endpoint_connection_name, resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -623,14 +604,6 @@ def begin_delete( :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -644,7 +617,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( private_endpoint_connection_name=private_endpoint_connection_name, resource_group_name=resource_group_name, resource_name=resource_name, @@ -654,11 +627,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -669,14 +643,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rprivate_link_resources_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rprivate_link_resources_operations.py index f871079d813f..6ae6707e8672 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rprivate_link_resources_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rprivate_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +45,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,7 +109,6 @@ def list( :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.PrivateLinkResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -117,7 +119,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -128,17 +130,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -150,13 +150,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceList", pipeline_response) @@ -166,11 +165,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -182,7 +181,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateLinkResources" - } diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rreplica_shared_private_link_resources_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rreplica_shared_private_link_resources_operations.py new file mode 100644 index 000000000000..3f9aefd2d991 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rreplica_shared_private_link_resources_operations.py @@ -0,0 +1,617 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, resource_name: str, replica_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}/sharedPrivateLinkResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", + ), + "replicaName": _SERIALIZER.url( + "replica_name", + replica_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", + ), + "replicaName": _SERIALIZER.url( + "replica_name", + replica_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", + ), + "sharedPrivateLinkResourceName": _SERIALIZER.url( + "shared_private_link_resource_name", + shared_private_link_resource_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceName": _SERIALIZER.url( + "resource_name", + resource_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", + ), + "replicaName": _SERIALIZER.url( + "replica_name", + replica_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", + ), + "sharedPrivateLinkResourceName": _SERIALIZER.url( + "shared_private_link_resource_name", + shared_private_link_resource_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +class SignalRReplicaSharedPrivateLinkResourcesOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.SignalRManagementClient`'s + :attr:`signal_rreplica_shared_private_link_resources` attribute. + """ + + models = _models + + 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, resource_name: str, replica_name: str, **kwargs: Any + ) -> Iterable["_models.SharedPrivateLinkResource"]: + """List shared private link resources. + + :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 resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :return: An iterator like instance of either SharedPrivateLinkResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SharedPrivateLinkResourceList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SharedPrivateLinkResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + **kwargs: Any + ) -> _models.SharedPrivateLinkResource: + """Get the specified shared private link resource. + + :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 resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :return: SharedPrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.signalr.models.SharedPrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + shared_private_link_resource_name=shared_private_link_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: Union[_models.SharedPrivateLinkResource, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SharedPrivateLinkResource") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + shared_private_link_resource_name=shared_private_link_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: _models.SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :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 resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: ~azure.mgmt.signalr.models.SharedPrivateLinkResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either SharedPrivateLinkResource or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :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 resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either SharedPrivateLinkResource or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + replica_name: str, + shared_private_link_resource_name: str, + parameters: Union[_models.SharedPrivateLinkResource, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :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 resource. Required. + :type resource_name: str + :param replica_name: The name of the replica. Required. + :type replica_name: str + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param parameters: The shared private link resource. Is either a SharedPrivateLinkResource type + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.SharedPrivateLinkResource or IO[bytes] + :return: An instance of LROPoller that returns either SharedPrivateLinkResource or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_name=resource_name, + replica_name=replica_name, + shared_private_link_resource_name=shared_private_link_resource_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SharedPrivateLinkResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SharedPrivateLinkResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rreplicas_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rreplicas_operations.py index 96a1e2028c29..528f2abb3722 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rreplicas_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rreplicas_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -85,7 +90,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -133,7 +138,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -184,7 +189,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -232,7 +237,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -283,7 +288,7 @@ def build_restart_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -353,7 +358,6 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> I :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Replica or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.Replica] :raises ~azure.core.exceptions.HttpResponseError: @@ -364,7 +368,7 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> I api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReplicaList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -375,17 +379,15 @@ def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> I def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -397,13 +399,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ReplicaList", pipeline_response) @@ -413,11 +414,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -430,10 +431,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas" - } - @distributed_trace def get(self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any) -> _models.Replica: """Get the replica and its properties. @@ -445,12 +442,11 @@ def get(self, resource_group_name: str, resource_name: str, replica_name: str, * :type resource_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Replica or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.Replica :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -464,22 +460,20 @@ def get(self, resource_group_name: str, resource_name: str, replica_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Replica] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_name=resource_name, replica_name=replica_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -489,26 +483,22 @@ def get(self, resource_group_name: str, resource_name: str, replica_name: str, * error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = self._deserialize("Replica", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, replica_name: str, - parameters: Union[_models.Replica, IO], + parameters: Union[_models.Replica, IO[bytes]], **kwargs: Any - ) -> _models.Replica: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -521,7 +511,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -531,7 +521,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "Replica") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, replica_name=replica_name, @@ -540,40 +530,35 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Replica", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}" - } - @overload def begin_create_or_update( self, @@ -599,14 +584,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.Replica] :raises ~azure.core.exceptions.HttpResponseError: @@ -618,7 +595,7 @@ def begin_create_or_update( resource_group_name: str, resource_name: str, replica_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -633,18 +610,10 @@ def begin_create_or_update( :param replica_name: The name of the replica. Required. :type replica_name: str :param parameters: Parameters for the create or update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.Replica] :raises ~azure.core.exceptions.HttpResponseError: @@ -656,7 +625,7 @@ def begin_create_or_update( resource_group_name: str, resource_name: str, replica_name: str, - parameters: Union[_models.Replica, IO], + parameters: Union[_models.Replica, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Replica]: """Create or update a replica. @@ -669,19 +638,8 @@ def begin_create_or_update( :param replica_name: The name of the replica. Required. :type replica_name: str :param parameters: Parameters for the create or update operation. Is either a Replica type or a - IO type. Required. - :type parameters: ~azure.mgmt.signalr.models.Replica or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/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. + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.Replica or IO[bytes] :return: An instance of LROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.Replica] :raises ~azure.core.exceptions.HttpResponseError: @@ -708,12 +666,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = self._deserialize("Replica", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -725,17 +684,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Replica].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}" - } + return LROPoller[_models.Replica]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -750,12 +707,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -769,22 +725,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, replica_name=replica_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -795,21 +749,17 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}" - } + return cls(pipeline_response, None, {}) # type: ignore def _update_initial( self, resource_group_name: str, resource_name: str, replica_name: str, - parameters: Union[_models.Replica, IO], + parameters: Union[_models.Replica, IO[bytes]], **kwargs: Any - ) -> _models.Replica: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -822,7 +772,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Replica] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -832,7 +782,7 @@ def _update_initial( else: _json = self._serialize.body(parameters, "Replica") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, replica_name=replica_name, @@ -841,43 +791,39 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Replica", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}" - } - @overload def begin_update( self, @@ -903,14 +849,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.Replica] :raises ~azure.core.exceptions.HttpResponseError: @@ -922,7 +860,7 @@ def begin_update( resource_group_name: str, resource_name: str, replica_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -937,18 +875,10 @@ def begin_update( :param replica_name: The name of the replica. Required. :type replica_name: str :param parameters: Parameters for the update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.Replica] :raises ~azure.core.exceptions.HttpResponseError: @@ -960,7 +890,7 @@ def begin_update( resource_group_name: str, resource_name: str, replica_name: str, - parameters: Union[_models.Replica, IO], + parameters: Union[_models.Replica, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Replica]: """Operation to update an exiting replica. @@ -972,20 +902,9 @@ def begin_update( :type resource_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :param parameters: Parameters for the update operation. Is either a Replica type or a IO type. - Required. - :type parameters: ~azure.mgmt.signalr.models.Replica or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json', - 'text/json'. Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param parameters: Parameters for the update operation. Is either a Replica type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.signalr.models.Replica or IO[bytes] :return: An instance of LROPoller that returns either Replica or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.Replica] :raises ~azure.core.exceptions.HttpResponseError: @@ -1012,12 +931,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replica", pipeline_response) + deserialized = self._deserialize("Replica", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1029,22 +949,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Replica].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}" - } + return LROPoller[_models.Replica]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _restart_initial( # pylint: disable=inconsistent-return-statements + def _restart_initial( self, resource_group_name: str, resource_name: str, replica_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1056,29 +974,32 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_restart_request( + _request = build_restart_request( resource_group_name=resource_group_name, resource_name=resource_name, replica_name=replica_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._restart_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1087,12 +1008,12 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _restart_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}/restart" - } + return deserialized # type: ignore @distributed_trace def begin_restart( @@ -1107,14 +1028,6 @@ def begin_restart( :type resource_name: str :param replica_name: The name of the replica. Required. :type replica_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1128,7 +1041,7 @@ def begin_restart( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._restart_initial( # type: ignore + raw_result = self._restart_initial( resource_group_name=resource_group_name, resource_name=resource_name, replica_name=replica_name, @@ -1138,11 +1051,12 @@ def begin_restart( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -1153,14 +1067,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_restart.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/replicas/{replicaName}/restart" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rshared_private_link_resources_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rshared_private_link_resources_operations.py index 9647cafccd61..d39b600dec1c 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rshared_private_link_resources_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rshared_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +94,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +104,12 @@ def build_get_request( ) # pylint: disable=line-too-long path_format_arguments = { "sharedPrivateLinkResourceName": _SERIALIZER.url( - "shared_private_link_resource_name", shared_private_link_resource_name, "str" + "shared_private_link_resource_name", + shared_private_link_resource_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -136,7 +146,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -147,7 +157,12 @@ def build_create_or_update_request( ) # pylint: disable=line-too-long path_format_arguments = { "sharedPrivateLinkResourceName": _SERIALIZER.url( - "shared_private_link_resource_name", shared_private_link_resource_name, "str" + "shared_private_link_resource_name", + shared_private_link_resource_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -186,7 +201,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -196,7 +211,12 @@ def build_delete_request( ) # pylint: disable=line-too-long path_format_arguments = { "sharedPrivateLinkResourceName": _SERIALIZER.url( - "shared_private_link_resource_name", shared_private_link_resource_name, "str" + "shared_private_link_resource_name", + shared_private_link_resource_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$", ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -223,7 +243,7 @@ def build_delete_request( return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -class SignalRSharedPrivateLinkResourcesOperations: +class SignalRSharedPrivateLinkResourcesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -253,7 +273,6 @@ def list( :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SharedPrivateLinkResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.SharedPrivateLinkResource] @@ -265,7 +284,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SharedPrivateLinkResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -276,17 +295,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -298,13 +315,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SharedPrivateLinkResourceList", pipeline_response) @@ -314,11 +330,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -331,10 +347,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources" - } - @distributed_trace def get( self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any @@ -349,12 +361,11 @@ def get( :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedPrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SharedPrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -368,22 +379,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( shared_private_link_resource_name=shared_private_link_resource_name, resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -393,26 +402,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, - parameters: Union[_models.SharedPrivateLinkResource, IO], + parameters: Union[_models.SharedPrivateLinkResource, IO[bytes]], **kwargs: Any - ) -> _models.SharedPrivateLinkResource: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -425,7 +430,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SharedPrivateLinkResource] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -435,7 +440,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "SharedPrivateLinkResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( shared_private_link_resource_name=shared_private_link_resource_name, resource_group_name=resource_group_name, resource_name=resource_name, @@ -444,40 +449,35 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}" - } - @overload def begin_create_or_update( self, @@ -504,14 +504,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either SharedPrivateLinkResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SharedPrivateLinkResource] @@ -524,7 +516,7 @@ def begin_create_or_update( shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -540,18 +532,10 @@ def begin_create_or_update( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: The shared private link resource. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either SharedPrivateLinkResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SharedPrivateLinkResource] @@ -564,7 +548,7 @@ def begin_create_or_update( shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, - parameters: Union[_models.SharedPrivateLinkResource, IO], + parameters: Union[_models.SharedPrivateLinkResource, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SharedPrivateLinkResource]: """Create or update a shared private link resource. @@ -578,19 +562,8 @@ def begin_create_or_update( :param resource_name: The name of the resource. Required. :type resource_name: str :param parameters: The shared private link resource. Is either a SharedPrivateLinkResource type - or a IO type. Required. - :type parameters: ~azure.mgmt.signalr.models.SharedPrivateLinkResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.signalr.models.SharedPrivateLinkResource or IO[bytes] :return: An instance of LROPoller that returns either SharedPrivateLinkResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SharedPrivateLinkResource] @@ -618,12 +591,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -635,22 +609,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SharedPrivateLinkResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}" - } + return LROPoller[_models.SharedPrivateLinkResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -662,39 +634,42 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( shared_private_link_resource_name=shared_private_link_resource_name, resource_group_name=resource_group_name, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -710,14 +685,6 @@ def begin_delete( :type resource_group_name: str :param resource_name: The name of the resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -731,7 +698,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( shared_private_link_resource_name=shared_private_link_resource_name, resource_group_name=resource_group_name, resource_name=resource_name, @@ -741,11 +708,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -756,14 +724,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_usages_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_usages_operations.py index d48ed872f931..0d990c17b230 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_usages_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_usages_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_request(location: str, subscription_id: str, **kwargs: Any) -> Ht _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -88,7 +91,6 @@ def list(self, location: str, **kwargs: Any) -> Iterable["_models.SignalRUsage"] :param location: the location like "eastus". Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SignalRUsage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.SignalRUsage] :raises ~azure.core.exceptions.HttpResponseError: @@ -99,7 +101,7 @@ def list(self, location: str, **kwargs: Any) -> Iterable["_models.SignalRUsage"] api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SignalRUsageList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -110,16 +112,14 @@ def list(self, location: str, **kwargs: Any) -> Iterable["_models.SignalRUsage"] def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -131,13 +131,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SignalRUsageList", pipeline_response) @@ -147,11 +146,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -163,7 +162,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/usages" - } diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/operations_list.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/operations_list.py index e79c77362c77..2af46fabd0ac 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/operations_list.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/operations_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/Operations_List.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/Operations_List.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_check_name_availability.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_check_name_availability.py index ccf2e6923bc3..e5c44dcda458 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_check_name_availability.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_check_name_availability.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalR_CheckNameAvailability.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalR_CheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_create_or_update.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_create_or_update.py index d6865a294c01..b7820b00a7e6 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_create_or_update.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -58,7 +59,7 @@ def main(): "publicNetwork": {"allow": ["ClientConnection"]}, }, "publicNetworkAccess": "Enabled", - "serverless": {"connectionTimeoutInSeconds": 5}, + "serverless": {"connectionTimeoutInSeconds": 5, "keepAliveIntervalInSeconds": 5}, "tls": {"clientCertEnabled": False}, "upstream": { "templates": [ @@ -79,6 +80,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalR_CreateOrUpdate.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalR_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_delete.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_delete.py index 5b2c1fcaeeec..ee5014b18c27 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_delete.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalR_Delete.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalR_Delete.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_get.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_get.py index a3c6607c6504..120c0aeacf3d 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_get.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalR_Get.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalR_Get.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_by_resource_group.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_by_resource_group.py index 02083322c5d4..27ba38ac7bbf 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_by_resource_group.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalR_ListByResourceGroup.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalR_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_by_subscription.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_by_subscription.py index 201913bf0faa..c900c4b76d81 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_by_subscription.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_by_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalR_ListBySubscription.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalR_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_keys.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_keys.py index c72fbaaea080..a073ac54a17e 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_keys.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_keys.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalR_ListKeys.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalR_ListKeys.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_replica_skus.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_replica_skus.py index b36dacd3c4fe..7c5182d044fc 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_replica_skus.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_replica_skus.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalR_ListReplicaSkus.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalR_ListReplicaSkus.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_skus.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_skus.py index 47db232b95ce..155c55d9f8db 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_skus.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_skus.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalR_ListSkus.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalR_ListSkus.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_regenerate_key.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_regenerate_key.py index d42c3b8bdd30..517d0e3679c6 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_regenerate_key.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_regenerate_key.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalR_RegenerateKey.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalR_RegenerateKey.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_restart.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_restart.py index 637a577d6011..4aff60d8c4ac 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_restart.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_restart.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalR_Restart.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalR_Restart.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_update.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_update.py index 4a7af8c6c474..cc26eefaee37 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_update.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -58,7 +59,7 @@ def main(): "publicNetwork": {"allow": ["ClientConnection"]}, }, "publicNetworkAccess": "Enabled", - "serverless": {"connectionTimeoutInSeconds": 5}, + "serverless": {"connectionTimeoutInSeconds": 5, "keepAliveIntervalInSeconds": 5}, "tls": {"clientCertEnabled": False}, "upstream": { "templates": [ @@ -79,6 +80,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalR_Update.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalR_Update.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_create_or_update.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_create_or_update.py index 22b63e33e173..485ec7ec544e 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_create_or_update.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -44,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRCustomCertificates_CreateOrUpdate.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRCustomCertificates_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_delete.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_delete.py index bec8224d3282..7e4c97789b4e 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_delete.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -36,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRCustomCertificates_Delete.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRCustomCertificates_Delete.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_get.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_get.py index 65d1218ffc88..b7f562b964b3 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_get.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRCustomCertificates_Get.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRCustomCertificates_Get.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_list.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_list.py index 60bc26c57e41..c1fc769dba4b 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_list.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRCustomCertificates_List.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRCustomCertificates_List.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_create_or_update.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_create_or_update.py index 4c6e71c9fc54..30335c319938 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_create_or_update.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRCustomDomains_CreateOrUpdate.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRCustomDomains_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_delete.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_delete.py index 0f01df9c0a6e..cae8ac3c6e7f 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_delete.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRCustomDomains_Delete.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRCustomDomains_Delete.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_get.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_get.py index e221230f6d9b..5390adf001ef 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_get.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRCustomDomains_Get.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRCustomDomains_Get.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_list.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_list.py index dfce99e158e5..34f25263c231 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_list.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRCustomDomains_List.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRCustomDomains_List.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_delete.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_delete.py index d2601e67e484..1c474206661e 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_delete.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRPrivateEndpointConnections_Delete.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRPrivateEndpointConnections_Delete.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_get.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_get.py index 0710b311eb79..611be8eb1a16 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_get.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRPrivateEndpointConnections_Get.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRPrivateEndpointConnections_Get.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_list.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_list.py index a4df76dc4dbb..6336d42274cc 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_list.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRPrivateEndpointConnections_List.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRPrivateEndpointConnections_List.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_update.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_update.py index 567b5f62478a..3e3f50106b28 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_update.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -43,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRPrivateEndpointConnections_Update.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRPrivateEndpointConnections_Update.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_link_resources_list.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_link_resources_list.py index f7348c2156e0..c09eec4b7432 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_link_resources_list.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_link_resources_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRPrivateLinkResources_List.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRPrivateLinkResources_List.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplica_shared_private_link_resources_create_or_update.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplica_shared_private_link_resources_create_or_update.py new file mode 100644 index 000000000000..ae044c5c8075 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplica_shared_private_link_resources_create_or_update.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rreplica_shared_private_link_resources_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rreplica_shared_private_link_resources.begin_create_or_update( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + replica_name="mySignalRService-eastus", + shared_private_link_resource_name="upstream", + parameters={ + "properties": { + "groupId": "sites", + "privateLinkResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.Web/sites/myWebApp", + "requestMessage": "Please approve", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRReplicaSharedPrivateLinkResources_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplica_shared_private_link_resources_get.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplica_shared_private_link_resources_get.py new file mode 100644 index 000000000000..6c0f98578a03 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplica_shared_private_link_resources_get.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rreplica_shared_private_link_resources_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rreplica_shared_private_link_resources.get( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + replica_name="mySignalRService-eastus", + shared_private_link_resource_name="upstream", + ) + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRReplicaSharedPrivateLinkResources_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplica_shared_private_link_resources_list.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplica_shared_private_link_resources_list.py new file mode 100644 index 000000000000..ed27a1e39f7c --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplica_shared_private_link_resources_list.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rreplica_shared_private_link_resources_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rreplica_shared_private_link_resources.list( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + replica_name="mySignalRService-eastus", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRReplicaSharedPrivateLinkResources_List.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_create_or_update.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_create_or_update.py index 0a29d1a5d99a..374d1d837d9b 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_create_or_update.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -43,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRReplicas_CreateOrUpdate.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRReplicas_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_delete.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_delete.py index ee5af6332ca9..63702825e337 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_delete.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -36,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRReplicas_Delete.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRReplicas_Delete.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_get.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_get.py index a590ebb170fb..5807955a77ff 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_get.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRReplicas_Get.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRReplicas_Get.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_list.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_list.py index 8da70b2dd009..4bc1de3a6cbe 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_list.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRReplicas_List.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRReplicas_List.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_restart.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_restart.py index 2bdad1bbc109..8d348e9e3c00 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_restart.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_restart.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRReplicas_Restart.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRReplicas_Restart.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_update.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_update.py index 621877131023..a8e5174ea7bc 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_update.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rreplicas_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -43,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRReplicas_Update.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRReplicas_Update.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_create_or_update.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_create_or_update.py index 1d27604a2e58..82d0745af8d5 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_create_or_update.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -44,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRSharedPrivateLinkResources_CreateOrUpdate.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRSharedPrivateLinkResources_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_delete.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_delete.py index 21507649c827..6ae097b5a781 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_delete.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRSharedPrivateLinkResources_Delete.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRSharedPrivateLinkResources_Delete.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_get.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_get.py index b7ebf823170d..acd2e233f938 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_get.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRSharedPrivateLinkResources_Get.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRSharedPrivateLinkResources_Get.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_list.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_list.py index ea0565beb5c4..18b720ef3cb9 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_list.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/SignalRSharedPrivateLinkResources_List.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/SignalRSharedPrivateLinkResources_List.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/usages_list.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/usages_list.py index 39ca0381ec46..d8c172102215 100644 --- a/sdk/signalr/azure-mgmt-signalr/generated_samples/usages_list.py +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/usages_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.signalr import SignalRManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2023-08-01-preview/examples/Usages_List.json +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2024-10-01-preview/examples/Usages_List.json if __name__ == "__main__": main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/conftest.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/conftest.py new file mode 100644 index 000000000000..1b853f453eb5 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + signalrmanagement_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + signalrmanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + signalrmanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + signalrmanagement_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=signalrmanagement_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=signalrmanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=signalrmanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=signalrmanagement_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_operations.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_operations.py new file mode 100644 index 000000000000..6fba80a8e8e8 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_operations_async.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_operations_async.py new file mode 100644 index 000000000000..dd1354dd3727 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr.aio import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rcustom_certificates_operations.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rcustom_certificates_operations.py new file mode 100644 index 000000000000..b9baab494e96 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rcustom_certificates_operations.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementSignalRCustomCertificatesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.signal_rcustom_certificates.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.signal_rcustom_certificates.get( + resource_group_name=resource_group.name, + resource_name="str", + certificate_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.signal_rcustom_certificates.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + certificate_name="str", + parameters={ + "keyVaultBaseUri": "str", + "keyVaultSecretName": "str", + "id": "str", + "keyVaultSecretVersion": "str", + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.signal_rcustom_certificates.delete( + resource_group_name=resource_group.name, + resource_name="str", + certificate_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rcustom_certificates_operations_async.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rcustom_certificates_operations_async.py new file mode 100644 index 000000000000..05c9e5d66cb3 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rcustom_certificates_operations_async.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr.aio import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementSignalRCustomCertificatesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.signal_rcustom_certificates.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.signal_rcustom_certificates.get( + resource_group_name=resource_group.name, + resource_name="str", + certificate_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.signal_rcustom_certificates.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + certificate_name="str", + parameters={ + "keyVaultBaseUri": "str", + "keyVaultSecretName": "str", + "id": "str", + "keyVaultSecretVersion": "str", + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.signal_rcustom_certificates.delete( + resource_group_name=resource_group.name, + resource_name="str", + certificate_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rcustom_domains_operations.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rcustom_domains_operations.py new file mode 100644 index 000000000000..a3f92173ea2d --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rcustom_domains_operations.py @@ -0,0 +1,86 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementSignalRCustomDomainsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.signal_rcustom_domains.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.signal_rcustom_domains.get( + resource_group_name=resource_group.name, + resource_name="str", + name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.signal_rcustom_domains.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + name="str", + parameters={ + "customCertificate": {"id": "str"}, + "domainName": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.signal_rcustom_domains.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rcustom_domains_operations_async.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rcustom_domains_operations_async.py new file mode 100644 index 000000000000..064c4fafac28 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rcustom_domains_operations_async.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr.aio import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementSignalRCustomDomainsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.signal_rcustom_domains.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.signal_rcustom_domains.get( + resource_group_name=resource_group.name, + resource_name="str", + name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.signal_rcustom_domains.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + name="str", + parameters={ + "customCertificate": {"id": "str"}, + "domainName": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.signal_rcustom_domains.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_roperations.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_roperations.py new file mode 100644 index 000000000000..38382ec35d02 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_roperations.py @@ -0,0 +1,374 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementSignalROperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability(self, resource_group): + response = self.client.signal_r.check_name_availability( + location="str", + parameters={"name": "str", "type": "str"}, + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_subscription(self, resource_group): + response = self.client.signal_r.list_by_subscription( + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.signal_r.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.signal_r.get( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.signal_r.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + parameters={ + "location": "str", + "applicationFirewall": { + "clientConnectionCountRules": ["client_connection_count_rule"], + "clientTrafficControlRules": ["client_traffic_control_rule"], + }, + "cors": {"allowedOrigins": ["str"]}, + "disableAadAuth": False, + "disableLocalAuth": False, + "externalIP": "str", + "features": [{"flag": "str", "value": "str", "properties": {"str": "str"}}], + "hostName": "str", + "hostNamePrefix": "str", + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "kind": "str", + "liveTraceConfiguration": {"categories": [{"enabled": "str", "name": "str"}], "enabled": "false"}, + "name": "str", + "networkACLs": { + "defaultAction": "str", + "ipRules": [{"action": "str", "value": "str"}], + "privateEndpoints": [{"name": "str", "allow": ["str"], "deny": ["str"]}], + "publicNetwork": {"allow": ["str"], "deny": ["str"]}, + }, + "privateEndpointConnections": [ + { + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "Enabled", + "publicPort": 0, + "regionEndpointEnabled": "Enabled", + "resourceLogConfiguration": {"categories": [{"enabled": "str", "name": "str"}]}, + "resourceStopped": "false", + "serverPort": 0, + "serverless": {"connectionTimeoutInSeconds": 30, "keepAliveIntervalInSeconds": 0}, + "sharedPrivateLinkResources": [ + { + "fqdns": ["str"], + "groupId": "str", + "id": "str", + "name": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "requestMessage": "str", + "status": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "tls": {"clientCertEnabled": False}, + "type": "str", + "upstream": { + "templates": [ + { + "urlTemplate": "str", + "auth": {"managedIdentity": {"resource": "str"}, "type": "str"}, + "categoryPattern": "str", + "eventPattern": "str", + "hubPattern": "str", + } + ] + }, + "version": "str", + }, + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.signal_r.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.signal_r.begin_update( + resource_group_name=resource_group.name, + resource_name="str", + parameters={ + "location": "str", + "applicationFirewall": { + "clientConnectionCountRules": ["client_connection_count_rule"], + "clientTrafficControlRules": ["client_traffic_control_rule"], + }, + "cors": {"allowedOrigins": ["str"]}, + "disableAadAuth": False, + "disableLocalAuth": False, + "externalIP": "str", + "features": [{"flag": "str", "value": "str", "properties": {"str": "str"}}], + "hostName": "str", + "hostNamePrefix": "str", + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "kind": "str", + "liveTraceConfiguration": {"categories": [{"enabled": "str", "name": "str"}], "enabled": "false"}, + "name": "str", + "networkACLs": { + "defaultAction": "str", + "ipRules": [{"action": "str", "value": "str"}], + "privateEndpoints": [{"name": "str", "allow": ["str"], "deny": ["str"]}], + "publicNetwork": {"allow": ["str"], "deny": ["str"]}, + }, + "privateEndpointConnections": [ + { + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "Enabled", + "publicPort": 0, + "regionEndpointEnabled": "Enabled", + "resourceLogConfiguration": {"categories": [{"enabled": "str", "name": "str"}]}, + "resourceStopped": "false", + "serverPort": 0, + "serverless": {"connectionTimeoutInSeconds": 30, "keepAliveIntervalInSeconds": 0}, + "sharedPrivateLinkResources": [ + { + "fqdns": ["str"], + "groupId": "str", + "id": "str", + "name": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "requestMessage": "str", + "status": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "tls": {"clientCertEnabled": False}, + "type": "str", + "upstream": { + "templates": [ + { + "urlTemplate": "str", + "auth": {"managedIdentity": {"resource": "str"}, "type": "str"}, + "categoryPattern": "str", + "eventPattern": "str", + "hubPattern": "str", + } + ] + }, + "version": "str", + }, + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_keys(self, resource_group): + response = self.client.signal_r.list_keys( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_regenerate_key(self, resource_group): + response = self.client.signal_r.begin_regenerate_key( + resource_group_name=resource_group.name, + resource_name="str", + parameters={"keyType": "str"}, + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_replica_skus(self, resource_group): + response = self.client.signal_r.list_replica_skus( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_restart(self, resource_group): + response = self.client.signal_r.begin_restart( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_skus(self, resource_group): + response = self.client.signal_r.list_skus( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_roperations_async.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_roperations_async.py new file mode 100644 index 000000000000..82909dcadaa6 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_roperations_async.py @@ -0,0 +1,385 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr.aio import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementSignalROperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability(self, resource_group): + response = await self.client.signal_r.check_name_availability( + location="str", + parameters={"name": "str", "type": "str"}, + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_subscription(self, resource_group): + response = self.client.signal_r.list_by_subscription( + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.signal_r.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.signal_r.get( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.signal_r.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + parameters={ + "location": "str", + "applicationFirewall": { + "clientConnectionCountRules": ["client_connection_count_rule"], + "clientTrafficControlRules": ["client_traffic_control_rule"], + }, + "cors": {"allowedOrigins": ["str"]}, + "disableAadAuth": False, + "disableLocalAuth": False, + "externalIP": "str", + "features": [{"flag": "str", "value": "str", "properties": {"str": "str"}}], + "hostName": "str", + "hostNamePrefix": "str", + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "kind": "str", + "liveTraceConfiguration": {"categories": [{"enabled": "str", "name": "str"}], "enabled": "false"}, + "name": "str", + "networkACLs": { + "defaultAction": "str", + "ipRules": [{"action": "str", "value": "str"}], + "privateEndpoints": [{"name": "str", "allow": ["str"], "deny": ["str"]}], + "publicNetwork": {"allow": ["str"], "deny": ["str"]}, + }, + "privateEndpointConnections": [ + { + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "Enabled", + "publicPort": 0, + "regionEndpointEnabled": "Enabled", + "resourceLogConfiguration": {"categories": [{"enabled": "str", "name": "str"}]}, + "resourceStopped": "false", + "serverPort": 0, + "serverless": {"connectionTimeoutInSeconds": 30, "keepAliveIntervalInSeconds": 0}, + "sharedPrivateLinkResources": [ + { + "fqdns": ["str"], + "groupId": "str", + "id": "str", + "name": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "requestMessage": "str", + "status": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "tls": {"clientCertEnabled": False}, + "type": "str", + "upstream": { + "templates": [ + { + "urlTemplate": "str", + "auth": {"managedIdentity": {"resource": "str"}, "type": "str"}, + "categoryPattern": "str", + "eventPattern": "str", + "hubPattern": "str", + } + ] + }, + "version": "str", + }, + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.signal_r.begin_delete( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.signal_r.begin_update( + resource_group_name=resource_group.name, + resource_name="str", + parameters={ + "location": "str", + "applicationFirewall": { + "clientConnectionCountRules": ["client_connection_count_rule"], + "clientTrafficControlRules": ["client_traffic_control_rule"], + }, + "cors": {"allowedOrigins": ["str"]}, + "disableAadAuth": False, + "disableLocalAuth": False, + "externalIP": "str", + "features": [{"flag": "str", "value": "str", "properties": {"str": "str"}}], + "hostName": "str", + "hostNamePrefix": "str", + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "kind": "str", + "liveTraceConfiguration": {"categories": [{"enabled": "str", "name": "str"}], "enabled": "false"}, + "name": "str", + "networkACLs": { + "defaultAction": "str", + "ipRules": [{"action": "str", "value": "str"}], + "privateEndpoints": [{"name": "str", "allow": ["str"], "deny": ["str"]}], + "publicNetwork": {"allow": ["str"], "deny": ["str"]}, + }, + "privateEndpointConnections": [ + { + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "Enabled", + "publicPort": 0, + "regionEndpointEnabled": "Enabled", + "resourceLogConfiguration": {"categories": [{"enabled": "str", "name": "str"}]}, + "resourceStopped": "false", + "serverPort": 0, + "serverless": {"connectionTimeoutInSeconds": 30, "keepAliveIntervalInSeconds": 0}, + "sharedPrivateLinkResources": [ + { + "fqdns": ["str"], + "groupId": "str", + "id": "str", + "name": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "requestMessage": "str", + "status": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "tls": {"clientCertEnabled": False}, + "type": "str", + "upstream": { + "templates": [ + { + "urlTemplate": "str", + "auth": {"managedIdentity": {"resource": "str"}, "type": "str"}, + "categoryPattern": "str", + "eventPattern": "str", + "hubPattern": "str", + } + ] + }, + "version": "str", + }, + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_keys(self, resource_group): + response = await self.client.signal_r.list_keys( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_regenerate_key(self, resource_group): + response = await ( + await self.client.signal_r.begin_regenerate_key( + resource_group_name=resource_group.name, + resource_name="str", + parameters={"keyType": "str"}, + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_replica_skus(self, resource_group): + response = await self.client.signal_r.list_replica_skus( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_restart(self, resource_group): + response = await ( + await self.client.signal_r.begin_restart( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_skus(self, resource_group): + response = await self.client.signal_r.list_skus( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rprivate_endpoint_connections_operations.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rprivate_endpoint_connections_operations.py new file mode 100644 index 000000000000..c60817d294b2 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rprivate_endpoint_connections_operations.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementSignalRPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.signal_rprivate_endpoint_connections.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.signal_rprivate_endpoint_connections.get( + private_endpoint_connection_name="str", + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.signal_rprivate_endpoint_connections.update( + private_endpoint_connection_name="str", + resource_group_name=resource_group.name, + resource_name="str", + parameters={ + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": {"actionsRequired": "str", "description": "str", "status": "str"}, + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.signal_rprivate_endpoint_connections.begin_delete( + private_endpoint_connection_name="str", + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rprivate_endpoint_connections_operations_async.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rprivate_endpoint_connections_operations_async.py new file mode 100644 index 000000000000..e78f55652e21 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rprivate_endpoint_connections_operations_async.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr.aio import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementSignalRPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.signal_rprivate_endpoint_connections.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.signal_rprivate_endpoint_connections.get( + private_endpoint_connection_name="str", + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.signal_rprivate_endpoint_connections.update( + private_endpoint_connection_name="str", + resource_group_name=resource_group.name, + resource_name="str", + parameters={ + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": {"actionsRequired": "str", "description": "str", "status": "str"}, + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.signal_rprivate_endpoint_connections.begin_delete( + private_endpoint_connection_name="str", + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rprivate_link_resources_operations.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rprivate_link_resources_operations.py new file mode 100644 index 000000000000..c0b6c95c7fab --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rprivate_link_resources_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementSignalRPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.signal_rprivate_link_resources.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rprivate_link_resources_operations_async.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rprivate_link_resources_operations_async.py new file mode 100644 index 000000000000..77c06e8e41fa --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rprivate_link_resources_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr.aio import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementSignalRPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.signal_rprivate_link_resources.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rreplica_shared_private_link_resources_operations.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rreplica_shared_private_link_resources_operations.py new file mode 100644 index 000000000000..29e3f7b410de --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rreplica_shared_private_link_resources_operations.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementSignalRReplicaSharedPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.signal_rreplica_shared_private_link_resources.list( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.signal_rreplica_shared_private_link_resources.get( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + shared_private_link_resource_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.signal_rreplica_shared_private_link_resources.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + shared_private_link_resource_name="str", + parameters={ + "fqdns": ["str"], + "groupId": "str", + "id": "str", + "name": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "requestMessage": "str", + "status": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rreplica_shared_private_link_resources_operations_async.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rreplica_shared_private_link_resources_operations_async.py new file mode 100644 index 000000000000..5dde3f480d65 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rreplica_shared_private_link_resources_operations_async.py @@ -0,0 +1,82 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr.aio import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementSignalRReplicaSharedPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.signal_rreplica_shared_private_link_resources.list( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.signal_rreplica_shared_private_link_resources.get( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + shared_private_link_resource_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.signal_rreplica_shared_private_link_resources.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + shared_private_link_resource_name="str", + parameters={ + "fqdns": ["str"], + "groupId": "str", + "id": "str", + "name": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "requestMessage": "str", + "status": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rreplicas_operations.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rreplicas_operations.py new file mode 100644 index 000000000000..ed399919d648 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rreplicas_operations.py @@ -0,0 +1,134 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementSignalRReplicasOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.signal_rreplicas.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.signal_rreplicas.get( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.signal_rreplicas.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + parameters={ + "location": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "regionEndpointEnabled": "Enabled", + "resourceStopped": "false", + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.signal_rreplicas.delete( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.signal_rreplicas.begin_update( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + parameters={ + "location": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "regionEndpointEnabled": "Enabled", + "resourceStopped": "false", + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_restart(self, resource_group): + response = self.client.signal_rreplicas.begin_restart( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rreplicas_operations_async.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rreplicas_operations_async.py new file mode 100644 index 000000000000..7b0b0afac435 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rreplicas_operations_async.py @@ -0,0 +1,141 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr.aio import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementSignalRReplicasOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.signal_rreplicas.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.signal_rreplicas.get( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.signal_rreplicas.begin_create_or_update( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + parameters={ + "location": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "regionEndpointEnabled": "Enabled", + "resourceStopped": "false", + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.signal_rreplicas.delete( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.signal_rreplicas.begin_update( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + parameters={ + "location": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "regionEndpointEnabled": "Enabled", + "resourceStopped": "false", + "sku": {"name": "str", "capacity": 0, "family": "str", "size": "str", "tier": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_restart(self, resource_group): + response = await ( + await self.client.signal_rreplicas.begin_restart( + resource_group_name=resource_group.name, + resource_name="str", + replica_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rshared_private_link_resources_operations.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rshared_private_link_resources_operations.py new file mode 100644 index 000000000000..777a73045a8c --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rshared_private_link_resources_operations.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementSignalRSharedPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.signal_rshared_private_link_resources.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.signal_rshared_private_link_resources.get( + shared_private_link_resource_name="str", + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.signal_rshared_private_link_resources.begin_create_or_update( + shared_private_link_resource_name="str", + resource_group_name=resource_group.name, + resource_name="str", + parameters={ + "fqdns": ["str"], + "groupId": "str", + "id": "str", + "name": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "requestMessage": "str", + "status": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.signal_rshared_private_link_resources.begin_delete( + shared_private_link_resource_name="str", + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rshared_private_link_resources_operations_async.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rshared_private_link_resources_operations_async.py new file mode 100644 index 000000000000..4bf85eb78cd6 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_signal_rshared_private_link_resources_operations_async.py @@ -0,0 +1,94 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr.aio import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementSignalRSharedPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.signal_rshared_private_link_resources.list( + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.signal_rshared_private_link_resources.get( + shared_private_link_resource_name="str", + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.signal_rshared_private_link_resources.begin_create_or_update( + shared_private_link_resource_name="str", + resource_group_name=resource_group.name, + resource_name="str", + parameters={ + "fqdns": ["str"], + "groupId": "str", + "id": "str", + "name": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "requestMessage": "str", + "status": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.signal_rshared_private_link_resources.begin_delete( + shared_private_link_resource_name="str", + resource_group_name=resource_group.name, + resource_name="str", + api_version="2024-10-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_usages_operations.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_usages_operations.py new file mode 100644 index 000000000000..f0bfd88b942b --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_usages_operations.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementUsagesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.usages.list( + location="str", + api_version="2024-10-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_usages_operations_async.py b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_usages_operations_async.py new file mode 100644 index 000000000000..5986636dc657 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_tests/test_signal_rmanagement_usages_operations_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.signalr.aio import SignalRManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestSignalRManagementUsagesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SignalRManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.usages.list( + location="str", + api_version="2024-10-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/signalr/azure-mgmt-signalr/setup.py b/sdk/signalr/azure-mgmt-signalr/setup.py index 8c20f4d9c608..2523074ffcbb 100644 --- a/sdk/signalr/azure-mgmt-signalr/setup.py +++ b/sdk/signalr/azure-mgmt-signalr/setup.py @@ -53,11 +53,11 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -74,10 +74,10 @@ "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7", + python_requires=">=3.8", )