diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/CHANGELOG.md b/sdk/servicelinker/azure-mgmt-servicelinker/CHANGELOG.md index 0ffcc24b894b..f26f2a2ee1b0 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/CHANGELOG.md +++ b/sdk/servicelinker/azure-mgmt-servicelinker/CHANGELOG.md @@ -1,5 +1,14 @@ # Release History +## 1.2.0b3 (2024-10-11) + +### Features Added + + - Enum `AzureResourceType` added member `APP_CONFIG` + - Enum `TargetServiceType` added member `FABRIC_PLATFORM` + - Added model `AzureAppConfigProperties` + - Added model `FabricPlatform` + ## 1.2.0b2 (2024-03-19) ### Features Added diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/_meta.json b/sdk/servicelinker/azure-mgmt-servicelinker/_meta.json index 4ed77847eac8..8d57bb5d90ad 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/_meta.json +++ b/sdk/servicelinker/azure-mgmt-servicelinker/_meta.json @@ -1,11 +1,11 @@ { - "commit": "84849e5293de3a8e01cbdde13b2d7086d3fb34d6", + "commit": "b61dcef24c4dbd9d1c26e321c9ea67465a5d8be7", "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/servicelinker/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/servicelinker/resource-manager/readme.md --generate-sample=True --generate-test=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.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/servicelinker/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/assets.json b/sdk/servicelinker/azure-mgmt-servicelinker/assets.json deleted file mode 100644 index 05b606fa1e75..000000000000 --- a/sdk/servicelinker/azure-mgmt-servicelinker/assets.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "AssetsRepo": "Azure/azure-sdk-assets", - "AssetsRepoPrefixPath": "python", - "TagPrefix": "python/servicelinker/azure-mgmt-servicelinker", - "Tag": "python/servicelinker/azure-mgmt-servicelinker_929a1bd9c7" -} diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_configuration.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_configuration.py index 6a720fde399c..db59389ef848 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_configuration.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_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 ServiceLinkerManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ServiceLinkerManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ServiceLinkerManagementClient. Note that all parameters used to create this instance are saved as instance @@ -27,14 +26,13 @@ class ServiceLinkerManagementClientConfiguration(Configuration): # pylint: disa :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2023-04-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: - super(ServiceLinkerManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-04-01-preview") + api_version: str = kwargs.pop("api_version", "2024-07-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -43,6 +41,7 @@ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-servicelinker/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +50,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/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_patch.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_patch.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_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/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_serialization.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_serialization.py index 4bae2292227b..8139854b97bb 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_serialization.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_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/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_service_linker_management_client.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_service_linker_management_client.py index ade67153cd78..232da33028f5 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_service_linker_management_client.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_service_linker_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from ._configuration import ServiceLinkerManagementClientConfiguration @@ -45,7 +48,7 @@ class ServiceLinkerManagementClient: # pylint: disable=client-accepts-api-versi :type credential: ~azure.core.credentials.TokenCredential :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-04-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-07-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 @@ -56,7 +59,25 @@ def __init__( self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = ServiceLinkerManagementClientConfiguration(credential=credential, **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) @@ -70,7 +91,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -90,12 +111,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) -> "ServiceLinkerManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_vendor.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_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/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_version.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_version.py index 6f72e83fa148..5d2aea489e57 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_version.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.2.0b2" +VERSION = "1.2.0b3" diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_configuration.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_configuration.py index fb896e18f25e..aa280a9e587a 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_configuration.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/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 ServiceLinkerManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ServiceLinkerManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ServiceLinkerManagementClient. Note that all parameters used to create this instance are saved as instance @@ -27,14 +26,13 @@ class ServiceLinkerManagementClientConfiguration(Configuration): # pylint: disa :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2023-04-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-07-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - super(ServiceLinkerManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-04-01-preview") + api_version: str = kwargs.pop("api_version", "2024-07-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -43,6 +41,7 @@ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-servicelinker/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +50,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/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_patch.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_patch.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/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/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_service_linker_management_client.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_service_linker_management_client.py index b90e9bcaa431..f9c1d875e594 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_service_linker_management_client.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/_service_linker_management_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from .._serialization import Deserializer, Serializer @@ -46,7 +49,7 @@ class ServiceLinkerManagementClient: # pylint: disable=client-accepts-api-versi :type credential: ~azure.core.credentials_async.AsyncTokenCredential :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-04-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2024-07-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 @@ -57,7 +60,25 @@ def __init__( self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = ServiceLinkerManagementClientConfiguration(credential=credential, **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) @@ -71,7 +92,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -91,12 +114,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) -> "ServiceLinkerManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_configuration_names_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_configuration_names_operations.py index 2121eb93cab3..2ed1bd8c73a1 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_configuration_names_operations.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_configuration_names_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._configuration_names_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 filter: str :param skip_token: OData skipToken option for pagination. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ConfigurationNameItem or the result of cls(response) :rtype: @@ -76,7 +78,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ConfigurationNameResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -87,16 +89,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( filter=filter, skip_token=skip_token, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -108,13 +108,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ConfigurationNameResult", pipeline_response) @@ -124,11 +123,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -140,5 +139,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.ServiceLinker/configurationNames"} diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_connector_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_connector_operations.py index 951d8682e504..51fb25b41058 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_connector_operations.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_connector_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._connector_operations import ( build_create_dryrun_request, build_create_or_update_request, @@ -46,6 +47,10 @@ build_validate_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]] @@ -82,7 +87,6 @@ def list_dryrun( :type resource_group_name: str :param location: The name of Azure region. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DryrunResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicelinker.models.DryrunResource] @@ -94,7 +98,7 @@ def list_dryrun( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DryrunList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -105,17 +109,15 @@ def list_dryrun( def prepare_request(next_link=None): if not next_link: - request = build_list_dryrun_request( + _request = build_list_dryrun_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, api_version=api_version, - template_url=self.list_dryrun.metadata["url"], 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 @@ -127,13 +129,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("DryrunList", pipeline_response) @@ -143,11 +144,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 @@ -160,10 +161,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_dryrun.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/dryruns" - } - @distributed_trace_async async def get_dryrun( self, subscription_id: str, resource_group_name: str, location: str, dryrun_name: str, **kwargs: Any @@ -179,12 +176,11 @@ async def get_dryrun( :type location: str :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DryrunResource or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.DryrunResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -198,22 +194,20 @@ async def get_dryrun( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DryrunResource] = kwargs.pop("cls", None) - request = build_get_dryrun_request( + _request = build_get_dryrun_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, dryrun_name=dryrun_name, api_version=api_version, - template_url=self.get_dryrun.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -223,16 +217,12 @@ async def get_dryrun( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DryrunResource", pipeline_response) + deserialized = self._deserialize("DryrunResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_dryrun.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/dryruns/{dryrunName}" - } + return deserialized # type: ignore async def _create_dryrun_initial( self, @@ -240,10 +230,10 @@ async def _create_dryrun_initial( resource_group_name: str, location: str, dryrun_name: str, - parameters: Union[_models.DryrunResource, IO], + parameters: Union[_models.DryrunResource, IO[bytes]], **kwargs: Any - ) -> _models.DryrunResource: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,7 +246,7 @@ async def _create_dryrun_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.DryrunResource] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -266,7 +256,7 @@ async def _create_dryrun_initial( else: _json = self._serialize.body(parameters, "DryrunResource") - request = build_create_dryrun_request( + _request = build_create_dryrun_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, @@ -275,40 +265,35 @@ async def _create_dryrun_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_dryrun_initial.metadata["url"], headers=_headers, 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("DryrunResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DryrunResource", 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_dryrun_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/dryruns/{dryrunName}" - } - @overload async def begin_create_dryrun( self, @@ -337,14 +322,6 @@ async def begin_create_dryrun( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -358,7 +335,7 @@ async def begin_create_dryrun( resource_group_name: str, location: str, dryrun_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -375,18 +352,10 @@ async def begin_create_dryrun( :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str :param parameters: dryrun 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 DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -400,7 +369,7 @@ async def begin_create_dryrun( resource_group_name: str, location: str, dryrun_name: str, - parameters: Union[_models.DryrunResource, IO], + parameters: Union[_models.DryrunResource, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DryrunResource]: """create a dryrun job to do necessary check before actual creation. @@ -414,19 +383,9 @@ async def begin_create_dryrun( :type location: str :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str - :param parameters: dryrun resource. Is either a DryrunResource type or a IO type. Required. - :type parameters: ~azure.mgmt.servicelinker.models.DryrunResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: dryrun resource. Is either a DryrunResource type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.servicelinker.models.DryrunResource or IO[bytes] :return: An instance of AsyncLROPoller that returns either DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -455,12 +414,13 @@ async def begin_create_dryrun( 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("DryrunResource", pipeline_response) + deserialized = self._deserialize("DryrunResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -473,17 +433,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DryrunResource].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_dryrun.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/dryruns/{dryrunName}" - } + return AsyncLROPoller[_models.DryrunResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_dryrun_initial( self, @@ -491,10 +449,10 @@ async def _update_dryrun_initial( resource_group_name: str, location: str, dryrun_name: str, - parameters: Union[_models.DryrunPatch, IO], + parameters: Union[_models.DryrunPatch, IO[bytes]], **kwargs: Any - ) -> Optional[_models.DryrunResource]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -507,7 +465,7 @@ async def _update_dryrun_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.DryrunResource]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -517,7 +475,7 @@ async def _update_dryrun_initial( else: _json = self._serialize.body(parameters, "DryrunPatch") - request = build_update_dryrun_request( + _request = build_update_dryrun_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, @@ -526,37 +484,34 @@ async def _update_dryrun_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_dryrun_initial.metadata["url"], headers=_headers, 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 - if response.status_code == 200: - deserialized = self._deserialize("DryrunResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_dryrun_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/dryruns/{dryrunName}" - } + return deserialized # type: ignore @overload async def begin_update_dryrun( @@ -586,14 +541,6 @@ async def begin_update_dryrun( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -607,7 +554,7 @@ async def begin_update_dryrun( resource_group_name: str, location: str, dryrun_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -624,18 +571,10 @@ async def begin_update_dryrun( :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str :param parameters: dryrun 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 DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -649,7 +588,7 @@ async def begin_update_dryrun( resource_group_name: str, location: str, dryrun_name: str, - parameters: Union[_models.DryrunPatch, IO], + parameters: Union[_models.DryrunPatch, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DryrunResource]: """update a dryrun job to do necessary check before actual creation. @@ -663,19 +602,8 @@ async def begin_update_dryrun( :type location: str :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str - :param parameters: dryrun resource. Is either a DryrunPatch type or a IO type. Required. - :type parameters: ~azure.mgmt.servicelinker.models.DryrunPatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: dryrun resource. Is either a DryrunPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.servicelinker.models.DryrunPatch or IO[bytes] :return: An instance of AsyncLROPoller that returns either DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -704,12 +632,13 @@ async def begin_update_dryrun( 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("DryrunResource", pipeline_response) + deserialized = self._deserialize("DryrunResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -722,17 +651,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DryrunResource].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_dryrun.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/dryruns/{dryrunName}" - } + return AsyncLROPoller[_models.DryrunResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete_dryrun( # pylint: disable=inconsistent-return-statements @@ -749,12 +676,11 @@ async def delete_dryrun( # pylint: disable=inconsistent-return-statements :type location: str :param dryrun_name: The name of dryrun. Required. :type dryrun_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, @@ -768,22 +694,20 @@ async def delete_dryrun( # 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_dryrun_request( + _request = build_delete_dryrun_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, dryrun_name=dryrun_name, api_version=api_version, - template_url=self.delete_dryrun.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -794,11 +718,7 @@ async def delete_dryrun( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_dryrun.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/dryruns/{dryrunName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -814,7 +734,6 @@ def list( :type resource_group_name: str :param location: The name of Azure region. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LinkerResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicelinker.models.LinkerResource] @@ -826,7 +745,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -837,17 +756,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, 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 @@ -859,13 +776,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("ResourceList", pipeline_response) @@ -875,11 +791,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 @@ -892,10 +808,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/connectors" - } - @distributed_trace_async async def get( self, subscription_id: str, resource_group_name: str, location: str, connector_name: str, **kwargs: Any @@ -911,12 +823,11 @@ async def get( :type location: str :param connector_name: The name of resource. Required. :type connector_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LinkerResource or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.LinkerResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -930,22 +841,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LinkerResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, connector_name=connector_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -955,16 +864,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("LinkerResource", pipeline_response) + deserialized = self._deserialize("LinkerResource", 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.ServiceLinker/locations/{location}/connectors/{connectorName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, @@ -972,10 +877,10 @@ async def _create_or_update_initial( resource_group_name: str, location: str, connector_name: str, - parameters: Union[_models.LinkerResource, IO], + parameters: Union[_models.LinkerResource, IO[bytes]], **kwargs: Any - ) -> _models.LinkerResource: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -988,7 +893,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.LinkerResource] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -998,7 +903,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "LinkerResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, @@ -1007,40 +912,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("LinkerResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("LinkerResource", 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.ServiceLinker/locations/{location}/connectors/{connectorName}" - } - @overload async def begin_create_or_update( self, @@ -1069,14 +969,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 LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -1090,7 +982,7 @@ async def begin_create_or_update( resource_group_name: str, location: str, connector_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1107,18 +999,10 @@ async def begin_create_or_update( :param connector_name: The name of resource. Required. :type connector_name: str :param parameters: Connector details. 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 LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -1132,7 +1016,7 @@ async def begin_create_or_update( resource_group_name: str, location: str, connector_name: str, - parameters: Union[_models.LinkerResource, IO], + parameters: Union[_models.LinkerResource, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.LinkerResource]: """Create or update Connector resource. @@ -1146,19 +1030,9 @@ async def begin_create_or_update( :type location: str :param connector_name: The name of resource. Required. :type connector_name: str - :param parameters: Connector details. Is either a LinkerResource type or a IO type. Required. - :type parameters: ~azure.mgmt.servicelinker.models.LinkerResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Connector details. Is either a LinkerResource type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.servicelinker.models.LinkerResource or IO[bytes] :return: An instance of AsyncLROPoller that returns either LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -1187,12 +1061,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("LinkerResource", pipeline_response) + deserialized = self._deserialize("LinkerResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1205,22 +1080,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.LinkerResource].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.ServiceLinker/locations/{location}/connectors/{connectorName}" - } + return AsyncLROPoller[_models.LinkerResource]( + 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, subscription_id: str, resource_group_name: str, location: str, connector_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1232,39 +1105,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( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, connector_name=connector_name, 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.ServiceLinker/locations/{location}/connectors/{connectorName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -1281,14 +1157,6 @@ async def begin_delete( :type location: str :param connector_name: The name of resource. Required. :type connector_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: @@ -1302,7 +1170,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( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, @@ -1313,11 +1181,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( @@ -1329,17 +1198,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/connectors/{connectorName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _update_initial( self, @@ -1347,10 +1212,10 @@ async def _update_initial( resource_group_name: str, location: str, connector_name: str, - parameters: Union[_models.LinkerPatch, IO], + parameters: Union[_models.LinkerPatch, IO[bytes]], **kwargs: Any - ) -> _models.LinkerResource: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1363,7 +1228,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.LinkerResource] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1373,7 +1238,7 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "LinkerPatch") - request = build_update_request( + _request = build_update_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, @@ -1382,40 +1247,35 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _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) - if response.status_code == 200: - deserialized = self._deserialize("LinkerResource", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("LinkerResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/connectors/{connectorName}" - } - @overload async def begin_update( self, @@ -1444,14 +1304,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 LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -1465,7 +1317,7 @@ async def begin_update( resource_group_name: str, location: str, connector_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1482,18 +1334,10 @@ async def begin_update( :param connector_name: The name of resource. Required. :type connector_name: str :param parameters: Connector details. 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 LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -1507,7 +1351,7 @@ async def begin_update( resource_group_name: str, location: str, connector_name: str, - parameters: Union[_models.LinkerPatch, IO], + parameters: Union[_models.LinkerPatch, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.LinkerResource]: """Operation to update an existing Connector. @@ -1521,19 +1365,9 @@ async def begin_update( :type location: str :param connector_name: The name of resource. Required. :type connector_name: str - :param parameters: Connector details. Is either a LinkerPatch type or a IO type. Required. - :type parameters: ~azure.mgmt.servicelinker.models.LinkerPatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Connector details. Is either a LinkerPatch type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.servicelinker.models.LinkerPatch or IO[bytes] :return: An instance of AsyncLROPoller that returns either LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -1562,12 +1396,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("LinkerResource", pipeline_response) + deserialized = self._deserialize("LinkerResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1580,22 +1415,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.LinkerResource].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.ServiceLinker/locations/{location}/connectors/{connectorName}" - } + return AsyncLROPoller[_models.LinkerResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _validate_initial( self, subscription_id: str, resource_group_name: str, location: str, connector_name: str, **kwargs: Any - ) -> Optional[_models.ValidateOperationResult]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1607,45 +1440,42 @@ async def _validate_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.ValidateOperationResult]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_validate_request( + _request = build_validate_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, connector_name=connector_name, api_version=api_version, - template_url=self._validate_initial.metadata["url"], headers=_headers, 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 - if response.status_code == 200: - deserialized = self._deserialize("ValidateOperationResult", 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 - _validate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/connectors/{connectorName}/validate" - } + return deserialized # type: ignore @distributed_trace_async async def begin_validate( @@ -1662,14 +1492,6 @@ async def begin_validate( :type location: str :param connector_name: The name of resource. Required. :type connector_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 ValidateOperationResult or the result of cls(response) :rtype: @@ -1696,12 +1518,13 @@ async def begin_validate( 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("ValidateOperationResult", pipeline_response) + deserialized = self._deserialize("ValidateOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1713,17 +1536,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ValidateOperationResult].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_validate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/connectors/{connectorName}/validate" - } + return AsyncLROPoller[_models.ValidateOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @overload async def generate_configurations( @@ -1753,7 +1574,6 @@ async def generate_configurations( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ConfigurationResult or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.ConfigurationResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1766,7 +1586,7 @@ async def generate_configurations( resource_group_name: str, location: str, connector_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1783,11 +1603,10 @@ async def generate_configurations( :param connector_name: The name of resource. Required. :type connector_name: str :param parameters: Connection Info, including format, secret store, etc. Default value is None. - :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: ConfigurationResult or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.ConfigurationResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1800,7 +1619,7 @@ async def generate_configurations( resource_group_name: str, location: str, connector_name: str, - parameters: Optional[Union[_models.ConfigurationInfo, IO]] = None, + parameters: Optional[Union[_models.ConfigurationInfo, IO[bytes]]] = None, **kwargs: Any ) -> _models.ConfigurationResult: """Generate configurations for a Connector. @@ -1815,17 +1634,13 @@ async def generate_configurations( :param connector_name: The name of resource. Required. :type connector_name: str :param parameters: Connection Info, including format, secret store, etc. Is either a - ConfigurationInfo type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.servicelinker.models.ConfigurationInfo or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ConfigurationInfo type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.servicelinker.models.ConfigurationInfo or IO[bytes] :return: ConfigurationResult or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.ConfigurationResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1851,7 +1666,7 @@ async def generate_configurations( else: _json = None - request = build_generate_configurations_request( + _request = build_generate_configurations_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, @@ -1860,16 +1675,14 @@ async def generate_configurations( content_type=content_type, json=_json, content=_content, - template_url=self.generate_configurations.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -1879,13 +1692,9 @@ async def generate_configurations( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConfigurationResult", pipeline_response) + deserialized = self._deserialize("ConfigurationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - generate_configurations.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/connectors/{connectorName}/generateConfigurations" - } + return deserialized # type: ignore diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_linker_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_linker_operations.py index aa7384572e73..4099f256908a 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_linker_operations.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_linker_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._linker_operations import ( build_create_or_update_request, build_delete_request, @@ -41,6 +42,10 @@ build_validate_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_uri: str, **kwargs: Any) -> AsyncIterable["_models.Linke :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to be connected. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LinkerResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicelinker.models.LinkerResource] @@ -84,7 +88,7 @@ def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.Linke api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,15 +99,13 @@ def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.Linke def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_uri=resource_uri, 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 @@ -115,13 +117,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("ResourceList", pipeline_response) @@ -131,11 +132,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 @@ -148,8 +149,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers"} - @distributed_trace_async async def get(self, resource_uri: str, linker_name: str, **kwargs: Any) -> _models.LinkerResource: """Returns Linker resource for a given name. @@ -159,12 +158,11 @@ async def get(self, resource_uri: str, linker_name: str, **kwargs: Any) -> _mode :type resource_uri: str :param linker_name: The name Linker resource. Required. :type linker_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LinkerResource or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.LinkerResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -178,20 +176,18 @@ async def get(self, resource_uri: str, linker_name: str, **kwargs: Any) -> _mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LinkerResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_uri=resource_uri, linker_name=linker_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -201,19 +197,17 @@ async def get(self, resource_uri: str, linker_name: str, **kwargs: Any) -> _mode error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("LinkerResource", pipeline_response) + deserialized = self._deserialize("LinkerResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}"} + return deserialized # type: ignore async def _create_or_update_initial( - self, resource_uri: str, linker_name: str, parameters: Union[_models.LinkerResource, IO], **kwargs: Any - ) -> _models.LinkerResource: - error_map = { + self, resource_uri: str, linker_name: str, parameters: Union[_models.LinkerResource, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -226,7 +220,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.LinkerResource] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -236,47 +230,42 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "LinkerResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_uri=resource_uri, linker_name=linker_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _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("LinkerResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("LinkerResource", 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": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}" - } - @overload async def begin_create_or_update( self, @@ -299,14 +288,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 LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -318,7 +299,7 @@ async def begin_create_or_update( self, resource_uri: str, linker_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -331,18 +312,10 @@ async def begin_create_or_update( :param linker_name: The name Linker resource. Required. :type linker_name: str :param parameters: Linker details. 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 LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -351,7 +324,7 @@ async def begin_create_or_update( @distributed_trace_async async def begin_create_or_update( - self, resource_uri: str, linker_name: str, parameters: Union[_models.LinkerResource, IO], **kwargs: Any + self, resource_uri: str, linker_name: str, parameters: Union[_models.LinkerResource, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.LinkerResource]: """Create or update Linker resource. @@ -360,19 +333,9 @@ async def begin_create_or_update( :type resource_uri: str :param linker_name: The name Linker resource. Required. :type linker_name: str - :param parameters: Linker details. Is either a LinkerResource type or a IO type. Required. - :type parameters: ~azure.mgmt.servicelinker.models.LinkerResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Linker details. Is either a LinkerResource type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.servicelinker.models.LinkerResource or IO[bytes] :return: An instance of AsyncLROPoller that returns either LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -399,12 +362,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("LinkerResource", pipeline_response) + deserialized = self._deserialize("LinkerResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -417,20 +381,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.LinkerResource].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": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}"} + return AsyncLROPoller[_models.LinkerResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, linker_name: str, **kwargs: Any - ) -> None: - error_map = { + async def _delete_initial(self, resource_uri: str, linker_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -442,35 +404,40 @@ 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_uri=resource_uri, linker_name=linker_name, 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": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}"} + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_uri: str, linker_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -481,14 +448,6 @@ async def begin_delete(self, resource_uri: str, linker_name: str, **kwargs: Any) :type resource_uri: str :param linker_name: The name Linker resource. Required. :type linker_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: @@ -502,7 +461,7 @@ async def begin_delete(self, resource_uri: str, linker_name: str, **kwargs: Any) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_uri=resource_uri, linker_name=linker_name, api_version=api_version, @@ -511,11 +470,12 @@ async def begin_delete(self, resource_uri: str, linker_name: str, **kwargs: Any) 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( @@ -527,20 +487,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}"} + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _update_initial( - self, resource_uri: str, linker_name: str, parameters: Union[_models.LinkerPatch, IO], **kwargs: Any - ) -> _models.LinkerResource: - error_map = { + self, resource_uri: str, linker_name: str, parameters: Union[_models.LinkerPatch, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -553,7 +511,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.LinkerResource] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -563,45 +521,42 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "LinkerPatch") - request = build_update_request( + _request = build_update_request( resource_uri=resource_uri, linker_name=linker_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + 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("LinkerResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("LinkerResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}"} - @overload async def begin_update( self, @@ -624,14 +579,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 LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -643,7 +590,7 @@ async def begin_update( self, resource_uri: str, linker_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -656,18 +603,10 @@ async def begin_update( :param linker_name: The name Linker resource. Required. :type linker_name: str :param parameters: Linker details. 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 LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -676,7 +615,7 @@ async def begin_update( @distributed_trace_async async def begin_update( - self, resource_uri: str, linker_name: str, parameters: Union[_models.LinkerPatch, IO], **kwargs: Any + self, resource_uri: str, linker_name: str, parameters: Union[_models.LinkerPatch, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.LinkerResource]: """Operation to update an existing Linker. @@ -685,19 +624,8 @@ async def begin_update( :type resource_uri: str :param linker_name: The name Linker resource. Required. :type linker_name: str - :param parameters: Linker details. Is either a LinkerPatch type or a IO type. Required. - :type parameters: ~azure.mgmt.servicelinker.models.LinkerPatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Linker details. Is either a LinkerPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.servicelinker.models.LinkerPatch or IO[bytes] :return: An instance of AsyncLROPoller that returns either LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -724,12 +652,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("LinkerResource", pipeline_response) + deserialized = self._deserialize("LinkerResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -742,20 +671,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.LinkerResource].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": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}"} + return AsyncLROPoller[_models.LinkerResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _validate_initial( - self, resource_uri: str, linker_name: str, **kwargs: Any - ) -> Optional[_models.ValidateOperationResult]: - error_map = { + async def _validate_initial(self, resource_uri: str, linker_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -767,43 +694,40 @@ async def _validate_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.ValidateOperationResult]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_validate_request( + _request = build_validate_request( resource_uri=resource_uri, linker_name=linker_name, api_version=api_version, - template_url=self._validate_initial.metadata["url"], headers=_headers, 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 - if response.status_code == 200: - deserialized = self._deserialize("ValidateOperationResult", 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 - _validate_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/validateLinker" - } + return deserialized # type: ignore @distributed_trace_async async def begin_validate( @@ -816,14 +740,6 @@ async def begin_validate( :type resource_uri: str :param linker_name: The name Linker resource. Required. :type linker_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 ValidateOperationResult or the result of cls(response) :rtype: @@ -848,12 +764,13 @@ async def begin_validate( 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("ValidateOperationResult", pipeline_response) + deserialized = self._deserialize("ValidateOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -865,17 +782,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ValidateOperationResult].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_validate.metadata = { - "url": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/validateLinker" - } + return AsyncLROPoller[_models.ValidateOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def list_configurations( @@ -888,12 +803,11 @@ async def list_configurations( :type resource_uri: str :param linker_name: The name Linker resource. Required. :type linker_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ConfigurationResult or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.ConfigurationResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -907,20 +821,18 @@ async def list_configurations( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ConfigurationResult] = kwargs.pop("cls", None) - request = build_list_configurations_request( + _request = build_list_configurations_request( resource_uri=resource_uri, linker_name=linker_name, api_version=api_version, - template_url=self.list_configurations.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -930,13 +842,9 @@ async def list_configurations( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConfigurationResult", pipeline_response) + deserialized = self._deserialize("ConfigurationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_configurations.metadata = { - "url": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/listConfigurations" - } + return deserialized # type: ignore diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_linkers_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_linkers_operations.py index e0882cbe48c2..5d0d76806cae 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_linkers_operations.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_linkers_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._linkers_operations import ( build_create_dryrun_request, build_delete_dryrun_request, @@ -41,6 +42,10 @@ build_update_dryrun_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]] @@ -71,7 +76,6 @@ def list_dryrun(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_model :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to be connected. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DryrunResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.servicelinker.models.DryrunResource] @@ -83,7 +87,7 @@ def list_dryrun(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DryrunList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,15 +98,13 @@ def list_dryrun(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_model def prepare_request(next_link=None): if not next_link: - request = build_list_dryrun_request( + _request = build_list_dryrun_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list_dryrun.metadata["url"], 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 @@ -114,13 +116,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("DryrunList", pipeline_response) @@ -130,11 +131,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -147,8 +148,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_dryrun.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/dryruns"} - @distributed_trace_async async def get_dryrun(self, resource_uri: str, dryrun_name: str, **kwargs: Any) -> _models.DryrunResource: """get a dryrun job. @@ -158,12 +157,11 @@ async def get_dryrun(self, resource_uri: str, dryrun_name: str, **kwargs: Any) - :type resource_uri: str :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DryrunResource or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.DryrunResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -177,20 +175,18 @@ async def get_dryrun(self, resource_uri: str, dryrun_name: str, **kwargs: Any) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DryrunResource] = kwargs.pop("cls", None) - request = build_get_dryrun_request( + _request = build_get_dryrun_request( resource_uri=resource_uri, dryrun_name=dryrun_name, api_version=api_version, - template_url=self.get_dryrun.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -200,19 +196,17 @@ async def get_dryrun(self, resource_uri: str, dryrun_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("DryrunResource", pipeline_response) + deserialized = self._deserialize("DryrunResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_dryrun.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/dryruns/{dryrunName}"} + return deserialized # type: ignore async def _create_dryrun_initial( - self, resource_uri: str, dryrun_name: str, parameters: Union[_models.DryrunResource, IO], **kwargs: Any - ) -> _models.DryrunResource: - error_map = { + self, resource_uri: str, dryrun_name: str, parameters: Union[_models.DryrunResource, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -225,7 +219,7 @@ async def _create_dryrun_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.DryrunResource] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -235,45 +229,42 @@ async def _create_dryrun_initial( else: _json = self._serialize.body(parameters, "DryrunResource") - request = build_create_dryrun_request( + _request = build_create_dryrun_request( resource_uri=resource_uri, dryrun_name=dryrun_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._create_dryrun_initial.metadata["url"], headers=_headers, 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("DryrunResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DryrunResource", 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_dryrun_initial.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/dryruns/{dryrunName}"} - @overload async def begin_create_dryrun( self, @@ -296,14 +287,6 @@ async def begin_create_dryrun( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -315,7 +298,7 @@ async def begin_create_dryrun( self, resource_uri: str, dryrun_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -328,18 +311,10 @@ async def begin_create_dryrun( :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str :param parameters: dryrun 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 DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -348,7 +323,7 @@ async def begin_create_dryrun( @distributed_trace_async async def begin_create_dryrun( - self, resource_uri: str, dryrun_name: str, parameters: Union[_models.DryrunResource, IO], **kwargs: Any + self, resource_uri: str, dryrun_name: str, parameters: Union[_models.DryrunResource, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DryrunResource]: """create a dryrun job to do necessary check before actual creation. @@ -357,19 +332,9 @@ async def begin_create_dryrun( :type resource_uri: str :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str - :param parameters: dryrun resource. Is either a DryrunResource type or a IO type. Required. - :type parameters: ~azure.mgmt.servicelinker.models.DryrunResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: dryrun resource. Is either a DryrunResource type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.servicelinker.models.DryrunResource or IO[bytes] :return: An instance of AsyncLROPoller that returns either DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -396,12 +361,13 @@ async def begin_create_dryrun( 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("DryrunResource", pipeline_response) + deserialized = self._deserialize("DryrunResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -414,20 +380,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DryrunResource].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_dryrun.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/dryruns/{dryrunName}"} + return AsyncLROPoller[_models.DryrunResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_dryrun_initial( - self, resource_uri: str, dryrun_name: str, parameters: Union[_models.DryrunPatch, IO], **kwargs: Any - ) -> Optional[_models.DryrunResource]: - error_map = { + self, resource_uri: str, dryrun_name: str, parameters: Union[_models.DryrunPatch, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -440,7 +406,7 @@ async def _update_dryrun_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.DryrunResource]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -450,42 +416,41 @@ async def _update_dryrun_initial( else: _json = self._serialize.body(parameters, "DryrunPatch") - request = build_update_dryrun_request( + _request = build_update_dryrun_request( resource_uri=resource_uri, dryrun_name=dryrun_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._update_dryrun_initial.metadata["url"], headers=_headers, 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 - if response.status_code == 200: - deserialized = self._deserialize("DryrunResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_dryrun_initial.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/dryruns/{dryrunName}"} + return deserialized # type: ignore @overload async def begin_update_dryrun( @@ -509,14 +474,6 @@ async def begin_update_dryrun( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -528,7 +485,7 @@ async def begin_update_dryrun( self, resource_uri: str, dryrun_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -541,18 +498,10 @@ async def begin_update_dryrun( :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str :param parameters: dryrun 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 DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -561,7 +510,7 @@ async def begin_update_dryrun( @distributed_trace_async async def begin_update_dryrun( - self, resource_uri: str, dryrun_name: str, parameters: Union[_models.DryrunPatch, IO], **kwargs: Any + self, resource_uri: str, dryrun_name: str, parameters: Union[_models.DryrunPatch, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DryrunResource]: """add a dryrun job to do necessary check before actual creation. @@ -570,19 +519,8 @@ async def begin_update_dryrun( :type resource_uri: str :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str - :param parameters: dryrun resource. Is either a DryrunPatch type or a IO type. Required. - :type parameters: ~azure.mgmt.servicelinker.models.DryrunPatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: dryrun resource. Is either a DryrunPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.servicelinker.models.DryrunPatch or IO[bytes] :return: An instance of AsyncLROPoller that returns either DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -609,12 +547,13 @@ async def begin_update_dryrun( 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("DryrunResource", pipeline_response) + deserialized = self._deserialize("DryrunResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -627,15 +566,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DryrunResource].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_dryrun.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/dryruns/{dryrunName}"} + return AsyncLROPoller[_models.DryrunResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete_dryrun( # pylint: disable=inconsistent-return-statements @@ -648,12 +587,11 @@ async def delete_dryrun( # pylint: disable=inconsistent-return-statements :type resource_uri: str :param dryrun_name: The name of dryrun. Required. :type dryrun_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, @@ -667,20 +605,18 @@ async def delete_dryrun( # 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_dryrun_request( + _request = build_delete_dryrun_request( resource_uri=resource_uri, dryrun_name=dryrun_name, api_version=api_version, - template_url=self.delete_dryrun.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -691,9 +627,7 @@ async def delete_dryrun( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_dryrun.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/dryruns/{dryrunName}"} + return cls(pipeline_response, None, {}) # type: ignore @overload async def generate_configurations( @@ -717,7 +651,6 @@ async def generate_configurations( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ConfigurationResult or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.ConfigurationResult :raises ~azure.core.exceptions.HttpResponseError: @@ -728,7 +661,7 @@ async def generate_configurations( self, resource_uri: str, linker_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -741,11 +674,10 @@ async def generate_configurations( :param linker_name: The name Linker resource. Required. :type linker_name: str :param parameters: Connection Info, including format, secret store, etc. Default value is None. - :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: ConfigurationResult or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.ConfigurationResult :raises ~azure.core.exceptions.HttpResponseError: @@ -756,7 +688,7 @@ async def generate_configurations( self, resource_uri: str, linker_name: str, - parameters: Optional[Union[_models.ConfigurationInfo, IO]] = None, + parameters: Optional[Union[_models.ConfigurationInfo, IO[bytes]]] = None, **kwargs: Any ) -> _models.ConfigurationResult: """Generate configurations for a Linker. @@ -767,17 +699,13 @@ async def generate_configurations( :param linker_name: The name Linker resource. Required. :type linker_name: str :param parameters: Connection Info, including format, secret store, etc. Is either a - ConfigurationInfo type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.servicelinker.models.ConfigurationInfo or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ConfigurationInfo type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.servicelinker.models.ConfigurationInfo or IO[bytes] :return: ConfigurationResult or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.ConfigurationResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -803,23 +731,21 @@ async def generate_configurations( else: _json = None - request = build_generate_configurations_request( + _request = build_generate_configurations_request( resource_uri=resource_uri, linker_name=linker_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.generate_configurations.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -829,16 +755,12 @@ async def generate_configurations( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConfigurationResult", pipeline_response) + deserialized = self._deserialize("ConfigurationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - generate_configurations.metadata = { - "url": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/generateConfigurations" - } + return deserialized # type: ignore @distributed_trace def list_dapr_configurations( @@ -849,7 +771,6 @@ def list_dapr_configurations( :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to be connected. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DaprConfigurationResource or the result of cls(response) :rtype: @@ -862,7 +783,7 @@ def list_dapr_configurations( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DaprConfigurationList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -873,15 +794,13 @@ def list_dapr_configurations( def prepare_request(next_link=None): if not next_link: - request = build_list_dapr_configurations_request( + _request = build_list_dapr_configurations_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list_dapr_configurations.metadata["url"], 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 @@ -893,13 +812,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DaprConfigurationList", pipeline_response) @@ -909,11 +827,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 @@ -925,5 +843,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_dapr_configurations.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/daprConfigurations"} diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_operations.py index 672ca4560ab8..88b2f81c8d33 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/aio/operations/_operations.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/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 the available ServiceLinker REST API operations. - :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.servicelinker.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -67,7 +69,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -78,14 +80,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -97,13 +97,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -113,11 +112,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -129,5 +128,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.ServiceLinker/operations"} diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/__init__.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/__init__.py index 88a26589b666..fff44a3114d0 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/__init__.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/__init__.py @@ -8,6 +8,7 @@ from ._models_py3 import AccessKeyInfoBase from ._models_py3 import AuthInfoBase +from ._models_py3 import AzureAppConfigProperties from ._models_py3 import AzureKeyVaultProperties from ._models_py3 import AzureResource from ._models_py3 import AzureResourcePropertiesBase @@ -36,6 +37,7 @@ from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse +from ._models_py3 import FabricPlatform from ._models_py3 import FirewallRules from ._models_py3 import KeyVaultSecretReferenceSecretInfo from ._models_py3 import KeyVaultSecretUriSecretInfo @@ -95,6 +97,7 @@ __all__ = [ "AccessKeyInfoBase", "AuthInfoBase", + "AzureAppConfigProperties", "AzureKeyVaultProperties", "AzureResource", "AzureResourcePropertiesBase", @@ -123,6 +126,7 @@ "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", + "FabricPlatform", "FirewallRules", "KeyVaultSecretReferenceSecretInfo", "KeyVaultSecretUriSecretInfo", diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_models_py3.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_models_py3.py index 7ae228143b04..07d452598e2d 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_models_py3.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_models_py3.py @@ -25,7 +25,7 @@ class AuthInfoBase(_serialization.Model): ServicePrincipalCertificateAuthInfo, ServicePrincipalSecretAuthInfo, SystemAssignedIdentityAuthInfo, UserAccountAuthInfo, UserAssignedIdentityAuthInfo - 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 auth_type: The authentication type. Required. Known values are: "systemAssignedIdentity", "userAssignedIdentity", "servicePrincipalSecret", "servicePrincipalCertificate", "secret", @@ -77,7 +77,7 @@ class AccessKeyInfoBase(AuthInfoBase): """The access key directly from target resource properties, which target service is Azure Resource, such as Microsoft.Storage. - 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 auth_type: The authentication type. Required. Known values are: "systemAssignedIdentity", "userAssignedIdentity", "servicePrincipalSecret", "servicePrincipalCertificate", "secret", @@ -89,7 +89,7 @@ class AccessKeyInfoBase(AuthInfoBase): are: "optInAllAuth" and "optOutAllAuth". :vartype auth_mode: str or ~azure.mgmt.servicelinker.models.AuthMode :ivar permissions: Permissions of the accessKey. ``Read`` and ``Write`` are for Azure Cosmos DB - and Azure App Configuration, ``Listen``\ , ``Send`` and ``Manage`` are for Azure Event Hub and + and Azure App Configuration, ``Listen``\\ , ``Send`` and ``Manage`` are for Azure Event Hub and Azure Service Bus. :vartype permissions: list[str or ~azure.mgmt.servicelinker.models.AccessKeyPermissions] """ @@ -118,7 +118,7 @@ def __init__( Known values are: "optInAllAuth" and "optOutAllAuth". :paramtype auth_mode: str or ~azure.mgmt.servicelinker.models.AuthMode :keyword permissions: Permissions of the accessKey. ``Read`` and ``Write`` are for Azure Cosmos - DB and Azure App Configuration, ``Listen``\ , ``Send`` and ``Manage`` are for Azure Event Hub + DB and Azure App Configuration, ``Listen``\\ , ``Send`` and ``Manage`` are for Azure Event Hub and Azure Service Bus. :paramtype permissions: list[str or ~azure.mgmt.servicelinker.models.AccessKeyPermissions] """ @@ -131,11 +131,11 @@ class AzureResourcePropertiesBase(_serialization.Model): """The azure resource properties. You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AzureKeyVaultProperties + AzureAppConfigProperties, AzureKeyVaultProperties - 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 azure resource type. Required. "KeyVault" + :ivar type: The azure resource type. Required. Known values are: "KeyVault" and "AppConfig". :vartype type: str or ~azure.mgmt.servicelinker.models.AzureResourceType """ @@ -147,7 +147,7 @@ class AzureResourcePropertiesBase(_serialization.Model): "type": {"key": "type", "type": "str"}, } - _subtype_map = {"type": {"KeyVault": "AzureKeyVaultProperties"}} + _subtype_map = {"type": {"AppConfig": "AzureAppConfigProperties", "KeyVault": "AzureKeyVaultProperties"}} def __init__(self, **kwargs: Any) -> None: """ """ @@ -155,12 +155,44 @@ def __init__(self, **kwargs: Any) -> None: self.type: Optional[str] = None +class AzureAppConfigProperties(AzureResourcePropertiesBase): + """The resource properties when type is Azure App Configuration. + + All required parameters must be populated in order to send to server. + + :ivar type: The azure resource type. Required. Known values are: "KeyVault" and "AppConfig". + :vartype type: str or ~azure.mgmt.servicelinker.models.AzureResourceType + :ivar connect_with_kubernetes_extension: True if connection enables app configuration + kubernetes extension. + :vartype connect_with_kubernetes_extension: bool + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "connect_with_kubernetes_extension": {"key": "connectWithKubernetesExtension", "type": "bool"}, + } + + def __init__(self, *, connect_with_kubernetes_extension: Optional[bool] = None, **kwargs: Any) -> None: + """ + :keyword connect_with_kubernetes_extension: True if connection enables app configuration + kubernetes extension. + :paramtype connect_with_kubernetes_extension: bool + """ + super().__init__(**kwargs) + self.type: str = "AppConfig" + self.connect_with_kubernetes_extension = connect_with_kubernetes_extension + + class AzureKeyVaultProperties(AzureResourcePropertiesBase): """The resource properties when type is Azure Key Vault. - 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 azure resource type. Required. "KeyVault" + :ivar type: The azure resource type. Required. Known values are: "KeyVault" and "AppConfig". :vartype type: str or ~azure.mgmt.servicelinker.models.AzureResourceType :ivar connect_as_kubernetes_csi_driver: True if connect via Kubernetes CSI Driver. :vartype connect_as_kubernetes_csi_driver: bool @@ -189,12 +221,14 @@ class TargetServiceBase(_serialization.Model): """The target service properties. You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AzureResource, ConfluentBootstrapServer, ConfluentSchemaRegistry, SelfHostedServer + AzureResource, ConfluentBootstrapServer, ConfluentSchemaRegistry, FabricPlatform, + SelfHostedServer - 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 target service type. Required. Known values are: "AzureResource", - "ConfluentBootstrapServer", "ConfluentSchemaRegistry", and "SelfHostedServer". + "ConfluentBootstrapServer", "ConfluentSchemaRegistry", "SelfHostedServer", and + "FabricPlatform". :vartype type: str or ~azure.mgmt.servicelinker.models.TargetServiceType """ @@ -211,6 +245,7 @@ class TargetServiceBase(_serialization.Model): "AzureResource": "AzureResource", "ConfluentBootstrapServer": "ConfluentBootstrapServer", "ConfluentSchemaRegistry": "ConfluentSchemaRegistry", + "FabricPlatform": "FabricPlatform", "SelfHostedServer": "SelfHostedServer", } } @@ -224,10 +259,11 @@ def __init__(self, **kwargs: Any) -> None: class AzureResource(TargetServiceBase): """The azure resource info when target service type is AzureResource. - 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 target service type. Required. Known values are: "AzureResource", - "ConfluentBootstrapServer", "ConfluentSchemaRegistry", and "SelfHostedServer". + "ConfluentBootstrapServer", "ConfluentSchemaRegistry", "SelfHostedServer", and + "FabricPlatform". :vartype type: str or ~azure.mgmt.servicelinker.models.TargetServiceType :ivar id: The Id of azure resource. :vartype id: str @@ -270,7 +306,7 @@ class DryrunPrerequisiteResult(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: BasicErrorDryrunPrerequisiteResult, PermissionsMissingDryrunPrerequisiteResult - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type: The type of dryrun result. Required. Known values are: "basicError" and "permissionsMissing". @@ -301,7 +337,7 @@ def __init__(self, **kwargs: Any) -> None: class BasicErrorDryrunPrerequisiteResult(DryrunPrerequisiteResult): """The represent of basic error. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type: The type of dryrun result. Required. Known values are: "basicError" and "permissionsMissing". @@ -603,10 +639,11 @@ def __init__(self, *, app_configuration_id: Optional[str] = None, **kwargs: Any) class ConfluentBootstrapServer(TargetServiceBase): """The service properties when target service type is ConfluentBootstrapServer. - 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 target service type. Required. Known values are: "AzureResource", - "ConfluentBootstrapServer", "ConfluentSchemaRegistry", and "SelfHostedServer". + "ConfluentBootstrapServer", "ConfluentSchemaRegistry", "SelfHostedServer", and + "FabricPlatform". :vartype type: str or ~azure.mgmt.servicelinker.models.TargetServiceType :ivar endpoint: The endpoint of service. :vartype endpoint: str @@ -634,10 +671,11 @@ def __init__(self, *, endpoint: Optional[str] = None, **kwargs: Any) -> None: class ConfluentSchemaRegistry(TargetServiceBase): """The service properties when target service type is ConfluentSchemaRegistry. - 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 target service type. Required. Known values are: "AzureResource", - "ConfluentBootstrapServer", "ConfluentSchemaRegistry", and "SelfHostedServer". + "ConfluentBootstrapServer", "ConfluentSchemaRegistry", "SelfHostedServer", and + "FabricPlatform". :vartype type: str or ~azure.mgmt.servicelinker.models.TargetServiceType :ivar endpoint: The endpoint of service. :vartype endpoint: str @@ -758,7 +796,7 @@ class DryrunParameters(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: CreateOrUpdateDryrunParameters - 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 action_name: The name of action for you dryrun job. Required. "createOrUpdate" :vartype action_name: str or ~azure.mgmt.servicelinker.models.DryrunActionName @@ -785,7 +823,7 @@ class CreateOrUpdateDryrunParameters(DryrunParameters, LinkerProperties): 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 target_service: The target service properties. :vartype target_service: ~azure.mgmt.servicelinker.models.TargetServiceBase @@ -1238,7 +1276,7 @@ class Resource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1280,7 +1318,7 @@ class ProxyResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1292,24 +1330,6 @@ class ProxyResource(Resource): :vartype system_data: ~azure.mgmt.servicelinker.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 DryrunResource(ProxyResource): """a dryrun job resource. @@ -1317,7 +1337,7 @@ class DryrunResource(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1373,7 +1393,7 @@ def __init__(self, *, parameters: Optional["_models.DryrunParameters"] = None, * class EasyAuthMicrosoftEntraIDAuthInfo(AuthInfoBase): """The authentication info when authType is EasyAuth Microsoft Entra ID. - 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 auth_type: The authentication type. Required. Known values are: "systemAssignedIdentity", "userAssignedIdentity", "servicePrincipalSecret", "servicePrincipalCertificate", "secret", @@ -1529,6 +1549,38 @@ def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: A self.error = error +class FabricPlatform(TargetServiceBase): + """The service properties when target service type is FabricPlatform. + + All required parameters must be populated in order to send to server. + + :ivar type: The target service type. Required. Known values are: "AzureResource", + "ConfluentBootstrapServer", "ConfluentSchemaRegistry", "SelfHostedServer", and + "FabricPlatform". + :vartype type: str or ~azure.mgmt.servicelinker.models.TargetServiceType + :ivar endpoint: The endpoint of service. + :vartype endpoint: str + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, + } + + def __init__(self, *, endpoint: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword endpoint: The endpoint of service. + :paramtype endpoint: str + """ + super().__init__(**kwargs) + self.type: str = "FabricPlatform" + self.endpoint = endpoint + + class FirewallRules(_serialization.Model): """Target service's firewall rules. to allow connections from source service. @@ -1582,7 +1634,7 @@ class SecretInfoBase(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: KeyVaultSecretReferenceSecretInfo, KeyVaultSecretUriSecretInfo, ValueSecretInfo - 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 secret_type: The secret type. Required. Known values are: "rawValue", "keyVaultSecretUri", and "keyVaultSecretReference". @@ -1616,7 +1668,7 @@ class KeyVaultSecretReferenceSecretInfo(SecretInfoBase): secret stored in user's keyvault and source is Azure Kubernetes. The key Vault's resource id is linked to secretStore.keyVaultId. - 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 secret_type: The secret type. Required. Known values are: "rawValue", "keyVaultSecretUri", and "keyVaultSecretReference". @@ -1654,7 +1706,7 @@ class KeyVaultSecretUriSecretInfo(SecretInfoBase): """The secret info when type is keyVaultSecretUri. It's for scenario that user provides a secret stored in user's keyvault and source is Web App, Spring Cloud or Container App. - 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 secret_type: The secret type. Required. Known values are: "rawValue", "keyVaultSecretUri", and "keyVaultSecretReference". @@ -1778,7 +1830,7 @@ class LinkerResource(ProxyResource): # pylint: disable=too-many-instance-attrib Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -2002,10 +2054,10 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class PermissionsMissingDryrunPrerequisiteResult(DryrunPrerequisiteResult): +class PermissionsMissingDryrunPrerequisiteResult(DryrunPrerequisiteResult): # pylint: disable=name-too-long """The represent of missing permissions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type: The type of dryrun result. Required. Known values are: "basicError" and "permissionsMissing". @@ -2134,7 +2186,7 @@ def __init__( class SecretAuthInfo(AuthInfoBase): """The authentication info when authType is secret. - 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 auth_type: The authentication type. Required. Known values are: "systemAssignedIdentity", "userAssignedIdentity", "servicePrincipalSecret", "servicePrincipalCertificate", "secret", @@ -2220,10 +2272,11 @@ def __init__( class SelfHostedServer(TargetServiceBase): """The service properties when target service type is SelfHostedServer. - 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 target service type. Required. Known values are: "AzureResource", - "ConfluentBootstrapServer", "ConfluentSchemaRegistry", and "SelfHostedServer". + "ConfluentBootstrapServer", "ConfluentSchemaRegistry", "SelfHostedServer", and + "FabricPlatform". :vartype type: str or ~azure.mgmt.servicelinker.models.TargetServiceType :ivar endpoint: The endpoint of service. :vartype endpoint: str @@ -2251,7 +2304,7 @@ def __init__(self, *, endpoint: Optional[str] = None, **kwargs: Any) -> None: class ServicePrincipalCertificateAuthInfo(AuthInfoBase): """The authentication info when authType is servicePrincipal certificate. - 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 auth_type: The authentication type. Required. Known values are: "systemAssignedIdentity", "userAssignedIdentity", "servicePrincipalSecret", "servicePrincipalCertificate", "secret", @@ -2335,7 +2388,7 @@ def __init__( class ServicePrincipalSecretAuthInfo(AuthInfoBase, DatabaseAadAuthInfo): """The authentication info when authType is servicePrincipal secret. - 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 user_name: Username created in the database which is mapped to a user in AAD. :vartype user_name: str @@ -2485,7 +2538,7 @@ def __init__( class SystemAssignedIdentityAuthInfo(AuthInfoBase, DatabaseAadAuthInfo): """The authentication info when authType is systemAssignedIdentity. - 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 user_name: Username created in the database which is mapped to a user in AAD. :vartype user_name: str @@ -2617,7 +2670,7 @@ def __init__( class UserAccountAuthInfo(AuthInfoBase, DatabaseAadAuthInfo): """The authentication info when authType is user account. - 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 user_name: Username created in the database which is mapped to a user in AAD. :vartype user_name: str @@ -2692,7 +2745,7 @@ def __init__( class UserAssignedIdentityAuthInfo(AuthInfoBase, DatabaseAadAuthInfo): """The authentication info when authType is userAssignedIdentity. - 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 user_name: Username created in the database which is mapped to a user in AAD. :vartype user_name: str @@ -2922,7 +2975,7 @@ def __init__( class ValueSecretInfo(SecretInfoBase): """The secret info when type is rawValue. It's for scenarios that user input the secret. - 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 secret_type: The secret type. Required. Known values are: "rawValue", "keyVaultSecretUri", and "keyVaultSecretReference". diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_service_linker_management_client_enums.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_service_linker_management_client_enums.py index dac839a12e95..e2e26bea2d33 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_service_linker_management_client_enums.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/models/_service_linker_management_client_enums.py @@ -61,6 +61,7 @@ class AzureResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The azure resource type.""" KEY_VAULT = "KeyVault" + APP_CONFIG = "AppConfig" class ClientType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -177,6 +178,7 @@ class TargetServiceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): CONFLUENT_BOOTSTRAP_SERVER = "ConfluentBootstrapServer" CONFLUENT_SCHEMA_REGISTRY = "ConfluentSchemaRegistry" SELF_HOSTED_SERVER = "SelfHostedServer" + FABRIC_PLATFORM = "FabricPlatform" class ValidationResultStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_configuration_names_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_configuration_names_operations.py index 1de85a3f646d..d1a3d5b34aa9 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_configuration_names_operations.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_configuration_names_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(*, filter: Optional[str] = None, skip_token: Optional[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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +92,6 @@ def list( :type filter: str :param skip_token: OData skipToken option for pagination. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ConfigurationNameItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicelinker.models.ConfigurationNameItem] @@ -101,7 +103,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ConfigurationNameResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,16 +114,14 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( filter=filter, skip_token=skip_token, 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 @@ -133,13 +133,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("ConfigurationNameResult", pipeline_response) @@ -149,11 +148,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -165,5 +164,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.ServiceLinker/configurationNames"} diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_connector_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_connector_operations.py index 0bd59922ca38..4ea74c6ab1ac 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_connector_operations.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_connector_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_dryrun_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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +83,7 @@ def build_get_dryrun_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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +117,7 @@ def build_create_dryrun_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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -149,7 +154,7 @@ def build_update_dryrun_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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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_dryrun_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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -218,7 +223,7 @@ def build_list_request(subscription_id: str, resource_group_name: str, location: _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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -251,7 +256,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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -285,7 +290,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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -322,7 +327,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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -356,7 +361,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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -393,7 +398,7 @@ def build_validate_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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -427,7 +432,7 @@ def build_generate_configurations_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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -490,7 +495,6 @@ def list_dryrun( :type resource_group_name: str :param location: The name of Azure region. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DryrunResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicelinker.models.DryrunResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -501,7 +505,7 @@ def list_dryrun( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DryrunList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -512,17 +516,15 @@ def list_dryrun( def prepare_request(next_link=None): if not next_link: - request = build_list_dryrun_request( + _request = build_list_dryrun_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, api_version=api_version, - template_url=self.list_dryrun.metadata["url"], 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 @@ -534,13 +536,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("DryrunList", pipeline_response) @@ -550,11 +551,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 @@ -567,10 +568,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_dryrun.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/dryruns" - } - @distributed_trace def get_dryrun( self, subscription_id: str, resource_group_name: str, location: str, dryrun_name: str, **kwargs: Any @@ -586,12 +583,11 @@ def get_dryrun( :type location: str :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DryrunResource or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.DryrunResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -605,22 +601,20 @@ def get_dryrun( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DryrunResource] = kwargs.pop("cls", None) - request = build_get_dryrun_request( + _request = build_get_dryrun_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, dryrun_name=dryrun_name, api_version=api_version, - template_url=self.get_dryrun.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -630,16 +624,12 @@ def get_dryrun( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DryrunResource", pipeline_response) + deserialized = self._deserialize("DryrunResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_dryrun.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/dryruns/{dryrunName}" - } + return deserialized # type: ignore def _create_dryrun_initial( self, @@ -647,10 +637,10 @@ def _create_dryrun_initial( resource_group_name: str, location: str, dryrun_name: str, - parameters: Union[_models.DryrunResource, IO], + parameters: Union[_models.DryrunResource, IO[bytes]], **kwargs: Any - ) -> _models.DryrunResource: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -663,7 +653,7 @@ def _create_dryrun_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.DryrunResource] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -673,7 +663,7 @@ def _create_dryrun_initial( else: _json = self._serialize.body(parameters, "DryrunResource") - request = build_create_dryrun_request( + _request = build_create_dryrun_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, @@ -682,40 +672,35 @@ def _create_dryrun_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_dryrun_initial.metadata["url"], headers=_headers, 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("DryrunResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DryrunResource", 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_dryrun_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/dryruns/{dryrunName}" - } - @overload def begin_create_dryrun( self, @@ -744,14 +729,6 @@ def begin_create_dryrun( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -765,7 +742,7 @@ def begin_create_dryrun( resource_group_name: str, location: str, dryrun_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -782,18 +759,10 @@ def begin_create_dryrun( :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str :param parameters: dryrun 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 DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -807,7 +776,7 @@ def begin_create_dryrun( resource_group_name: str, location: str, dryrun_name: str, - parameters: Union[_models.DryrunResource, IO], + parameters: Union[_models.DryrunResource, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DryrunResource]: """create a dryrun job to do necessary check before actual creation. @@ -821,19 +790,9 @@ def begin_create_dryrun( :type location: str :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str - :param parameters: dryrun resource. Is either a DryrunResource type or a IO type. Required. - :type parameters: ~azure.mgmt.servicelinker.models.DryrunResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: dryrun resource. Is either a DryrunResource type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.servicelinker.models.DryrunResource or IO[bytes] :return: An instance of LROPoller that returns either DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -862,12 +821,13 @@ def begin_create_dryrun( 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("DryrunResource", pipeline_response) + deserialized = self._deserialize("DryrunResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -879,17 +839,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DryrunResource].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_dryrun.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/dryruns/{dryrunName}" - } + return LROPoller[_models.DryrunResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_dryrun_initial( self, @@ -897,10 +855,10 @@ def _update_dryrun_initial( resource_group_name: str, location: str, dryrun_name: str, - parameters: Union[_models.DryrunPatch, IO], + parameters: Union[_models.DryrunPatch, IO[bytes]], **kwargs: Any - ) -> Optional[_models.DryrunResource]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -913,7 +871,7 @@ def _update_dryrun_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.DryrunResource]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -923,7 +881,7 @@ def _update_dryrun_initial( else: _json = self._serialize.body(parameters, "DryrunPatch") - request = build_update_dryrun_request( + _request = build_update_dryrun_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, @@ -932,37 +890,34 @@ def _update_dryrun_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_dryrun_initial.metadata["url"], headers=_headers, 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 - if response.status_code == 200: - deserialized = self._deserialize("DryrunResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_dryrun_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/dryruns/{dryrunName}" - } + return deserialized # type: ignore @overload def begin_update_dryrun( @@ -992,14 +947,6 @@ def begin_update_dryrun( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -1013,7 +960,7 @@ def begin_update_dryrun( resource_group_name: str, location: str, dryrun_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1030,18 +977,10 @@ def begin_update_dryrun( :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str :param parameters: dryrun 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 DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -1055,7 +994,7 @@ def begin_update_dryrun( resource_group_name: str, location: str, dryrun_name: str, - parameters: Union[_models.DryrunPatch, IO], + parameters: Union[_models.DryrunPatch, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DryrunResource]: """update a dryrun job to do necessary check before actual creation. @@ -1069,19 +1008,8 @@ def begin_update_dryrun( :type location: str :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str - :param parameters: dryrun resource. Is either a DryrunPatch type or a IO type. Required. - :type parameters: ~azure.mgmt.servicelinker.models.DryrunPatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: dryrun resource. Is either a DryrunPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.servicelinker.models.DryrunPatch or IO[bytes] :return: An instance of LROPoller that returns either DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -1110,12 +1038,13 @@ def begin_update_dryrun( 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("DryrunResource", pipeline_response) + deserialized = self._deserialize("DryrunResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1127,17 +1056,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DryrunResource].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_dryrun.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/dryruns/{dryrunName}" - } + return LROPoller[_models.DryrunResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete_dryrun( # pylint: disable=inconsistent-return-statements @@ -1154,12 +1081,11 @@ def delete_dryrun( # pylint: disable=inconsistent-return-statements :type location: str :param dryrun_name: The name of dryrun. Required. :type dryrun_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, @@ -1173,22 +1099,20 @@ def delete_dryrun( # 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_dryrun_request( + _request = build_delete_dryrun_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, dryrun_name=dryrun_name, api_version=api_version, - template_url=self.delete_dryrun.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -1199,11 +1123,7 @@ def delete_dryrun( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_dryrun.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/dryruns/{dryrunName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -1219,7 +1139,6 @@ def list( :type resource_group_name: str :param location: The name of Azure region. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LinkerResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicelinker.models.LinkerResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -1230,7 +1149,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1241,17 +1160,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, 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 @@ -1263,13 +1180,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("ResourceList", pipeline_response) @@ -1279,11 +1195,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 @@ -1296,10 +1212,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/connectors" - } - @distributed_trace def get( self, subscription_id: str, resource_group_name: str, location: str, connector_name: str, **kwargs: Any @@ -1315,12 +1227,11 @@ def get( :type location: str :param connector_name: The name of resource. Required. :type connector_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LinkerResource or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.LinkerResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1334,22 +1245,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LinkerResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, connector_name=connector_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1359,16 +1268,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("LinkerResource", pipeline_response) + deserialized = self._deserialize("LinkerResource", 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.ServiceLinker/locations/{location}/connectors/{connectorName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, @@ -1376,10 +1281,10 @@ def _create_or_update_initial( resource_group_name: str, location: str, connector_name: str, - parameters: Union[_models.LinkerResource, IO], + parameters: Union[_models.LinkerResource, IO[bytes]], **kwargs: Any - ) -> _models.LinkerResource: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1392,7 +1297,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.LinkerResource] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1402,7 +1307,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "LinkerResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, @@ -1411,40 +1316,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("LinkerResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("LinkerResource", 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.ServiceLinker/locations/{location}/connectors/{connectorName}" - } - @overload def begin_create_or_update( self, @@ -1473,14 +1373,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 LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -1494,7 +1386,7 @@ def begin_create_or_update( resource_group_name: str, location: str, connector_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1511,18 +1403,10 @@ def begin_create_or_update( :param connector_name: The name of resource. Required. :type connector_name: str :param parameters: Connector details. 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 LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -1536,7 +1420,7 @@ def begin_create_or_update( resource_group_name: str, location: str, connector_name: str, - parameters: Union[_models.LinkerResource, IO], + parameters: Union[_models.LinkerResource, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.LinkerResource]: """Create or update Connector resource. @@ -1550,19 +1434,9 @@ def begin_create_or_update( :type location: str :param connector_name: The name of resource. Required. :type connector_name: str - :param parameters: Connector details. Is either a LinkerResource type or a IO type. Required. - :type parameters: ~azure.mgmt.servicelinker.models.LinkerResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Connector details. Is either a LinkerResource type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.servicelinker.models.LinkerResource or IO[bytes] :return: An instance of LROPoller that returns either LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -1591,12 +1465,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("LinkerResource", pipeline_response) + deserialized = self._deserialize("LinkerResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1608,22 +1483,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.LinkerResource].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.ServiceLinker/locations/{location}/connectors/{connectorName}" - } + return LROPoller[_models.LinkerResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, subscription_id: str, resource_group_name: str, location: str, connector_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1635,39 +1508,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( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, connector_name=connector_name, 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.ServiceLinker/locations/{location}/connectors/{connectorName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -1684,14 +1560,6 @@ def begin_delete( :type location: str :param connector_name: The name of resource. Required. :type connector_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: @@ -1705,7 +1573,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( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, @@ -1716,11 +1584,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( @@ -1731,17 +1600,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/connectors/{connectorName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _update_initial( self, @@ -1749,10 +1614,10 @@ def _update_initial( resource_group_name: str, location: str, connector_name: str, - parameters: Union[_models.LinkerPatch, IO], + parameters: Union[_models.LinkerPatch, IO[bytes]], **kwargs: Any - ) -> _models.LinkerResource: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1765,7 +1630,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.LinkerResource] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1775,7 +1640,7 @@ def _update_initial( else: _json = self._serialize.body(parameters, "LinkerPatch") - request = build_update_request( + _request = build_update_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, @@ -1784,40 +1649,35 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _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) - if response.status_code == 200: - deserialized = self._deserialize("LinkerResource", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("LinkerResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/connectors/{connectorName}" - } - @overload def begin_update( self, @@ -1846,14 +1706,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 LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -1867,7 +1719,7 @@ def begin_update( resource_group_name: str, location: str, connector_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1884,18 +1736,10 @@ def begin_update( :param connector_name: The name of resource. Required. :type connector_name: str :param parameters: Connector details. 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 LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -1909,7 +1753,7 @@ def begin_update( resource_group_name: str, location: str, connector_name: str, - parameters: Union[_models.LinkerPatch, IO], + parameters: Union[_models.LinkerPatch, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.LinkerResource]: """Operation to update an existing Connector. @@ -1923,19 +1767,9 @@ def begin_update( :type location: str :param connector_name: The name of resource. Required. :type connector_name: str - :param parameters: Connector details. Is either a LinkerPatch type or a IO type. Required. - :type parameters: ~azure.mgmt.servicelinker.models.LinkerPatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Connector details. Is either a LinkerPatch type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.servicelinker.models.LinkerPatch or IO[bytes] :return: An instance of LROPoller that returns either LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -1964,12 +1798,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("LinkerResource", pipeline_response) + deserialized = self._deserialize("LinkerResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1981,22 +1816,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.LinkerResource].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.ServiceLinker/locations/{location}/connectors/{connectorName}" - } + return LROPoller[_models.LinkerResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _validate_initial( self, subscription_id: str, resource_group_name: str, location: str, connector_name: str, **kwargs: Any - ) -> Optional[_models.ValidateOperationResult]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2008,45 +1841,42 @@ def _validate_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.ValidateOperationResult]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_validate_request( + _request = build_validate_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, connector_name=connector_name, api_version=api_version, - template_url=self._validate_initial.metadata["url"], headers=_headers, 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 - if response.status_code == 200: - deserialized = self._deserialize("ValidateOperationResult", 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 - _validate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/connectors/{connectorName}/validate" - } + return deserialized # type: ignore @distributed_trace def begin_validate( @@ -2063,14 +1893,6 @@ def begin_validate( :type location: str :param connector_name: The name of resource. Required. :type connector_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 ValidateOperationResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.ValidateOperationResult] @@ -2096,12 +1918,13 @@ def begin_validate( 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("ValidateOperationResult", pipeline_response) + deserialized = self._deserialize("ValidateOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2113,17 +1936,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ValidateOperationResult].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_validate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/connectors/{connectorName}/validate" - } + return LROPoller[_models.ValidateOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @overload def generate_configurations( @@ -2153,7 +1974,6 @@ def generate_configurations( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ConfigurationResult or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.ConfigurationResult :raises ~azure.core.exceptions.HttpResponseError: @@ -2166,7 +1986,7 @@ def generate_configurations( resource_group_name: str, location: str, connector_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2183,11 +2003,10 @@ def generate_configurations( :param connector_name: The name of resource. Required. :type connector_name: str :param parameters: Connection Info, including format, secret store, etc. Default value is None. - :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: ConfigurationResult or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.ConfigurationResult :raises ~azure.core.exceptions.HttpResponseError: @@ -2200,7 +2019,7 @@ def generate_configurations( resource_group_name: str, location: str, connector_name: str, - parameters: Optional[Union[_models.ConfigurationInfo, IO]] = None, + parameters: Optional[Union[_models.ConfigurationInfo, IO[bytes]]] = None, **kwargs: Any ) -> _models.ConfigurationResult: """Generate configurations for a Connector. @@ -2215,17 +2034,13 @@ def generate_configurations( :param connector_name: The name of resource. Required. :type connector_name: str :param parameters: Connection Info, including format, secret store, etc. Is either a - ConfigurationInfo type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.servicelinker.models.ConfigurationInfo or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ConfigurationInfo type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.servicelinker.models.ConfigurationInfo or IO[bytes] :return: ConfigurationResult or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.ConfigurationResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2251,7 +2066,7 @@ def generate_configurations( else: _json = None - request = build_generate_configurations_request( + _request = build_generate_configurations_request( subscription_id=subscription_id, resource_group_name=resource_group_name, location=location, @@ -2260,16 +2075,14 @@ def generate_configurations( content_type=content_type, json=_json, content=_content, - template_url=self.generate_configurations.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -2279,13 +2092,9 @@ def generate_configurations( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConfigurationResult", pipeline_response) + deserialized = self._deserialize("ConfigurationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - generate_configurations.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.ServiceLinker/locations/{location}/connectors/{connectorName}/generateConfigurations" - } + return deserialized # type: ignore diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_linker_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_linker_operations.py index 0d940a434140..cc46f9171d39 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_linker_operations.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_linker_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +48,7 @@ def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +72,7 @@ def build_get_request(resource_uri: str, linker_name: str, **kwargs: Any) -> Htt _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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,7 +97,7 @@ def build_create_or_update_request(resource_uri: str, linker_name: str, **kwargs _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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -120,7 +125,7 @@ def build_delete_request(resource_uri: str, linker_name: str, **kwargs: Any) -> _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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -145,7 +150,7 @@ def build_update_request(resource_uri: str, linker_name: str, **kwargs: Any) -> _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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -173,7 +178,7 @@ def build_validate_request(resource_uri: str, linker_name: str, **kwargs: Any) - _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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -200,7 +205,7 @@ def build_list_configurations_request(resource_uri: str, linker_name: str, **kwa _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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -250,7 +255,6 @@ def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.LinkerReso :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to be connected. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LinkerResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicelinker.models.LinkerResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -261,7 +265,7 @@ def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.LinkerReso api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -272,15 +276,13 @@ def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.LinkerReso def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_uri=resource_uri, 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 @@ -292,13 +294,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("ResourceList", pipeline_response) @@ -308,11 +309,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 @@ -325,8 +326,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers"} - @distributed_trace def get(self, resource_uri: str, linker_name: str, **kwargs: Any) -> _models.LinkerResource: """Returns Linker resource for a given name. @@ -336,12 +335,11 @@ def get(self, resource_uri: str, linker_name: str, **kwargs: Any) -> _models.Lin :type resource_uri: str :param linker_name: The name Linker resource. Required. :type linker_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LinkerResource or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.LinkerResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -355,20 +353,18 @@ def get(self, resource_uri: str, linker_name: str, **kwargs: Any) -> _models.Lin api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LinkerResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_uri=resource_uri, linker_name=linker_name, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -378,19 +374,17 @@ def get(self, resource_uri: str, linker_name: str, **kwargs: Any) -> _models.Lin error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("LinkerResource", pipeline_response) + deserialized = self._deserialize("LinkerResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}"} + return deserialized # type: ignore def _create_or_update_initial( - self, resource_uri: str, linker_name: str, parameters: Union[_models.LinkerResource, IO], **kwargs: Any - ) -> _models.LinkerResource: - error_map = { + self, resource_uri: str, linker_name: str, parameters: Union[_models.LinkerResource, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -403,7 +397,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.LinkerResource] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -413,47 +407,42 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "LinkerResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_uri=resource_uri, linker_name=linker_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _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("LinkerResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("LinkerResource", 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": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}" - } - @overload def begin_create_or_update( self, @@ -476,14 +465,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 LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -495,7 +476,7 @@ def begin_create_or_update( self, resource_uri: str, linker_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -508,18 +489,10 @@ def begin_create_or_update( :param linker_name: The name Linker resource. Required. :type linker_name: str :param parameters: Linker details. 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 LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -528,7 +501,7 @@ def begin_create_or_update( @distributed_trace def begin_create_or_update( - self, resource_uri: str, linker_name: str, parameters: Union[_models.LinkerResource, IO], **kwargs: Any + self, resource_uri: str, linker_name: str, parameters: Union[_models.LinkerResource, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.LinkerResource]: """Create or update Linker resource. @@ -537,19 +510,9 @@ def begin_create_or_update( :type resource_uri: str :param linker_name: The name Linker resource. Required. :type linker_name: str - :param parameters: Linker details. Is either a LinkerResource type or a IO type. Required. - :type parameters: ~azure.mgmt.servicelinker.models.LinkerResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Linker details. Is either a LinkerResource type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.servicelinker.models.LinkerResource or IO[bytes] :return: An instance of LROPoller that returns either LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -576,12 +539,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("LinkerResource", pipeline_response) + deserialized = self._deserialize("LinkerResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -593,20 +557,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.LinkerResource].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": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}"} + return LROPoller[_models.LinkerResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, linker_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_uri: str, linker_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -618,35 +580,40 @@ 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_uri=resource_uri, linker_name=linker_name, 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": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}"} + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_uri: str, linker_name: str, **kwargs: Any) -> LROPoller[None]: @@ -657,14 +624,6 @@ def begin_delete(self, resource_uri: str, linker_name: str, **kwargs: Any) -> LR :type resource_uri: str :param linker_name: The name Linker resource. Required. :type linker_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: @@ -678,7 +637,7 @@ def begin_delete(self, resource_uri: str, linker_name: str, **kwargs: Any) -> LR 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_uri=resource_uri, linker_name=linker_name, api_version=api_version, @@ -687,11 +646,12 @@ def begin_delete(self, resource_uri: str, linker_name: str, **kwargs: Any) -> LR 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( @@ -702,20 +662,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}"} + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _update_initial( - self, resource_uri: str, linker_name: str, parameters: Union[_models.LinkerPatch, IO], **kwargs: Any - ) -> _models.LinkerResource: - error_map = { + self, resource_uri: str, linker_name: str, parameters: Union[_models.LinkerPatch, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -728,7 +686,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.LinkerResource] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -738,45 +696,42 @@ def _update_initial( else: _json = self._serialize.body(parameters, "LinkerPatch") - request = build_update_request( + _request = build_update_request( resource_uri=resource_uri, linker_name=linker_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + 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("LinkerResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("LinkerResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}"} - @overload def begin_update( self, @@ -799,14 +754,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 LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -818,7 +765,7 @@ def begin_update( self, resource_uri: str, linker_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -831,18 +778,10 @@ def begin_update( :param linker_name: The name Linker resource. Required. :type linker_name: str :param parameters: Linker details. 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 LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -851,7 +790,7 @@ def begin_update( @distributed_trace def begin_update( - self, resource_uri: str, linker_name: str, parameters: Union[_models.LinkerPatch, IO], **kwargs: Any + self, resource_uri: str, linker_name: str, parameters: Union[_models.LinkerPatch, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.LinkerResource]: """Operation to update an existing Linker. @@ -860,19 +799,8 @@ def begin_update( :type resource_uri: str :param linker_name: The name Linker resource. Required. :type linker_name: str - :param parameters: Linker details. Is either a LinkerPatch type or a IO type. Required. - :type parameters: ~azure.mgmt.servicelinker.models.LinkerPatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Linker details. Is either a LinkerPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.servicelinker.models.LinkerPatch or IO[bytes] :return: An instance of LROPoller that returns either LinkerResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.LinkerResource] @@ -899,12 +827,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("LinkerResource", pipeline_response) + deserialized = self._deserialize("LinkerResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -916,20 +845,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.LinkerResource].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": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}"} + return LROPoller[_models.LinkerResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _validate_initial( - self, resource_uri: str, linker_name: str, **kwargs: Any - ) -> Optional[_models.ValidateOperationResult]: - error_map = { + def _validate_initial(self, resource_uri: str, linker_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -941,43 +868,40 @@ def _validate_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.ValidateOperationResult]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_validate_request( + _request = build_validate_request( resource_uri=resource_uri, linker_name=linker_name, api_version=api_version, - template_url=self._validate_initial.metadata["url"], headers=_headers, 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 - if response.status_code == 200: - deserialized = self._deserialize("ValidateOperationResult", 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 - _validate_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/validateLinker" - } + return deserialized # type: ignore @distributed_trace def begin_validate( @@ -990,14 +914,6 @@ def begin_validate( :type resource_uri: str :param linker_name: The name Linker resource. Required. :type linker_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 ValidateOperationResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.ValidateOperationResult] @@ -1021,12 +937,13 @@ def begin_validate( 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("ValidateOperationResult", pipeline_response) + deserialized = self._deserialize("ValidateOperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1038,17 +955,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ValidateOperationResult].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_validate.metadata = { - "url": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/validateLinker" - } + return LROPoller[_models.ValidateOperationResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_configurations(self, resource_uri: str, linker_name: str, **kwargs: Any) -> _models.ConfigurationResult: @@ -1059,12 +974,11 @@ def list_configurations(self, resource_uri: str, linker_name: str, **kwargs: Any :type resource_uri: str :param linker_name: The name Linker resource. Required. :type linker_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ConfigurationResult or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.ConfigurationResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1078,20 +992,18 @@ def list_configurations(self, resource_uri: str, linker_name: str, **kwargs: Any api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ConfigurationResult] = kwargs.pop("cls", None) - request = build_list_configurations_request( + _request = build_list_configurations_request( resource_uri=resource_uri, linker_name=linker_name, api_version=api_version, - template_url=self.list_configurations.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -1101,13 +1013,9 @@ def list_configurations(self, resource_uri: str, linker_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("ConfigurationResult", pipeline_response) + deserialized = self._deserialize("ConfigurationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_configurations.metadata = { - "url": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/listConfigurations" - } + return deserialized # type: ignore diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_linkers_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_linkers_operations.py index e8f0a14de846..9dbe340d891c 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_linkers_operations.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_linkers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +48,7 @@ def build_list_dryrun_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +72,7 @@ def build_get_dryrun_request(resource_uri: str, dryrun_name: str, **kwargs: Any) _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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,7 +97,7 @@ def build_create_dryrun_request(resource_uri: str, dryrun_name: str, **kwargs: A _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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -120,7 +125,7 @@ def build_update_dryrun_request(resource_uri: str, dryrun_name: str, **kwargs: A _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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -148,7 +153,7 @@ def build_delete_dryrun_request(resource_uri: str, dryrun_name: str, **kwargs: A _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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -173,7 +178,7 @@ def build_generate_configurations_request(resource_uri: str, linker_name: 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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -203,7 +208,7 @@ def build_list_dapr_configurations_request(resource_uri: str, **kwargs: Any) -> _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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -249,7 +254,6 @@ def list_dryrun(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.Dry :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to be connected. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DryrunResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.servicelinker.models.DryrunResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -260,7 +264,7 @@ def list_dryrun(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.Dry api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DryrunList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -271,15 +275,13 @@ def list_dryrun(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.Dry def prepare_request(next_link=None): if not next_link: - request = build_list_dryrun_request( + _request = build_list_dryrun_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list_dryrun.metadata["url"], 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 @@ -291,13 +293,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("DryrunList", pipeline_response) @@ -307,11 +308,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 @@ -324,8 +325,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_dryrun.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/dryruns"} - @distributed_trace def get_dryrun(self, resource_uri: str, dryrun_name: str, **kwargs: Any) -> _models.DryrunResource: """get a dryrun job. @@ -335,12 +334,11 @@ def get_dryrun(self, resource_uri: str, dryrun_name: str, **kwargs: Any) -> _mod :type resource_uri: str :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DryrunResource or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.DryrunResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -354,20 +352,18 @@ def get_dryrun(self, resource_uri: str, dryrun_name: str, **kwargs: Any) -> _mod api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DryrunResource] = kwargs.pop("cls", None) - request = build_get_dryrun_request( + _request = build_get_dryrun_request( resource_uri=resource_uri, dryrun_name=dryrun_name, api_version=api_version, - template_url=self.get_dryrun.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -377,19 +373,17 @@ def get_dryrun(self, resource_uri: str, dryrun_name: str, **kwargs: Any) -> _mod error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DryrunResource", pipeline_response) + deserialized = self._deserialize("DryrunResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_dryrun.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/dryruns/{dryrunName}"} + return deserialized # type: ignore def _create_dryrun_initial( - self, resource_uri: str, dryrun_name: str, parameters: Union[_models.DryrunResource, IO], **kwargs: Any - ) -> _models.DryrunResource: - error_map = { + self, resource_uri: str, dryrun_name: str, parameters: Union[_models.DryrunResource, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -402,7 +396,7 @@ def _create_dryrun_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.DryrunResource] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -412,45 +406,42 @@ def _create_dryrun_initial( else: _json = self._serialize.body(parameters, "DryrunResource") - request = build_create_dryrun_request( + _request = build_create_dryrun_request( resource_uri=resource_uri, dryrun_name=dryrun_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._create_dryrun_initial.metadata["url"], headers=_headers, 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("DryrunResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DryrunResource", 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_dryrun_initial.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/dryruns/{dryrunName}"} - @overload def begin_create_dryrun( self, @@ -473,14 +464,6 @@ def begin_create_dryrun( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -492,7 +475,7 @@ def begin_create_dryrun( self, resource_uri: str, dryrun_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -505,18 +488,10 @@ def begin_create_dryrun( :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str :param parameters: dryrun 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 DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -525,7 +500,7 @@ def begin_create_dryrun( @distributed_trace def begin_create_dryrun( - self, resource_uri: str, dryrun_name: str, parameters: Union[_models.DryrunResource, IO], **kwargs: Any + self, resource_uri: str, dryrun_name: str, parameters: Union[_models.DryrunResource, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DryrunResource]: """create a dryrun job to do necessary check before actual creation. @@ -534,19 +509,9 @@ def begin_create_dryrun( :type resource_uri: str :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str - :param parameters: dryrun resource. Is either a DryrunResource type or a IO type. Required. - :type parameters: ~azure.mgmt.servicelinker.models.DryrunResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: dryrun resource. Is either a DryrunResource type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.servicelinker.models.DryrunResource or IO[bytes] :return: An instance of LROPoller that returns either DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -573,12 +538,13 @@ def begin_create_dryrun( 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("DryrunResource", pipeline_response) + deserialized = self._deserialize("DryrunResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -590,20 +556,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DryrunResource].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_dryrun.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/dryruns/{dryrunName}"} + return LROPoller[_models.DryrunResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_dryrun_initial( - self, resource_uri: str, dryrun_name: str, parameters: Union[_models.DryrunPatch, IO], **kwargs: Any - ) -> Optional[_models.DryrunResource]: - error_map = { + self, resource_uri: str, dryrun_name: str, parameters: Union[_models.DryrunPatch, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -616,7 +582,7 @@ def _update_dryrun_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.DryrunResource]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -626,42 +592,41 @@ def _update_dryrun_initial( else: _json = self._serialize.body(parameters, "DryrunPatch") - request = build_update_dryrun_request( + _request = build_update_dryrun_request( resource_uri=resource_uri, dryrun_name=dryrun_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._update_dryrun_initial.metadata["url"], headers=_headers, 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 - if response.status_code == 200: - deserialized = self._deserialize("DryrunResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_dryrun_initial.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/dryruns/{dryrunName}"} + return deserialized # type: ignore @overload def begin_update_dryrun( @@ -685,14 +650,6 @@ def begin_update_dryrun( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -704,7 +661,7 @@ def begin_update_dryrun( self, resource_uri: str, dryrun_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -717,18 +674,10 @@ def begin_update_dryrun( :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str :param parameters: dryrun 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 DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -737,7 +686,7 @@ def begin_update_dryrun( @distributed_trace def begin_update_dryrun( - self, resource_uri: str, dryrun_name: str, parameters: Union[_models.DryrunPatch, IO], **kwargs: Any + self, resource_uri: str, dryrun_name: str, parameters: Union[_models.DryrunPatch, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DryrunResource]: """add a dryrun job to do necessary check before actual creation. @@ -746,19 +695,8 @@ def begin_update_dryrun( :type resource_uri: str :param dryrun_name: The name of dryrun. Required. :type dryrun_name: str - :param parameters: dryrun resource. Is either a DryrunPatch type or a IO type. Required. - :type parameters: ~azure.mgmt.servicelinker.models.DryrunPatch or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: dryrun resource. Is either a DryrunPatch type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.servicelinker.models.DryrunPatch or IO[bytes] :return: An instance of LROPoller that returns either DryrunResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.servicelinker.models.DryrunResource] @@ -785,12 +723,13 @@ def begin_update_dryrun( 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("DryrunResource", pipeline_response) + deserialized = self._deserialize("DryrunResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -802,15 +741,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DryrunResource].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_dryrun.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/dryruns/{dryrunName}"} + return LROPoller[_models.DryrunResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete_dryrun( # pylint: disable=inconsistent-return-statements @@ -823,12 +762,11 @@ def delete_dryrun( # pylint: disable=inconsistent-return-statements :type resource_uri: str :param dryrun_name: The name of dryrun. Required. :type dryrun_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, @@ -842,20 +780,18 @@ def delete_dryrun( # 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_dryrun_request( + _request = build_delete_dryrun_request( resource_uri=resource_uri, dryrun_name=dryrun_name, api_version=api_version, - template_url=self.delete_dryrun.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -866,9 +802,7 @@ def delete_dryrun( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete_dryrun.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/dryruns/{dryrunName}"} + return cls(pipeline_response, None, {}) # type: ignore @overload def generate_configurations( @@ -892,7 +826,6 @@ def generate_configurations( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ConfigurationResult or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.ConfigurationResult :raises ~azure.core.exceptions.HttpResponseError: @@ -903,7 +836,7 @@ def generate_configurations( self, resource_uri: str, linker_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -916,11 +849,10 @@ def generate_configurations( :param linker_name: The name Linker resource. Required. :type linker_name: str :param parameters: Connection Info, including format, secret store, etc. Default value is None. - :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: ConfigurationResult or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.ConfigurationResult :raises ~azure.core.exceptions.HttpResponseError: @@ -931,7 +863,7 @@ def generate_configurations( self, resource_uri: str, linker_name: str, - parameters: Optional[Union[_models.ConfigurationInfo, IO]] = None, + parameters: Optional[Union[_models.ConfigurationInfo, IO[bytes]]] = None, **kwargs: Any ) -> _models.ConfigurationResult: """Generate configurations for a Linker. @@ -942,17 +874,13 @@ def generate_configurations( :param linker_name: The name Linker resource. Required. :type linker_name: str :param parameters: Connection Info, including format, secret store, etc. Is either a - ConfigurationInfo type or a IO type. Default value is None. - :type parameters: ~azure.mgmt.servicelinker.models.ConfigurationInfo or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ConfigurationInfo type or a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.servicelinker.models.ConfigurationInfo or IO[bytes] :return: ConfigurationResult or the result of cls(response) :rtype: ~azure.mgmt.servicelinker.models.ConfigurationResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -978,23 +906,21 @@ def generate_configurations( else: _json = None - request = build_generate_configurations_request( + _request = build_generate_configurations_request( resource_uri=resource_uri, linker_name=linker_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.generate_configurations.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -1004,16 +930,12 @@ def generate_configurations( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ConfigurationResult", pipeline_response) + deserialized = self._deserialize("ConfigurationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - generate_configurations.metadata = { - "url": "/{resourceUri}/providers/Microsoft.ServiceLinker/linkers/{linkerName}/generateConfigurations" - } + return deserialized # type: ignore @distributed_trace def list_dapr_configurations( @@ -1024,7 +946,6 @@ def list_dapr_configurations( :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to be connected. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DaprConfigurationResource or the result of cls(response) :rtype: @@ -1037,7 +958,7 @@ def list_dapr_configurations( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DaprConfigurationList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1048,15 +969,13 @@ def list_dapr_configurations( def prepare_request(next_link=None): if not next_link: - request = build_list_dapr_configurations_request( + _request = build_list_dapr_configurations_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list_dapr_configurations.metadata["url"], 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 @@ -1068,13 +987,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("DaprConfigurationList", pipeline_response) @@ -1084,11 +1002,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 @@ -1100,5 +1018,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_dapr_configurations.metadata = {"url": "/{resourceUri}/providers/Microsoft.ServiceLinker/daprConfigurations"} diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_operations.py index 501a3a17324c..0259c24f99ee 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/operations/_operations.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/azure/mgmt/servicelinker/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-04-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-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 the available ServiceLinker REST API operations. - :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.servicelinker.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -89,7 +91,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,14 +102,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,13 +119,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -135,11 +134,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,5 +150,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.ServiceLinker/operations"} diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/dev_requirements.txt b/sdk/servicelinker/azure-mgmt-servicelinker/dev_requirements.txt index 1cfa079cdfb1..fa6811a93df0 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/dev_requirements.txt +++ b/sdk/servicelinker/azure-mgmt-servicelinker/dev_requirements.txt @@ -1,2 +1,3 @@ -e ../../../tools/azure-sdk-tools -e ../../resources/azure-mgmt-resource +aiohttp \ No newline at end of file diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/configuration_names_list.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/configuration_names_list.py index 18b07075b19e..5b5c65ae3fe5 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/configuration_names_list.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/configuration_names_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -33,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/ConfigurationNamesList.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/ConfigurationNamesList.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_create.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_create.py index e7b1deb07625..151c58b5910c 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_create.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_create.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -53,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/ConnectorDryrunCreate.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/ConnectorDryrunCreate.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_delete.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_delete.py index 78364a23cd36..c53ff293faa8 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_delete.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -36,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/ConnectorDryrunDelete.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/ConnectorDryrunDelete.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_get.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_get.py index 8fdc973509c4..857088da4af8 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_get.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/ConnectorDryrunGet.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/ConnectorDryrunGet.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_list.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_list.py index ca39bef4454d..a39ba8807504 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_list.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/ConnectorDryrunList.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/ConnectorDryrunList.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_update.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_update.py index 1ada6f82ebf5..5096981cdc2a 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_update.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_dryrun_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -53,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/ConnectorDryrunUpdate.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/ConnectorDryrunUpdate.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_list.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_list.py index 948b5188d330..161448d6ebf3 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_list.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connector_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/ConnectorList.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/ConnectorList.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connectors.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connectors.py index bbfa71d15593..73a3169f4cf7 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connectors.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/connectors.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/Connectors.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/Connectors.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/delete_connector.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/delete_connector.py index aeec7f5aadf2..bec798058acf 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/delete_connector.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/delete_connector.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/DeleteConnector.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/DeleteConnector.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/delete_dryrun.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/delete_dryrun.py index 802f49a1b93f..481c5daf5ec0 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/delete_dryrun.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/delete_dryrun.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -34,6 +35,6 @@ def main(): ) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/DeleteDryrun.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/DeleteDryrun.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/delete_linker.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/delete_linker.py index 481d5b2369bc..72d189718004 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/delete_linker.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/delete_linker.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -34,6 +35,6 @@ def main(): ).result() -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/DeleteLinker.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/DeleteLinker.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/generate_configurations.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/generate_configurations.py index bec2a04b9fb6..b26343ab1d20 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/generate_configurations.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/generate_configurations.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/GenerateConfigurations.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/GenerateConfigurations.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/get_configurations.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/get_configurations.py index cd568016859b..779dea6db532 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/get_configurations.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/get_configurations.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/GetConfigurations.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/GetConfigurations.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/get_dapr_configurations.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/get_dapr_configurations.py index 27b3f7042e14..8d388a74cc14 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/get_dapr_configurations.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/get_dapr_configurations.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -35,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/GetDaprConfigurations.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/GetDaprConfigurations.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/get_dryrun.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/get_dryrun.py index b6f4c545bd08..81e9eb1848bd 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/get_dryrun.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/get_dryrun.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/GetDryrun.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/GetDryrun.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/linker.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/linker.py index 17af45e5f777..22bd38147c1d 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/linker.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/linker.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/Linker.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/Linker.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/linker_generate_configurations.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/linker_generate_configurations.py index 72e5867916b7..f67ecb95747f 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/linker_generate_configurations.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/linker_generate_configurations.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/LinkerGenerateConfigurations.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/LinkerGenerateConfigurations.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/linker_list.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/linker_list.py index bdb2e3910a05..3e5cb067e46b 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/linker_list.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/linker_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -35,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/LinkerList.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/LinkerList.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/list_dryrun.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/list_dryrun.py index b08bd47c3b00..924b975a31dd 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/list_dryrun.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/list_dryrun.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -35,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/ListDryrun.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/ListDryrun.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/operations_list.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/operations_list.py index 886ff5129dc4..cd50768982fb 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/operations_list.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/operations_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -33,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/OperationsList.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/OperationsList.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/patch_connector.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/patch_connector.py index 0390b71a75bb..4eeb225e0fc2 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/patch_connector.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/patch_connector.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -51,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/PatchConnector.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/PatchConnector.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/patch_dryrun.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/patch_dryrun.py index 268679c3fa45..acd25cc71ae1 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/patch_dryrun.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/patch_dryrun.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -51,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/PatchDryrun.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/PatchDryrun.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/patch_linker.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/patch_linker.py index fc86f70ac479..fe538cee0606 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/patch_linker.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/patch_linker.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -49,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/PatchLinker.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/PatchLinker.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/put_connector.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/put_connector.py index 797ad53c067f..f1868b6127df 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/put_connector.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/put_connector.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -49,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/PutConnector.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/PutConnector.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/put_dryrun.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/put_dryrun.py index dd63b35c1b95..bc141b91f2ce 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/put_dryrun.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/put_dryrun.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -51,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/PutDryrun.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/PutDryrun.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/put_linker.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/put_linker.py index 2e0d51c400f7..0b84a95cbad8 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/put_linker.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/put_linker.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -49,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/PutLinker.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/PutLinker.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/validate_connector_success.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/validate_connector_success.py index 7c52662c44d2..4e0750a1e8b3 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/validate_connector_success.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/validate_connector_success.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/ValidateConnectorSuccess.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/ValidateConnectorSuccess.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/validate_linker_success.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/validate_linker_success.py index 4c0053398e65..c24265c42058 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/validate_linker_success.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_samples/validate_linker_success.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.servicelinker import ServiceLinkerManagementClient """ @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2023-04-01-preview/examples/ValidateLinkerSuccess.json +# x-ms-original-file: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/preview/2024-07-01-preview/examples/ValidateLinkerSuccess.json if __name__ == "__main__": main() diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/conftest.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/conftest.py new file mode 100644 index 000000000000..74ab781506a7 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/conftest.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +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): + servicelinkermanagement_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + servicelinkermanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + servicelinkermanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + servicelinkermanagement_client_secret = os.environ.get( + "AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=servicelinkermanagement_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer(regex=servicelinkermanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=servicelinkermanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer( + regex=servicelinkermanagement_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/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_configuration_names_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_configuration_names_operations.py new file mode 100644 index 000000000000..06900e621739 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_configuration_names_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.servicelinker import ServiceLinkerManagementClient + +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 TestServiceLinkerManagementConfigurationNamesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ServiceLinkerManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.configuration_names.list( + api_version="2024-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_configuration_names_operations_async.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_configuration_names_operations_async.py new file mode 100644 index 000000000000..c466e824043d --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_configuration_names_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.servicelinker.aio import ServiceLinkerManagementClient + +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 TestServiceLinkerManagementConfigurationNamesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ServiceLinkerManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.configuration_names.list( + api_version="2024-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_connector_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_connector_operations.py new file mode 100644 index 000000000000..140479ee3996 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_connector_operations.py @@ -0,0 +1,289 @@ +# 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.servicelinker import ServiceLinkerManagementClient + +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 TestServiceLinkerManagementConnectorOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ServiceLinkerManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_dryrun(self, resource_group): + response = self.client.connector.list_dryrun( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + api_version="2024-07-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_dryrun(self, resource_group): + response = self.client.connector.get_dryrun( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + dryrun_name="str", + api_version="2024-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_dryrun(self, resource_group): + response = self.client.connector.begin_create_dryrun( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + dryrun_name="str", + parameters={ + "id": "str", + "name": "str", + "operationPreviews": [ + {"action": "str", "description": "str", "name": "str", "operationType": "str", "scope": "str"} + ], + "parameters": "dryrun_parameters", + "prerequisiteResults": ["dryrun_prerequisite_result"], + "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-07-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_dryrun(self, resource_group): + response = self.client.connector.begin_update_dryrun( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + dryrun_name="str", + parameters={ + "operationPreviews": [ + {"action": "str", "description": "str", "name": "str", "operationType": "str", "scope": "str"} + ], + "parameters": "dryrun_parameters", + "prerequisiteResults": ["dryrun_prerequisite_result"], + "provisioningState": "str", + }, + api_version="2024-07-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_dryrun(self, resource_group): + response = self.client.connector.delete_dryrun( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + dryrun_name="str", + api_version="2024-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.connector.list( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + api_version="2024-07-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.connector.get( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + connector_name="str", + api_version="2024-07-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.connector.begin_create_or_update( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + connector_name="str", + parameters={ + "authInfo": "auth_info_base", + "clientType": "str", + "configurationInfo": { + "action": "str", + "additionalConfigurations": {"str": "str"}, + "additionalConnectionStringProperties": {"str": "str"}, + "configurationStore": {"appConfigurationId": "str"}, + "customizedKeys": {"str": "str"}, + "daprProperties": { + "bindingComponentDirection": "str", + "componentType": "str", + "metadata": [ + {"description": "str", "name": "str", "required": "str", "secretRef": "str", "value": "str"} + ], + "runtimeVersion": "str", + "scopes": ["str"], + "secretStoreComponent": "str", + "version": "str", + }, + "deleteOrUpdateBehavior": "str", + }, + "id": "str", + "name": "str", + "provisioningState": "str", + "publicNetworkSolution": { + "action": "str", + "deleteOrUpdateBehavior": "str", + "firewallRules": {"azureServices": "str", "callerClientIP": "str", "ipRanges": ["str"]}, + }, + "scope": "str", + "secretStore": {"keyVaultId": "str", "keyVaultSecretName": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "targetService": "target_service_base", + "type": "str", + "vNetSolution": {"deleteOrUpdateBehavior": "str", "type": "str"}, + }, + api_version="2024-07-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.connector.begin_delete( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + connector_name="str", + api_version="2024-07-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.connector.begin_update( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + connector_name="str", + parameters={ + "authInfo": "auth_info_base", + "clientType": "str", + "configurationInfo": { + "action": "str", + "additionalConfigurations": {"str": "str"}, + "additionalConnectionStringProperties": {"str": "str"}, + "configurationStore": {"appConfigurationId": "str"}, + "customizedKeys": {"str": "str"}, + "daprProperties": { + "bindingComponentDirection": "str", + "componentType": "str", + "metadata": [ + {"description": "str", "name": "str", "required": "str", "secretRef": "str", "value": "str"} + ], + "runtimeVersion": "str", + "scopes": ["str"], + "secretStoreComponent": "str", + "version": "str", + }, + "deleteOrUpdateBehavior": "str", + }, + "provisioningState": "str", + "publicNetworkSolution": { + "action": "str", + "deleteOrUpdateBehavior": "str", + "firewallRules": {"azureServices": "str", "callerClientIP": "str", "ipRanges": ["str"]}, + }, + "scope": "str", + "secretStore": {"keyVaultId": "str", "keyVaultSecretName": "str"}, + "targetService": "target_service_base", + "vNetSolution": {"deleteOrUpdateBehavior": "str", "type": "str"}, + }, + api_version="2024-07-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_validate(self, resource_group): + response = self.client.connector.begin_validate( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + connector_name="str", + api_version="2024-07-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_generate_configurations(self, resource_group): + response = self.client.connector.generate_configurations( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + connector_name="str", + api_version="2024-07-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_connector_operations_async.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_connector_operations_async.py new file mode 100644 index 000000000000..8c26fe7c677e --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_connector_operations_async.py @@ -0,0 +1,314 @@ +# 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.servicelinker.aio import ServiceLinkerManagementClient + +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 TestServiceLinkerManagementConnectorOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ServiceLinkerManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_dryrun(self, resource_group): + response = self.client.connector.list_dryrun( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + api_version="2024-07-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_dryrun(self, resource_group): + response = await self.client.connector.get_dryrun( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + dryrun_name="str", + api_version="2024-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_dryrun(self, resource_group): + response = await ( + await self.client.connector.begin_create_dryrun( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + dryrun_name="str", + parameters={ + "id": "str", + "name": "str", + "operationPreviews": [ + {"action": "str", "description": "str", "name": "str", "operationType": "str", "scope": "str"} + ], + "parameters": "dryrun_parameters", + "prerequisiteResults": ["dryrun_prerequisite_result"], + "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-07-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_dryrun(self, resource_group): + response = await ( + await self.client.connector.begin_update_dryrun( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + dryrun_name="str", + parameters={ + "operationPreviews": [ + {"action": "str", "description": "str", "name": "str", "operationType": "str", "scope": "str"} + ], + "parameters": "dryrun_parameters", + "prerequisiteResults": ["dryrun_prerequisite_result"], + "provisioningState": "str", + }, + api_version="2024-07-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_dryrun(self, resource_group): + response = await self.client.connector.delete_dryrun( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + dryrun_name="str", + api_version="2024-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.connector.list( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + api_version="2024-07-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.connector.get( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + connector_name="str", + api_version="2024-07-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.connector.begin_create_or_update( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + connector_name="str", + parameters={ + "authInfo": "auth_info_base", + "clientType": "str", + "configurationInfo": { + "action": "str", + "additionalConfigurations": {"str": "str"}, + "additionalConnectionStringProperties": {"str": "str"}, + "configurationStore": {"appConfigurationId": "str"}, + "customizedKeys": {"str": "str"}, + "daprProperties": { + "bindingComponentDirection": "str", + "componentType": "str", + "metadata": [ + { + "description": "str", + "name": "str", + "required": "str", + "secretRef": "str", + "value": "str", + } + ], + "runtimeVersion": "str", + "scopes": ["str"], + "secretStoreComponent": "str", + "version": "str", + }, + "deleteOrUpdateBehavior": "str", + }, + "id": "str", + "name": "str", + "provisioningState": "str", + "publicNetworkSolution": { + "action": "str", + "deleteOrUpdateBehavior": "str", + "firewallRules": {"azureServices": "str", "callerClientIP": "str", "ipRanges": ["str"]}, + }, + "scope": "str", + "secretStore": {"keyVaultId": "str", "keyVaultSecretName": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "targetService": "target_service_base", + "type": "str", + "vNetSolution": {"deleteOrUpdateBehavior": "str", "type": "str"}, + }, + api_version="2024-07-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.connector.begin_delete( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + connector_name="str", + api_version="2024-07-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.connector.begin_update( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + connector_name="str", + parameters={ + "authInfo": "auth_info_base", + "clientType": "str", + "configurationInfo": { + "action": "str", + "additionalConfigurations": {"str": "str"}, + "additionalConnectionStringProperties": {"str": "str"}, + "configurationStore": {"appConfigurationId": "str"}, + "customizedKeys": {"str": "str"}, + "daprProperties": { + "bindingComponentDirection": "str", + "componentType": "str", + "metadata": [ + { + "description": "str", + "name": "str", + "required": "str", + "secretRef": "str", + "value": "str", + } + ], + "runtimeVersion": "str", + "scopes": ["str"], + "secretStoreComponent": "str", + "version": "str", + }, + "deleteOrUpdateBehavior": "str", + }, + "provisioningState": "str", + "publicNetworkSolution": { + "action": "str", + "deleteOrUpdateBehavior": "str", + "firewallRules": {"azureServices": "str", "callerClientIP": "str", "ipRanges": ["str"]}, + }, + "scope": "str", + "secretStore": {"keyVaultId": "str", "keyVaultSecretName": "str"}, + "targetService": "target_service_base", + "vNetSolution": {"deleteOrUpdateBehavior": "str", "type": "str"}, + }, + api_version="2024-07-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_validate(self, resource_group): + response = await ( + await self.client.connector.begin_validate( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + connector_name="str", + api_version="2024-07-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_generate_configurations(self, resource_group): + response = await self.client.connector.generate_configurations( + subscription_id="str", + resource_group_name=resource_group.name, + location="str", + connector_name="str", + api_version="2024-07-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_linker_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_linker_operations.py new file mode 100644 index 000000000000..70f75028cccf --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_linker_operations.py @@ -0,0 +1,179 @@ +# 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.servicelinker import ServiceLinkerManagementClient + +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 TestServiceLinkerManagementLinkerOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ServiceLinkerManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.linker.list( + resource_uri="str", + api_version="2024-07-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.linker.get( + resource_uri="str", + linker_name="str", + api_version="2024-07-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.linker.begin_create_or_update( + resource_uri="str", + linker_name="str", + parameters={ + "authInfo": "auth_info_base", + "clientType": "str", + "configurationInfo": { + "action": "str", + "additionalConfigurations": {"str": "str"}, + "additionalConnectionStringProperties": {"str": "str"}, + "configurationStore": {"appConfigurationId": "str"}, + "customizedKeys": {"str": "str"}, + "daprProperties": { + "bindingComponentDirection": "str", + "componentType": "str", + "metadata": [ + {"description": "str", "name": "str", "required": "str", "secretRef": "str", "value": "str"} + ], + "runtimeVersion": "str", + "scopes": ["str"], + "secretStoreComponent": "str", + "version": "str", + }, + "deleteOrUpdateBehavior": "str", + }, + "id": "str", + "name": "str", + "provisioningState": "str", + "publicNetworkSolution": { + "action": "str", + "deleteOrUpdateBehavior": "str", + "firewallRules": {"azureServices": "str", "callerClientIP": "str", "ipRanges": ["str"]}, + }, + "scope": "str", + "secretStore": {"keyVaultId": "str", "keyVaultSecretName": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "targetService": "target_service_base", + "type": "str", + "vNetSolution": {"deleteOrUpdateBehavior": "str", "type": "str"}, + }, + api_version="2024-07-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.linker.begin_delete( + resource_uri="str", + linker_name="str", + api_version="2024-07-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.linker.begin_update( + resource_uri="str", + linker_name="str", + parameters={ + "authInfo": "auth_info_base", + "clientType": "str", + "configurationInfo": { + "action": "str", + "additionalConfigurations": {"str": "str"}, + "additionalConnectionStringProperties": {"str": "str"}, + "configurationStore": {"appConfigurationId": "str"}, + "customizedKeys": {"str": "str"}, + "daprProperties": { + "bindingComponentDirection": "str", + "componentType": "str", + "metadata": [ + {"description": "str", "name": "str", "required": "str", "secretRef": "str", "value": "str"} + ], + "runtimeVersion": "str", + "scopes": ["str"], + "secretStoreComponent": "str", + "version": "str", + }, + "deleteOrUpdateBehavior": "str", + }, + "provisioningState": "str", + "publicNetworkSolution": { + "action": "str", + "deleteOrUpdateBehavior": "str", + "firewallRules": {"azureServices": "str", "callerClientIP": "str", "ipRanges": ["str"]}, + }, + "scope": "str", + "secretStore": {"keyVaultId": "str", "keyVaultSecretName": "str"}, + "targetService": "target_service_base", + "vNetSolution": {"deleteOrUpdateBehavior": "str", "type": "str"}, + }, + api_version="2024-07-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_validate(self, resource_group): + response = self.client.linker.begin_validate( + resource_uri="str", + linker_name="str", + api_version="2024-07-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_configurations(self, resource_group): + response = self.client.linker.list_configurations( + resource_uri="str", + linker_name="str", + api_version="2024-07-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_linker_operations_async.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_linker_operations_async.py new file mode 100644 index 000000000000..9c951337a4ad --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_linker_operations_async.py @@ -0,0 +1,200 @@ +# 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.servicelinker.aio import ServiceLinkerManagementClient + +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 TestServiceLinkerManagementLinkerOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ServiceLinkerManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.linker.list( + resource_uri="str", + api_version="2024-07-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.linker.get( + resource_uri="str", + linker_name="str", + api_version="2024-07-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.linker.begin_create_or_update( + resource_uri="str", + linker_name="str", + parameters={ + "authInfo": "auth_info_base", + "clientType": "str", + "configurationInfo": { + "action": "str", + "additionalConfigurations": {"str": "str"}, + "additionalConnectionStringProperties": {"str": "str"}, + "configurationStore": {"appConfigurationId": "str"}, + "customizedKeys": {"str": "str"}, + "daprProperties": { + "bindingComponentDirection": "str", + "componentType": "str", + "metadata": [ + { + "description": "str", + "name": "str", + "required": "str", + "secretRef": "str", + "value": "str", + } + ], + "runtimeVersion": "str", + "scopes": ["str"], + "secretStoreComponent": "str", + "version": "str", + }, + "deleteOrUpdateBehavior": "str", + }, + "id": "str", + "name": "str", + "provisioningState": "str", + "publicNetworkSolution": { + "action": "str", + "deleteOrUpdateBehavior": "str", + "firewallRules": {"azureServices": "str", "callerClientIP": "str", "ipRanges": ["str"]}, + }, + "scope": "str", + "secretStore": {"keyVaultId": "str", "keyVaultSecretName": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "targetService": "target_service_base", + "type": "str", + "vNetSolution": {"deleteOrUpdateBehavior": "str", "type": "str"}, + }, + api_version="2024-07-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.linker.begin_delete( + resource_uri="str", + linker_name="str", + api_version="2024-07-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.linker.begin_update( + resource_uri="str", + linker_name="str", + parameters={ + "authInfo": "auth_info_base", + "clientType": "str", + "configurationInfo": { + "action": "str", + "additionalConfigurations": {"str": "str"}, + "additionalConnectionStringProperties": {"str": "str"}, + "configurationStore": {"appConfigurationId": "str"}, + "customizedKeys": {"str": "str"}, + "daprProperties": { + "bindingComponentDirection": "str", + "componentType": "str", + "metadata": [ + { + "description": "str", + "name": "str", + "required": "str", + "secretRef": "str", + "value": "str", + } + ], + "runtimeVersion": "str", + "scopes": ["str"], + "secretStoreComponent": "str", + "version": "str", + }, + "deleteOrUpdateBehavior": "str", + }, + "provisioningState": "str", + "publicNetworkSolution": { + "action": "str", + "deleteOrUpdateBehavior": "str", + "firewallRules": {"azureServices": "str", "callerClientIP": "str", "ipRanges": ["str"]}, + }, + "scope": "str", + "secretStore": {"keyVaultId": "str", "keyVaultSecretName": "str"}, + "targetService": "target_service_base", + "vNetSolution": {"deleteOrUpdateBehavior": "str", "type": "str"}, + }, + api_version="2024-07-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_validate(self, resource_group): + response = await ( + await self.client.linker.begin_validate( + resource_uri="str", + linker_name="str", + api_version="2024-07-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_configurations(self, resource_group): + response = await self.client.linker.list_configurations( + resource_uri="str", + linker_name="str", + api_version="2024-07-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_linkers_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_linkers_operations.py new file mode 100644 index 000000000000..3548c4d5c6da --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_linkers_operations.py @@ -0,0 +1,128 @@ +# 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.servicelinker import ServiceLinkerManagementClient + +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 TestServiceLinkerManagementLinkersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ServiceLinkerManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_dryrun(self, resource_group): + response = self.client.linkers.list_dryrun( + resource_uri="str", + api_version="2024-07-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_dryrun(self, resource_group): + response = self.client.linkers.get_dryrun( + resource_uri="str", + dryrun_name="str", + api_version="2024-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_dryrun(self, resource_group): + response = self.client.linkers.begin_create_dryrun( + resource_uri="str", + dryrun_name="str", + parameters={ + "id": "str", + "name": "str", + "operationPreviews": [ + {"action": "str", "description": "str", "name": "str", "operationType": "str", "scope": "str"} + ], + "parameters": "dryrun_parameters", + "prerequisiteResults": ["dryrun_prerequisite_result"], + "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-07-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_dryrun(self, resource_group): + response = self.client.linkers.begin_update_dryrun( + resource_uri="str", + dryrun_name="str", + parameters={ + "operationPreviews": [ + {"action": "str", "description": "str", "name": "str", "operationType": "str", "scope": "str"} + ], + "parameters": "dryrun_parameters", + "prerequisiteResults": ["dryrun_prerequisite_result"], + "provisioningState": "str", + }, + api_version="2024-07-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_dryrun(self, resource_group): + response = self.client.linkers.delete_dryrun( + resource_uri="str", + dryrun_name="str", + api_version="2024-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_generate_configurations(self, resource_group): + response = self.client.linkers.generate_configurations( + resource_uri="str", + linker_name="str", + api_version="2024-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_dapr_configurations(self, resource_group): + response = self.client.linkers.list_dapr_configurations( + resource_uri="str", + api_version="2024-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_linkers_operations_async.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_linkers_operations_async.py new file mode 100644 index 000000000000..af8413a4ce9a --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_linkers_operations_async.py @@ -0,0 +1,133 @@ +# 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.servicelinker.aio import ServiceLinkerManagementClient + +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 TestServiceLinkerManagementLinkersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ServiceLinkerManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_dryrun(self, resource_group): + response = self.client.linkers.list_dryrun( + resource_uri="str", + api_version="2024-07-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_dryrun(self, resource_group): + response = await self.client.linkers.get_dryrun( + resource_uri="str", + dryrun_name="str", + api_version="2024-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_dryrun(self, resource_group): + response = await ( + await self.client.linkers.begin_create_dryrun( + resource_uri="str", + dryrun_name="str", + parameters={ + "id": "str", + "name": "str", + "operationPreviews": [ + {"action": "str", "description": "str", "name": "str", "operationType": "str", "scope": "str"} + ], + "parameters": "dryrun_parameters", + "prerequisiteResults": ["dryrun_prerequisite_result"], + "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-07-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_dryrun(self, resource_group): + response = await ( + await self.client.linkers.begin_update_dryrun( + resource_uri="str", + dryrun_name="str", + parameters={ + "operationPreviews": [ + {"action": "str", "description": "str", "name": "str", "operationType": "str", "scope": "str"} + ], + "parameters": "dryrun_parameters", + "prerequisiteResults": ["dryrun_prerequisite_result"], + "provisioningState": "str", + }, + api_version="2024-07-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_dryrun(self, resource_group): + response = await self.client.linkers.delete_dryrun( + resource_uri="str", + dryrun_name="str", + api_version="2024-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_generate_configurations(self, resource_group): + response = await self.client.linkers.generate_configurations( + resource_uri="str", + linker_name="str", + api_version="2024-07-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_dapr_configurations(self, resource_group): + response = self.client.linkers.list_dapr_configurations( + resource_uri="str", + api_version="2024-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_operations.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_operations.py new file mode 100644 index 000000000000..8d932442ed85 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.servicelinker import ServiceLinkerManagementClient + +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 TestServiceLinkerManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ServiceLinkerManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_operations_async.py b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_operations_async.py new file mode 100644 index 000000000000..bfd5a41c5901 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/generated_tests/test_service_linker_management_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.servicelinker.aio import ServiceLinkerManagementClient + +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 TestServiceLinkerManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ServiceLinkerManagementClient, 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-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/setup.py b/sdk/servicelinker/azure-mgmt-servicelinker/setup.py index 2b410cf24d40..fa3281f8b346 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/setup.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/setup.py @@ -74,9 +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", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], python_requires=">=3.8", ) diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/tests/conftest.py b/sdk/servicelinker/azure-mgmt-servicelinker/tests/conftest.py index 587e126e50b0..74ab781506a7 100644 --- a/sdk/servicelinker/azure-mgmt-servicelinker/tests/conftest.py +++ b/sdk/servicelinker/azure-mgmt-servicelinker/tests/conftest.py @@ -1,50 +1,43 @@ +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# 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 platform import pytest -import sys - from dotenv import load_dotenv - -from devtools_testutils import test_proxy, add_general_regex_sanitizer -from devtools_testutils import add_header_regex_sanitizer, add_body_key_sanitizer +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): - subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") - tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") - client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") - client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=subscription_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=tenant_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=client_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=client_secret, value="00000000-0000-0000-0000-000000000000") + servicelinkermanagement_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + servicelinkermanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + servicelinkermanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + servicelinkermanagement_client_secret = os.environ.get( + "AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=servicelinkermanagement_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer(regex=servicelinkermanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=servicelinkermanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer( + regex=servicelinkermanagement_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") \ No newline at end of file + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_cli_mgmt_servicelinker.py b/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_cli_mgmt_servicelinker.py deleted file mode 100644 index 0ffc1ebcd63e..000000000000 --- a/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_cli_mgmt_servicelinker.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding: utf-8 - -#------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -#-------------------------------------------------------------------------- - -from azure.mgmt.servicelinker import ServiceLinkerManagementClient -from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy - -AZURE_LOCATION = 'eastus' - -class TestMgmtServiceLinker(AzureMgmtRecordedTestCase): - - def setup_method(self, method): - self.client = self.create_mgmt_client(ServiceLinkerManagementClient) - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_list_by_resource_group(self, resource_group): - assert list(self.client.connector.list(self.get_settings_value("SUBSCRIPTION_ID"), resource_group.name, AZURE_LOCATION)) == [] - - @recorded_by_proxy - def test_list_operations(self): - assert list(self.client.operations.list()) diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_configuration_names_operations_async_test.py b/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_configuration_names_operations_async_test.py new file mode 100644 index 000000000000..3426dd5d6e00 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_configuration_names_operations_async_test.py @@ -0,0 +1,28 @@ +# 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.servicelinker.aio import ServiceLinkerManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestServiceLinkerManagementConfigurationNamesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ServiceLinkerManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.configuration_names.list() + result = [r async for r in response] + assert result + \ No newline at end of file diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_configuration_names_operations_test.py b/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_configuration_names_operations_test.py new file mode 100644 index 000000000000..9945f19aa842 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_configuration_names_operations_test.py @@ -0,0 +1,27 @@ +# 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.servicelinker import ServiceLinkerManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestServiceLinkerManagementConfigurationNamesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ServiceLinkerManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.configuration_names.list() + result = [r for r in response] + assert result + \ No newline at end of file diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_connector_operations_async_test.py b/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_connector_operations_async_test.py new file mode 100644 index 000000000000..34591fd4a59e --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_connector_operations_async_test.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.servicelinker.aio import ServiceLinkerManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestServiceLinkerManagementConnectorOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ServiceLinkerManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_dryrun(self, resource_group): + response = self.client.connector.list_dryrun( + subscription_id=self.get_settings_value("SUBSCRIPTION_ID"), + resource_group_name=resource_group.name, + location=AZURE_LOCATION, + ) + result = [r async for r in response] + assert result == [] + + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.connector.list( + subscription_id=self.get_settings_value("SUBSCRIPTION_ID"), + resource_group_name=resource_group.name, + location=AZURE_LOCATION, + ) + result = [r async for r in response] + assert result == [] diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_connector_operations_test.py b/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_connector_operations_test.py new file mode 100644 index 000000000000..2fe716692af1 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_connector_operations_test.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.servicelinker import ServiceLinkerManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestServiceLinkerManagementConnectorOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ServiceLinkerManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_dryrun(self, resource_group): + response = self.client.connector.list_dryrun( + subscription_id=self.get_settings_value("SUBSCRIPTION_ID"), + resource_group_name=resource_group.name, + location=AZURE_LOCATION, + ) + result = [r for r in response] + assert result == [] + + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.connector.list( + subscription_id=self.get_settings_value("SUBSCRIPTION_ID"), + resource_group_name=resource_group.name, + location=AZURE_LOCATION, + ) + result = [r for r in response] + assert result == [] diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_operations_async_test.py b/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_operations_async_test.py new file mode 100644 index 000000000000..7197bb1e6118 --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_operations_async_test.py @@ -0,0 +1,28 @@ +# 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.servicelinker.aio import ServiceLinkerManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestServiceLinkerManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ServiceLinkerManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.operations.list() + result = [r async for r in response] + assert result + \ No newline at end of file diff --git a/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_operations_test.py b/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_operations_test.py new file mode 100644 index 000000000000..d2610fbed95a --- /dev/null +++ b/sdk/servicelinker/azure-mgmt-servicelinker/tests/test_service_linker_management_operations_test.py @@ -0,0 +1,26 @@ +# 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.servicelinker import ServiceLinkerManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestServiceLinkerManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ServiceLinkerManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list() + result = [r for r in response] + assert result