From 34a03ee1636b7f9b98b2f96a9cfeda9631dc0dbb Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Sun, 22 Sep 2024 20:35:06 -0700 Subject: [PATCH] [AutoRelease] t2-elasticsan-2024-08-21-47787(can only be merged by SDK owner) (#36970) * code and test * update testcases * Update CHANGELOG.md --------- Co-authored-by: azure-sdk Co-authored-by: ChenxiJiang333 Co-authored-by: ChenxiJiang333 <119990644+ChenxiJiang333@users.noreply.github.com> --- .../azure-mgmt-elasticsan/CHANGELOG.md | 7 + .../azure-mgmt-elasticsan/_meta.json | 10 +- .../azure/mgmt/elasticsan/_configuration.py | 11 +- .../elasticsan/_elastic_san_mgmt_client.py | 31 +- .../azure/mgmt/elasticsan/_serialization.py | 94 +++-- .../azure/mgmt/elasticsan/_vendor.py | 16 - .../azure/mgmt/elasticsan/_version.py | 2 +- .../mgmt/elasticsan/aio/_configuration.py | 11 +- .../aio/_elastic_san_mgmt_client.py | 33 +- .../operations/_elastic_sans_operations.py | 323 +++++++---------- .../elasticsan/aio/operations/_operations.py | 37 +- ...private_endpoint_connections_operations.py | 199 ++++------- .../_private_link_resources_operations.py | 34 +- .../aio/operations/_skus_operations.py | 37 +- .../operations/_volume_groups_operations.py | 289 ++++++--------- .../_volume_snapshots_operations.py | 199 ++++------- .../aio/operations/_volumes_operations.py | 288 ++++++--------- .../models/_elastic_san_mgmt_client_enums.py | 2 +- .../mgmt/elasticsan/models/_models_py3.py | 94 ++--- .../operations/_elastic_sans_operations.py | 335 +++++++----------- .../mgmt/elasticsan/operations/_operations.py | 39 +- ...private_endpoint_connections_operations.py | 207 ++++------- .../_private_link_resources_operations.py | 36 +- .../elasticsan/operations/_skus_operations.py | 39 +- .../operations/_volume_groups_operations.py | 299 ++++++---------- .../_volume_snapshots_operations.py | 207 ++++------- .../operations/_volumes_operations.py | 298 ++++++---------- .../dev_requirements.txt | 3 +- .../elastic_sans_create_maximum_set_gen.py | 5 +- .../elastic_sans_create_minimum_set_gen.py | 5 +- .../elastic_sans_delete_maximum_set_gen.py | 3 +- .../elastic_sans_delete_minimum_set_gen.py | 3 +- .../elastic_sans_get_maximum_set_gen.py | 3 +- .../elastic_sans_get_minimum_set_gen.py | 3 +- ..._list_by_resource_group_maximum_set_gen.py | 3 +- ..._list_by_resource_group_minimum_set_gen.py | 3 +- ...ns_list_by_subscription_maximum_set_gen.py | 3 +- ...ns_list_by_subscription_minimum_set_gen.py | 3 +- .../elastic_sans_update_maximum_set_gen.py | 5 +- .../operations_list_maximum_set_gen.py | 3 +- .../operations_list_minimum_set_gen.py | 3 +- ...oint_connections_create_maximum_set_gen.py | 5 +- ...oint_connections_create_minimum_set_gen.py | 5 +- ...oint_connections_delete_maximum_set_gen.py | 3 +- ...oint_connections_delete_minimum_set_gen.py | 3 +- ...ndpoint_connections_get_maximum_set_gen.py | 3 +- ...ndpoint_connections_get_minimum_set_gen.py | 3 +- ...dpoint_connections_list_maximum_set_gen.py | 3 +- ...dpoint_connections_list_minimum_set_gen.py | 3 +- ...ces_list_by_elastic_san_maximum_set_gen.py | 3 +- ...ces_list_by_elastic_san_minimum_set_gen.py | 3 +- .../skus_list_maximum_set_gen.py | 3 +- .../skus_list_minimum_set_gen.py | 3 +- .../volume_groups_create_maximum_set_gen.py | 27 +- .../volume_groups_delete_maximum_set_gen.py | 3 +- .../volume_groups_delete_minimum_set_gen.py | 3 +- .../volume_groups_get_maximum_set_gen.py | 3 +- .../volume_groups_get_minimum_set_gen.py | 3 +- ...ups_list_by_elastic_san_maximum_set_gen.py | 3 +- ...ups_list_by_elastic_san_minimum_set_gen.py | 3 +- .../volume_groups_update_maximum_set_gen.py | 25 +- ...volume_snapshots_create_maximum_set_gen.py | 5 +- ...volume_snapshots_create_minimum_set_gen.py | 5 +- ...volume_snapshots_delete_maximum_set_gen.py | 3 +- ...volume_snapshots_delete_minimum_set_gen.py | 3 +- .../volume_snapshots_get_maximum_set_gen.py | 3 +- .../volume_snapshots_get_minimum_set_gen.py | 3 +- ...ts_list_by_volume_group_maximum_set_gen.py | 3 +- ...ts_list_by_volume_group_minimum_set_gen.py | 3 +- .../volumes_create_maximum_set_gen.py | 5 +- .../volumes_create_minimum_set_gen.py | 5 +- .../volumes_delete_maximum_set_gen.py | 3 +- .../volumes_delete_minimum_set_gen.py | 3 +- .../volumes_get_maximum_set_gen.py | 3 +- .../volumes_get_minimum_set_gen.py | 3 +- ...es_list_by_volume_group_maximum_set_gen.py | 3 +- ...es_list_by_volume_group_minimum_set_gen.py | 3 +- .../volumes_update_maximum_set_gen.py | 5 +- .../generated_tests/conftest.py | 35 ++ ...lastic_san_mgmt_elastic_sans_operations.py | 145 ++++++++ ..._san_mgmt_elastic_sans_operations_async.py | 152 ++++++++ .../test_elastic_san_mgmt_operations.py | 29 ++ .../test_elastic_san_mgmt_operations_async.py | 30 ++ ...private_endpoint_connections_operations.py | 93 +++++ ...e_endpoint_connections_operations_async.py | 98 +++++ ..._mgmt_private_link_resources_operations.py | 31 ++ ...private_link_resources_operations_async.py | 32 ++ .../test_elastic_san_mgmt_skus_operations.py | 29 ++ ..._elastic_san_mgmt_skus_operations_async.py | 30 ++ ...astic_san_mgmt_volume_groups_operations.py | 170 +++++++++ ...san_mgmt_volume_groups_operations_async.py | 177 +++++++++ ...ic_san_mgmt_volume_snapshots_operations.py | 93 +++++ ..._mgmt_volume_snapshots_operations_async.py | 98 +++++ ...est_elastic_san_mgmt_volumes_operations.py | 116 ++++++ ...astic_san_mgmt_volumes_operations_async.py | 123 +++++++ sdk/elasticsan/azure-mgmt-elasticsan/setup.py | 7 +- .../azure-mgmt-elasticsan/tests/conftest.py | 35 ++ ...mgmt_elastic_sans_operations_async_test.py | 30 ++ ...c_san_mgmt_elastic_sans_operations_test.py | 29 ++ ..._elastic_san_mgmt_operations_async_test.py | 28 ++ .../test_elastic_san_mgmt_operations_test.py | 27 ++ 101 files changed, 3020 insertions(+), 2013 deletions(-) delete mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_vendor.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/conftest.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_elastic_sans_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_elastic_sans_operations_async.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_operations_async.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_endpoint_connections_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_endpoint_connections_operations_async.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_link_resources_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_link_resources_operations_async.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_skus_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_skus_operations_async.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_groups_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_groups_operations_async.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_snapshots_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_snapshots_operations_async.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volumes_operations.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volumes_operations_async.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/tests/conftest.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/tests/test_elastic_san_mgmt_elastic_sans_operations_async_test.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/tests/test_elastic_san_mgmt_elastic_sans_operations_test.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/tests/test_elastic_san_mgmt_operations_async_test.py create mode 100644 sdk/elasticsan/azure-mgmt-elasticsan/tests/test_elastic_san_mgmt_operations_test.py diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/CHANGELOG.md b/sdk/elasticsan/azure-mgmt-elasticsan/CHANGELOG.md index 32d686ba518f..cc01c2ad5cd9 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/CHANGELOG.md +++ b/sdk/elasticsan/azure-mgmt-elasticsan/CHANGELOG.md @@ -1,5 +1,12 @@ # Release History +## 1.1.0 (2024-09-23) + +### Features Added + + - Model VolumeGroupProperties has a new parameter enforce_data_integrity_check_for_iscsi + - Model VolumeGroupUpdateProperties has a new parameter enforce_data_integrity_check_for_iscsi + ## 1.0.0 (2024-01-25) ### Features Added diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/_meta.json b/sdk/elasticsan/azure-mgmt-elasticsan/_meta.json index e09bc1adcd23..d6b9194cb417 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/_meta.json +++ b/sdk/elasticsan/azure-mgmt-elasticsan/_meta.json @@ -1,11 +1,11 @@ { - "commit": "09e36d3ffae7fa6428cef8c86f2ad7caf4704e2c", + "commit": "cd41ba31a6af51dae34b0a5930eeb2e77a04b481", "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.17.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/elasticsan/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/elasticsan/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.17.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/elasticsan/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_configuration.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_configuration.py index e000042acbec..dae38f28153e 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_configuration.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_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 ElasticSanMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ElasticSanMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ElasticSanMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class ElasticSanMgmtClientConfiguration(Configuration): # pylint: disable=too-m :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-01-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ElasticSanMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-01-01") + api_version: str = kwargs.pop("api_version", "2024-05-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-elasticsan/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_elastic_san_mgmt_client.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_elastic_san_mgmt_client.py index afbd7d5b0689..299f3726666a 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_elastic_san_mgmt_client.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_elastic_san_mgmt_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 ElasticSanMgmtClientConfiguration @@ -58,7 +61,7 @@ class ElasticSanMgmtClient: # pylint: disable=client-accepts-api-version-keywor :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-01-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-05-01". 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 @@ -75,7 +78,25 @@ def __init__( self._config = ElasticSanMgmtClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -96,7 +117,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 @@ -116,12 +137,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) -> "ElasticSanMgmtClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_serialization.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_serialization.py index 4bae2292227b..8139854b97bb 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_serialization.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_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/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_vendor.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_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/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_version.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_version.py index c47f66669f1b..59deb8c7263b 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_version.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.1.0" diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_configuration.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_configuration.py index cbd9306721db..896fbe5fd932 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_configuration.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/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 ElasticSanMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class ElasticSanMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for ElasticSanMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class ElasticSanMgmtClientConfiguration(Configuration): # pylint: disable=too-m :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-01-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-05-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(ElasticSanMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-01-01") + api_version: str = kwargs.pop("api_version", "2024-05-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-elasticsan/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_elastic_san_mgmt_client.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_elastic_san_mgmt_client.py index de7d474a9034..7c961d880aa1 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_elastic_san_mgmt_client.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/_elastic_san_mgmt_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 @@ -58,7 +61,7 @@ class ElasticSanMgmtClient: # pylint: disable=client-accepts-api-version-keywor :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-01-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-05-01". 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 @@ -75,7 +78,25 @@ def __init__( self._config = ElasticSanMgmtClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -96,7 +117,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 @@ -116,12 +139,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) -> "ElasticSanMgmtClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_elastic_sans_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_elastic_sans_operations.py index 5f14fd0cf698..249043312d27 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_elastic_sans_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_elastic_sans_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._elastic_sans_operations import ( build_create_request, build_delete_request, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -67,7 +72,6 @@ def __init__(self, *args, **kwargs) -> None: def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ElasticSan"]: """Gets a list of ElasticSans in a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ElasticSan or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.ElasticSan] :raises ~azure.core.exceptions.HttpResponseError: @@ -78,7 +82,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ElasticS api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticSanList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,15 +93,13 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ElasticS def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -109,13 +111,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("ElasticSanList", pipeline_response) @@ -125,11 +126,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 @@ -142,10 +143,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ElasticSan/elasticSans" - } - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ElasticSan"]: """Gets a list of ElasticSan in a resource group. @@ -153,7 +150,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ElasticSan or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.ElasticSan] :raises ~azure.core.exceptions.HttpResponseError: @@ -164,7 +160,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticSanList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -175,16 +171,14 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -196,13 +190,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("ElasticSanList", pipeline_response) @@ -212,11 +205,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 @@ -229,14 +222,14 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans" - } - async def _create_initial( - self, resource_group_name: str, elastic_san_name: str, parameters: Union[_models.ElasticSan, IO], **kwargs: Any - ) -> _models.ElasticSan: - error_map = { + self, + resource_group_name: str, + elastic_san_name: str, + parameters: Union[_models.ElasticSan, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -249,7 +242,7 @@ async def _create_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.ElasticSan] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -259,7 +252,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "ElasticSan") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, subscription_id=self._config.subscription_id, @@ -267,40 +260,35 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _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("ElasticSan", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ElasticSan", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}" - } - @overload async def begin_create( self, @@ -323,14 +311,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ElasticSan or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] @@ -342,7 +322,7 @@ async def begin_create( self, resource_group_name: str, elastic_san_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -355,18 +335,10 @@ async def begin_create( :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_name: str :param parameters: Elastic San object. 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 ElasticSan or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] @@ -375,7 +347,11 @@ async def begin_create( @distributed_trace_async async def begin_create( - self, resource_group_name: str, elastic_san_name: str, parameters: Union[_models.ElasticSan, IO], **kwargs: Any + self, + resource_group_name: str, + elastic_san_name: str, + parameters: Union[_models.ElasticSan, IO[bytes]], + **kwargs: Any ) -> AsyncLROPoller[_models.ElasticSan]: """Create ElasticSan. @@ -384,19 +360,9 @@ async def begin_create( :type resource_group_name: str :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_name: str - :param parameters: Elastic San object. Is either a ElasticSan type or a IO type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.ElasticSan or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Elastic San object. Is either a ElasticSan type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.elasticsan.models.ElasticSan or IO[bytes] :return: An instance of AsyncLROPoller that returns either ElasticSan or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] @@ -423,12 +389,13 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ElasticSan", pipeline_response) + deserialized = self._deserialize("ElasticSan", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -440,26 +407,24 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ElasticSan].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}" - } + return AsyncLROPoller[_models.ElasticSan]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, elastic_san_name: str, - parameters: Union[_models.ElasticSanUpdate, IO], + parameters: Union[_models.ElasticSanUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ElasticSan]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -472,7 +437,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ElasticSan]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -482,7 +447,7 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "ElasticSanUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, subscription_id=self._config.subscription_id, @@ -490,41 +455,38 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ElasticSan", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -548,14 +510,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 ElasticSan or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] @@ -567,7 +521,7 @@ async def begin_update( self, resource_group_name: str, elastic_san_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -580,18 +534,10 @@ async def begin_update( :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_name: str :param parameters: Elastic San object. 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 ElasticSan or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] @@ -603,7 +549,7 @@ async def begin_update( self, resource_group_name: str, elastic_san_name: str, - parameters: Union[_models.ElasticSanUpdate, IO], + parameters: Union[_models.ElasticSanUpdate, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ElasticSan]: """Update a Elastic San. @@ -613,20 +559,9 @@ async def begin_update( :type resource_group_name: str :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_name: str - :param parameters: Elastic San object. Is either a ElasticSanUpdate type or a IO type. + :param parameters: Elastic San object. Is either a ElasticSanUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.ElasticSanUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :type parameters: ~azure.mgmt.elasticsan.models.ElasticSanUpdate or IO[bytes] :return: An instance of AsyncLROPoller that returns either ElasticSan or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.ElasticSan] @@ -653,12 +588,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("ElasticSan", pipeline_response) + deserialized = self._deserialize("ElasticSan", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -670,22 +606,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ElasticSan].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.ElasticSan/elasticSans/{elasticSanName}" - } + return AsyncLROPoller[_models.ElasticSan]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, elastic_san_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -697,28 +631,31 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -727,12 +664,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -745,14 +682,6 @@ async def begin_delete( :type resource_group_name: str :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_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: @@ -766,7 +695,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, api_version=api_version, @@ -775,11 +704,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( @@ -790,17 +720,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.ElasticSan/elasticSans/{elasticSanName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, elastic_san_name: str, **kwargs: Any) -> _models.ElasticSan: @@ -811,12 +737,11 @@ async def get(self, resource_group_name: str, elastic_san_name: str, **kwargs: A :type resource_group_name: str :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ElasticSan or the result of cls(response) :rtype: ~azure.mgmt.elasticsan.models.ElasticSan :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -830,21 +755,19 @@ async def get(self, resource_group_name: str, elastic_san_name: str, **kwargs: A api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticSan] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -854,13 +777,9 @@ async def get(self, resource_group_name: str, elastic_san_name: str, **kwargs: A error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ElasticSan", pipeline_response) + deserialized = self._deserialize("ElasticSan", 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.ElasticSan/elasticSans/{elasticSanName}" - } + return deserialized # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_operations.py index 8ca29c53d8ae..b6dbe0073c64 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/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"]: """Gets a list of ElasticSan 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.elasticsan.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 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.ElasticSan/operations"} diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_private_endpoint_connections_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_private_endpoint_connections_operations.py index 0ae83eae5f80..5fa07160fcaf 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._private_endpoint_connections_operations import ( build_create_request, build_delete_request, @@ -38,6 +39,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,10 +71,10 @@ async def _create_initial( resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,7 +87,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -92,7 +97,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "PrivateEndpointConnection") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -101,40 +106,35 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - @overload async def begin_create( self, @@ -160,14 +160,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -181,7 +173,7 @@ async def begin_create( resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -196,18 +188,10 @@ async def begin_create( :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. :type private_endpoint_connection_name: str :param parameters: Private Endpoint Connection Approval object. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -221,7 +205,7 @@ async def begin_create( resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the Elastic San. @@ -234,19 +218,8 @@ async def begin_create( :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. :type private_endpoint_connection_name: str :param parameters: Private Endpoint Connection Approval object. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection or IO[bytes] :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -275,12 +248,13 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -292,17 +266,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def get( @@ -317,12 +289,11 @@ async def get( :type elastic_san_name: str :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -336,22 +307,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -361,21 +330,17 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -387,29 +352,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -418,12 +386,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -438,14 +406,6 @@ async def begin_delete( :type elastic_san_name: str :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -459,7 +419,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -469,11 +429,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( @@ -484,17 +445,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.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list( @@ -507,7 +464,6 @@ def list( :type resource_group_name: str :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -520,7 +476,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -531,17 +487,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -553,13 +507,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -569,11 +522,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -585,7 +538,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections" - } diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_private_link_resources_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_private_link_resources_operations.py index b39f6f1f569b..5ef92f5bab3d 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_private_link_resources_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_elastic_san_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]] @@ -61,12 +64,11 @@ async def list_by_elastic_san( :type resource_group_name: str :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.elasticsan.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,21 +82,19 @@ async def list_by_elastic_san( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_elastic_san_request( + _request = build_list_by_elastic_san_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_elastic_san.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -104,13 +104,9 @@ async def list_by_elastic_san( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_elastic_san.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_skus_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_skus_operations.py index 0b9ba7392992..df98d2cbd74c 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_skus_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_skus_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,7 +64,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m :param filter: Specify $filter='location eq :code:``' to filter on location. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.SkuInformation] :raises ~azure.core.exceptions.HttpResponseError: @@ -72,7 +74,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SkuInformationList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,16 +85,14 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -104,13 +104,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("SkuInformationList", pipeline_response) @@ -120,11 +119,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -136,5 +135,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ElasticSan/skus"} diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volume_groups_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volume_groups_operations.py index 6f54c67ee071..b2b400ad442b 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volume_groups_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volume_groups_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._volume_groups_operations import ( build_create_request, build_delete_request, @@ -39,6 +40,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +78,6 @@ def list_by_elastic_san( :type resource_group_name: str :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VolumeGroup or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.VolumeGroup] :raises ~azure.core.exceptions.HttpResponseError: @@ -84,7 +88,7 @@ def list_by_elastic_san( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VolumeGroupList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,17 +99,15 @@ def list_by_elastic_san( def prepare_request(next_link=None): if not next_link: - request = build_list_by_elastic_san_request( + _request = build_list_by_elastic_san_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_elastic_san.metadata["url"], 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 @@ -117,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 async def extract_data(pipeline_response): deserialized = self._deserialize("VolumeGroupList", pipeline_response) @@ -133,11 +134,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,19 +151,15 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_elastic_san.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumeGroups" - } - async def _create_initial( self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, - parameters: Union[_models.VolumeGroup, IO], + parameters: Union[_models.VolumeGroup, IO[bytes]], **kwargs: Any - ) -> _models.VolumeGroup: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -175,7 +172,7 @@ async def _create_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.VolumeGroup] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -185,7 +182,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "VolumeGroup") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -194,40 +191,35 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _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("VolumeGroup", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("VolumeGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" - } - @overload async def begin_create( self, @@ -253,14 +245,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VolumeGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] @@ -273,7 +257,7 @@ async def begin_create( resource_group_name: str, elastic_san_name: str, volume_group_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -288,18 +272,10 @@ async def begin_create( :param volume_group_name: The name of the VolumeGroup. Required. :type volume_group_name: str :param parameters: Volume Group object. 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 VolumeGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] @@ -312,7 +288,7 @@ async def begin_create( resource_group_name: str, elastic_san_name: str, volume_group_name: str, - parameters: Union[_models.VolumeGroup, IO], + parameters: Union[_models.VolumeGroup, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.VolumeGroup]: """Create a Volume Group. @@ -324,19 +300,9 @@ async def begin_create( :type elastic_san_name: str :param volume_group_name: The name of the VolumeGroup. Required. :type volume_group_name: str - :param parameters: Volume Group object. Is either a VolumeGroup type or a IO type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroup or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Volume Group object. Is either a VolumeGroup type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroup or IO[bytes] :return: An instance of AsyncLROPoller that returns either VolumeGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] @@ -364,12 +330,13 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VolumeGroup", pipeline_response) + deserialized = self._deserialize("VolumeGroup", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -381,27 +348,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VolumeGroup].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" - } + return AsyncLROPoller[_models.VolumeGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, - parameters: Union[_models.VolumeGroupUpdate, IO], + parameters: Union[_models.VolumeGroupUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.VolumeGroup]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -414,7 +379,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.VolumeGroup]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -424,7 +389,7 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "VolumeGroupUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -433,41 +398,38 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("VolumeGroup", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -494,14 +456,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 VolumeGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] @@ -514,7 +468,7 @@ async def begin_update( resource_group_name: str, elastic_san_name: str, volume_group_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -529,18 +483,10 @@ async def begin_update( :param volume_group_name: The name of the VolumeGroup. Required. :type volume_group_name: str :param parameters: Volume Group object. 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 VolumeGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] @@ -553,7 +499,7 @@ async def begin_update( resource_group_name: str, elastic_san_name: str, volume_group_name: str, - parameters: Union[_models.VolumeGroupUpdate, IO], + parameters: Union[_models.VolumeGroupUpdate, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.VolumeGroup]: """Update an VolumeGroup. @@ -565,20 +511,9 @@ async def begin_update( :type elastic_san_name: str :param volume_group_name: The name of the VolumeGroup. Required. :type volume_group_name: str - :param parameters: Volume Group object. Is either a VolumeGroupUpdate type or a IO type. + :param parameters: Volume Group object. Is either a VolumeGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroupUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroupUpdate or IO[bytes] :return: An instance of AsyncLROPoller that returns either VolumeGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] @@ -606,12 +541,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("VolumeGroup", pipeline_response) + deserialized = self._deserialize("VolumeGroup", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -623,22 +559,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VolumeGroup].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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" - } + return AsyncLROPoller[_models.VolumeGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -650,29 +584,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _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) @@ -681,12 +618,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -701,14 +638,6 @@ async def begin_delete( :type elastic_san_name: str :param volume_group_name: The name of the VolumeGroup. Required. :type volume_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -722,7 +651,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -732,11 +661,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( @@ -747,17 +677,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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get( @@ -772,12 +698,11 @@ async def get( :type elastic_san_name: str :param volume_group_name: The name of the VolumeGroup. Required. :type volume_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VolumeGroup or the result of cls(response) :rtype: ~azure.mgmt.elasticsan.models.VolumeGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -791,22 +716,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VolumeGroup] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -816,13 +739,9 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("VolumeGroup", pipeline_response) + deserialized = self._deserialize("VolumeGroup", 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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" - } + return deserialized # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volume_snapshots_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volume_snapshots_operations.py index 256818209764..80037fe9ed51 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volume_snapshots_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volume_snapshots_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._volume_snapshots_operations import ( build_create_request, build_delete_request, @@ -38,6 +39,10 @@ build_list_by_volume_group_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]] @@ -83,7 +88,6 @@ def list_by_volume_group( :param filter: Specify $filter='volumeName eq :code:``' to filter on volume. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Snapshot or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: @@ -94,7 +98,7 @@ def list_by_volume_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SnapshotList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -105,19 +109,17 @@ def list_by_volume_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_volume_group_request( + _request = build_list_by_volume_group_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_volume_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -129,13 +131,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SnapshotList", pipeline_response) @@ -145,11 +146,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 @@ -162,20 +163,16 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_volume_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots" - } - async def _create_initial( self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, snapshot_name: str, - parameters: Union[_models.Snapshot, IO], + parameters: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> _models.Snapshot: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,7 +185,7 @@ async def _create_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.Snapshot] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -198,7 +195,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "Snapshot") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -208,40 +205,35 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _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("Snapshot", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Snapshot", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots/{snapshotName}" - } - @overload async def begin_create( self, @@ -270,14 +262,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Snapshot or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Snapshot] @@ -291,7 +275,7 @@ async def begin_create( elastic_san_name: str, volume_group_name: str, snapshot_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -308,18 +292,10 @@ async def begin_create( :param snapshot_name: The name of the volume snapshot within the given volume group. Required. :type snapshot_name: str :param parameters: Snapshot object. 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 Snapshot or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Snapshot] @@ -333,7 +309,7 @@ async def begin_create( elastic_san_name: str, volume_group_name: str, snapshot_name: str, - parameters: Union[_models.Snapshot, IO], + parameters: Union[_models.Snapshot, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Snapshot]: """Create a Volume Snapshot. @@ -347,19 +323,8 @@ async def begin_create( :type volume_group_name: str :param snapshot_name: The name of the volume snapshot within the given volume group. Required. :type snapshot_name: str - :param parameters: Snapshot object. Is either a Snapshot type or a IO type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.Snapshot or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Snapshot object. Is either a Snapshot type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.elasticsan.models.Snapshot or IO[bytes] :return: An instance of AsyncLROPoller that returns either Snapshot or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Snapshot] @@ -388,12 +353,13 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Snapshot", pipeline_response) + deserialized = self._deserialize("Snapshot", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -405,22 +371,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Snapshot].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots/{snapshotName}" - } + return AsyncLROPoller[_models.Snapshot]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, snapshot_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -432,30 +396,33 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -464,12 +431,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots/{snapshotName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -486,14 +453,6 @@ async def begin_delete( :type volume_group_name: str :param snapshot_name: The name of the volume snapshot within the given volume group. Required. :type snapshot_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: @@ -507,7 +466,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -518,11 +477,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( @@ -533,17 +493,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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots/{snapshotName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get( @@ -560,12 +516,11 @@ async def get( :type volume_group_name: str :param snapshot_name: The name of the volume snapshot within the given volume group. Required. :type snapshot_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Snapshot or the result of cls(response) :rtype: ~azure.mgmt.elasticsan.models.Snapshot :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -579,23 +534,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -605,13 +558,9 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Snapshot", pipeline_response) + deserialized = self._deserialize("Snapshot", 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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots/{snapshotName}" - } + return deserialized # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volumes_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volumes_operations.py index 4b63587d30dc..a9ba68e9c0b4 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volumes_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/aio/operations/_volumes_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._volumes_operations import ( build_create_request, build_delete_request, @@ -39,6 +40,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,10 +73,10 @@ async def _create_initial( elastic_san_name: str, volume_group_name: str, volume_name: str, - parameters: Union[_models.Volume, IO], + parameters: Union[_models.Volume, IO[bytes]], **kwargs: Any - ) -> _models.Volume: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,7 +89,7 @@ async def _create_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.Volume] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -94,7 +99,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "Volume") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -104,40 +109,35 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _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("Volume", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Volume", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" - } - @overload async def begin_create( self, @@ -166,14 +166,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] @@ -187,7 +179,7 @@ async def begin_create( elastic_san_name: str, volume_group_name: str, volume_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -204,18 +196,10 @@ async def begin_create( :param volume_name: The name of the Volume. Required. :type volume_name: str :param parameters: Volume object. 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 Volume or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] @@ -229,7 +213,7 @@ async def begin_create( elastic_san_name: str, volume_group_name: str, volume_name: str, - parameters: Union[_models.Volume, IO], + parameters: Union[_models.Volume, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Volume]: """Create a Volume. @@ -243,19 +227,8 @@ async def begin_create( :type volume_group_name: str :param volume_name: The name of the Volume. Required. :type volume_name: str - :param parameters: Volume object. Is either a Volume type or a IO type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.Volume or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Volume object. Is either a Volume type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.elasticsan.models.Volume or IO[bytes] :return: An instance of AsyncLROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] @@ -284,12 +257,13 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Volume", pipeline_response) + deserialized = self._deserialize("Volume", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -301,17 +275,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Volume].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" - } + return AsyncLROPoller[_models.Volume]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, @@ -319,10 +291,10 @@ async def _update_initial( elastic_san_name: str, volume_group_name: str, volume_name: str, - parameters: Union[_models.VolumeUpdate, IO], + parameters: Union[_models.VolumeUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.Volume]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,7 +307,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.Volume]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -345,7 +317,7 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "VolumeUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -355,41 +327,38 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Volume", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -419,14 +388,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 Volume or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] @@ -440,7 +401,7 @@ async def begin_update( elastic_san_name: str, volume_group_name: str, volume_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -457,18 +418,10 @@ async def begin_update( :param volume_name: The name of the Volume. Required. :type volume_name: str :param parameters: Volume object. 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 Volume or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] @@ -482,7 +435,7 @@ async def begin_update( elastic_san_name: str, volume_group_name: str, volume_name: str, - parameters: Union[_models.VolumeUpdate, IO], + parameters: Union[_models.VolumeUpdate, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Volume]: """Update an Volume. @@ -496,19 +449,8 @@ async def begin_update( :type volume_group_name: str :param volume_name: The name of the Volume. Required. :type volume_name: str - :param parameters: Volume object. Is either a VolumeUpdate type or a IO type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Volume object. Is either a VolumeUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeUpdate or IO[bytes] :return: An instance of AsyncLROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.elasticsan.models.Volume] @@ -537,12 +479,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("Volume", pipeline_response) + deserialized = self._deserialize("Volume", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -554,19 +497,17 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Volume].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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" - } + return AsyncLROPoller[_models.Volume]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, elastic_san_name: str, @@ -575,8 +516,8 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements x_ms_delete_snapshots: Optional[Union[str, _models.XMsDeleteSnapshots]] = None, x_ms_force_delete: Optional[Union[str, _models.XMsForceDelete]] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -588,9 +529,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -599,21 +540,24 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements x_ms_delete_snapshots=x_ms_delete_snapshots, x_ms_force_delete=x_ms_force_delete, 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) @@ -622,12 +566,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -659,14 +603,6 @@ async def begin_delete( value are only true or false. Default value is false. Known values are: "true" and "false". Default value is None. :type x_ms_force_delete: str or ~azure.mgmt.elasticsan.models.XMsForceDelete - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: 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: @@ -680,7 +616,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -693,11 +629,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( @@ -708,17 +645,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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get( @@ -735,12 +668,11 @@ async def get( :type volume_group_name: str :param volume_name: The name of the Volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Volume or the result of cls(response) :rtype: ~azure.mgmt.elasticsan.models.Volume :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -754,23 +686,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Volume] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -780,16 +710,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("Volume", pipeline_response) + deserialized = self._deserialize("Volume", 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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" - } + return deserialized # type: ignore @distributed_trace def list_by_volume_group( @@ -804,7 +730,6 @@ def list_by_volume_group( :type elastic_san_name: str :param volume_group_name: The name of the VolumeGroup. Required. :type volume_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Volume or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.elasticsan.models.Volume] :raises ~azure.core.exceptions.HttpResponseError: @@ -815,7 +740,7 @@ def list_by_volume_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VolumeList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -826,18 +751,16 @@ def list_by_volume_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_volume_group_request( + _request = build_list_by_volume_group_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_volume_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -849,13 +772,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("VolumeList", pipeline_response) @@ -865,11 +787,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 @@ -881,7 +803,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_volume_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes" - } diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_elastic_san_mgmt_client_enums.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_elastic_san_mgmt_client_enums.py index 5e80730c84d4..8d285dc4d2ca 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_elastic_san_mgmt_client_enums.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_elastic_san_mgmt_client_enums.py @@ -38,7 +38,7 @@ class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Volume is encrypted at rest with Platform managed key. It is the default encryption type.""" ENCRYPTION_AT_REST_WITH_CUSTOMER_MANAGED_KEY = "EncryptionAtRestWithCustomerManagedKey" """Volume is encrypted at rest with Customer managed key that can be changed and revoked by a - #: customer.""" + customer.""" class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_models_py3.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_models_py3.py index d9fabec0a947..7d76d0f971f3 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_models_py3.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/models/_models_py3.py @@ -23,7 +23,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 @@ -64,10 +64,10 @@ class TrackedResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -117,10 +117,10 @@ class ElasticSan(TrackedResource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -212,7 +212,7 @@ class ElasticSanProperties(_serialization.Model): # pylint: disable=too-many-in 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 sku: resource sku. Required. :vartype sku: ~azure.mgmt.elasticsan.models.Sku @@ -538,7 +538,7 @@ class Identity(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -898,10 +898,10 @@ class PrivateEndpointConnection(Resource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -975,7 +975,7 @@ class PrivateEndpointConnectionProperties(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar provisioning_state: Provisioning State of Private Endpoint connection resource. Known values are: "Invalid", "Succeeded", "Failed", "Canceled", "Pending", "Creating", "Updating", @@ -1036,7 +1036,7 @@ class PrivateLinkResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1189,7 +1189,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 @@ -1201,29 +1201,11 @@ class ProxyResource(Resource): :vartype system_data: ~azure.mgmt.elasticsan.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 Sku(_serialization.Model): """The SKU name. Required for account creation; optional for update. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The sku name. Required. Known values are: "Premium_LRS" and "Premium_ZRS". :vartype name: str or ~azure.mgmt.elasticsan.models.SkuName @@ -1291,7 +1273,7 @@ class SkuInformation(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: Sku Name. Required. Known values are: "Premium_LRS" and "Premium_ZRS". :vartype name: str or ~azure.mgmt.elasticsan.models.SkuName @@ -1408,10 +1390,10 @@ class Snapshot(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1453,10 +1435,10 @@ def __init__(self, *, properties: "_models.SnapshotProperties", **kwargs: Any) - class SnapshotCreationData(_serialization.Model): """Data used when creating a volume snapshot. - 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 source_id: Fully qualified resource ID of the volume. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}". # pylint: disable=line-too-long Required. :vartype source_id: str """ @@ -1472,7 +1454,7 @@ class SnapshotCreationData(_serialization.Model): def __init__(self, *, source_id: str, **kwargs: Any) -> None: """ :keyword source_id: Fully qualified resource ID of the volume. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}". # pylint: disable=line-too-long Required. :paramtype source_id: str """ @@ -1515,7 +1497,7 @@ class SnapshotProperties(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar creation_data: Data used when creating a volume snapshot. Required. :vartype creation_data: ~azure.mgmt.elasticsan.models.SnapshotCreationData @@ -1561,7 +1543,7 @@ class SourceCreationData(_serialization.Model): are: "None", "VolumeSnapshot", "DiskSnapshot", "Disk", and "DiskRestorePoint". :vartype create_source: str or ~azure.mgmt.elasticsan.models.VolumeCreateOption :ivar source_id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype source_id: str """ @@ -1582,7 +1564,7 @@ def __init__( are: "None", "VolumeSnapshot", "DiskSnapshot", "Disk", and "DiskRestorePoint". :paramtype create_source: str or ~azure.mgmt.elasticsan.models.VolumeCreateOption :keyword source_id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :paramtype source_id: str """ super().__init__(**kwargs) @@ -1685,10 +1667,10 @@ def __init__(self, **kwargs: Any) -> None: class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. - 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 virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :vartype virtual_network_resource_id: str :ivar action: The action of virtual network rule. "Allow" @@ -1709,7 +1691,7 @@ def __init__( ) -> None: """ :keyword virtual_network_resource_id: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long Required. :paramtype virtual_network_resource_id: str :keyword action: The action of virtual network rule. "Allow" @@ -1725,10 +1707,10 @@ class Volume(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1773,7 +1755,7 @@ class VolumeGroup(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 @@ -1875,6 +1857,9 @@ class VolumeGroupProperties(_serialization.Model): :ivar private_endpoint_connections: The list of Private Endpoint Connections. :vartype private_endpoint_connections: list[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] + :ivar enforce_data_integrity_check_for_iscsi: A boolean indicating whether or not Data + Integrity Check is enabled. + :vartype enforce_data_integrity_check_for_iscsi: bool """ _validation = { @@ -1889,6 +1874,7 @@ class VolumeGroupProperties(_serialization.Model): "encryption_properties": {"key": "encryptionProperties", "type": "EncryptionProperties"}, "network_acls": {"key": "networkAcls", "type": "NetworkRuleSet"}, "private_endpoint_connections": {"key": "privateEndpointConnections", "type": "[PrivateEndpointConnection]"}, + "enforce_data_integrity_check_for_iscsi": {"key": "enforceDataIntegrityCheckForIscsi", "type": "bool"}, } def __init__( @@ -1898,6 +1884,7 @@ def __init__( encryption: Optional[Union[str, "_models.EncryptionType"]] = None, encryption_properties: Optional["_models.EncryptionProperties"] = None, network_acls: Optional["_models.NetworkRuleSet"] = None, + enforce_data_integrity_check_for_iscsi: Optional[bool] = None, **kwargs: Any ) -> None: """ @@ -1912,6 +1899,9 @@ def __init__( :keyword network_acls: A collection of rules governing the accessibility from specific network locations. :paramtype network_acls: ~azure.mgmt.elasticsan.models.NetworkRuleSet + :keyword enforce_data_integrity_check_for_iscsi: A boolean indicating whether or not Data + Integrity Check is enabled. + :paramtype enforce_data_integrity_check_for_iscsi: bool """ super().__init__(**kwargs) self.provisioning_state = None @@ -1920,6 +1910,7 @@ def __init__( self.encryption_properties = encryption_properties self.network_acls = network_acls self.private_endpoint_connections = None + self.enforce_data_integrity_check_for_iscsi = enforce_data_integrity_check_for_iscsi class VolumeGroupUpdate(_serialization.Model): @@ -1968,6 +1959,9 @@ class VolumeGroupUpdateProperties(_serialization.Model): :ivar network_acls: A collection of rules governing the accessibility from specific network locations. :vartype network_acls: ~azure.mgmt.elasticsan.models.NetworkRuleSet + :ivar enforce_data_integrity_check_for_iscsi: A boolean indicating whether or not Data + Integrity Check is enabled. + :vartype enforce_data_integrity_check_for_iscsi: bool """ _attribute_map = { @@ -1975,6 +1969,7 @@ class VolumeGroupUpdateProperties(_serialization.Model): "encryption": {"key": "encryption", "type": "str"}, "encryption_properties": {"key": "encryptionProperties", "type": "EncryptionProperties"}, "network_acls": {"key": "networkAcls", "type": "NetworkRuleSet"}, + "enforce_data_integrity_check_for_iscsi": {"key": "enforceDataIntegrityCheckForIscsi", "type": "bool"}, } def __init__( @@ -1984,6 +1979,7 @@ def __init__( encryption: Optional[Union[str, "_models.EncryptionType"]] = None, encryption_properties: Optional["_models.EncryptionProperties"] = None, network_acls: Optional["_models.NetworkRuleSet"] = None, + enforce_data_integrity_check_for_iscsi: Optional[bool] = None, **kwargs: Any ) -> None: """ @@ -1998,12 +1994,16 @@ def __init__( :keyword network_acls: A collection of rules governing the accessibility from specific network locations. :paramtype network_acls: ~azure.mgmt.elasticsan.models.NetworkRuleSet + :keyword enforce_data_integrity_check_for_iscsi: A boolean indicating whether or not Data + Integrity Check is enabled. + :paramtype enforce_data_integrity_check_for_iscsi: bool """ super().__init__(**kwargs) self.protocol_type = protocol_type self.encryption = encryption self.encryption_properties = encryption_properties self.network_acls = network_acls + self.enforce_data_integrity_check_for_iscsi = enforce_data_integrity_check_for_iscsi class VolumeList(_serialization.Model): @@ -2041,7 +2041,7 @@ class VolumeProperties(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar volume_id: Unique Id of the volume in GUID format. :vartype volume_id: str diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_elastic_sans_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_elastic_sans_operations.py index 529c34fdc7ab..49f1c4e49fc2 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_elastic_sans_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_elastic_sans_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_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +72,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +104,7 @@ def build_create_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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -142,7 +147,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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -185,7 +190,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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -225,7 +230,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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -282,7 +287,6 @@ def __init__(self, *args, **kwargs): def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ElasticSan"]: """Gets a list of ElasticSans in a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ElasticSan or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.ElasticSan] :raises ~azure.core.exceptions.HttpResponseError: @@ -293,7 +297,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ElasticSan"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticSanList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -304,15 +308,13 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ElasticSan"]: def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -324,13 +326,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("ElasticSanList", pipeline_response) @@ -340,11 +341,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 @@ -357,10 +358,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.ElasticSan/elasticSans" - } - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ElasticSan"]: """Gets a list of ElasticSan in a resource group. @@ -368,7 +365,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ElasticSan or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.ElasticSan] :raises ~azure.core.exceptions.HttpResponseError: @@ -379,7 +375,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticSanList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -390,16 +386,14 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -411,13 +405,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("ElasticSanList", pipeline_response) @@ -427,11 +420,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 @@ -444,14 +437,14 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans" - } - def _create_initial( - self, resource_group_name: str, elastic_san_name: str, parameters: Union[_models.ElasticSan, IO], **kwargs: Any - ) -> _models.ElasticSan: - error_map = { + self, + resource_group_name: str, + elastic_san_name: str, + parameters: Union[_models.ElasticSan, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -464,7 +457,7 @@ def _create_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.ElasticSan] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -474,7 +467,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "ElasticSan") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, subscription_id=self._config.subscription_id, @@ -482,40 +475,35 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _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("ElasticSan", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ElasticSan", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}" - } - @overload def begin_create( self, @@ -538,14 +526,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either ElasticSan or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] :raises ~azure.core.exceptions.HttpResponseError: @@ -556,7 +536,7 @@ def begin_create( self, resource_group_name: str, elastic_san_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -569,18 +549,10 @@ def begin_create( :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_name: str :param parameters: Elastic San object. 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 ElasticSan or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] :raises ~azure.core.exceptions.HttpResponseError: @@ -588,7 +560,11 @@ def begin_create( @distributed_trace def begin_create( - self, resource_group_name: str, elastic_san_name: str, parameters: Union[_models.ElasticSan, IO], **kwargs: Any + self, + resource_group_name: str, + elastic_san_name: str, + parameters: Union[_models.ElasticSan, IO[bytes]], + **kwargs: Any ) -> LROPoller[_models.ElasticSan]: """Create ElasticSan. @@ -597,19 +573,9 @@ def begin_create( :type resource_group_name: str :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_name: str - :param parameters: Elastic San object. Is either a ElasticSan type or a IO type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.ElasticSan or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Elastic San object. Is either a ElasticSan type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.elasticsan.models.ElasticSan or IO[bytes] :return: An instance of LROPoller that returns either ElasticSan or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] :raises ~azure.core.exceptions.HttpResponseError: @@ -635,12 +601,13 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ElasticSan", pipeline_response) + deserialized = self._deserialize("ElasticSan", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -652,26 +619,24 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ElasticSan].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}" - } + return LROPoller[_models.ElasticSan]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, elastic_san_name: str, - parameters: Union[_models.ElasticSanUpdate, IO], + parameters: Union[_models.ElasticSanUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ElasticSan]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -684,7 +649,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ElasticSan]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -694,7 +659,7 @@ def _update_initial( else: _json = self._serialize.body(parameters, "ElasticSanUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, subscription_id=self._config.subscription_id, @@ -702,41 +667,38 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ElasticSan", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -760,14 +722,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 ElasticSan or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] :raises ~azure.core.exceptions.HttpResponseError: @@ -778,7 +732,7 @@ def begin_update( self, resource_group_name: str, elastic_san_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -791,18 +745,10 @@ def begin_update( :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_name: str :param parameters: Elastic San object. 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 ElasticSan or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] :raises ~azure.core.exceptions.HttpResponseError: @@ -813,7 +759,7 @@ def begin_update( self, resource_group_name: str, elastic_san_name: str, - parameters: Union[_models.ElasticSanUpdate, IO], + parameters: Union[_models.ElasticSanUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ElasticSan]: """Update a Elastic San. @@ -823,20 +769,9 @@ def begin_update( :type resource_group_name: str :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_name: str - :param parameters: Elastic San object. Is either a ElasticSanUpdate type or a IO type. + :param parameters: Elastic San object. Is either a ElasticSanUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.ElasticSanUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :type parameters: ~azure.mgmt.elasticsan.models.ElasticSanUpdate or IO[bytes] :return: An instance of LROPoller that returns either ElasticSan or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.ElasticSan] :raises ~azure.core.exceptions.HttpResponseError: @@ -862,12 +797,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("ElasticSan", pipeline_response) + deserialized = self._deserialize("ElasticSan", 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,22 +815,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ElasticSan].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.ElasticSan/elasticSans/{elasticSanName}" - } + return LROPoller[_models.ElasticSan]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, elastic_san_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, elastic_san_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -906,28 +838,31 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -936,12 +871,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, elastic_san_name: str, **kwargs: Any) -> LROPoller[None]: @@ -952,14 +887,6 @@ def begin_delete(self, resource_group_name: str, elastic_san_name: str, **kwargs :type resource_group_name: str :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_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: @@ -973,7 +900,7 @@ def begin_delete(self, resource_group_name: str, elastic_san_name: str, **kwargs lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, api_version=api_version, @@ -982,11 +909,12 @@ def begin_delete(self, resource_group_name: str, elastic_san_name: str, **kwargs params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -997,17 +925,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.ElasticSan/elasticSans/{elasticSanName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get(self, resource_group_name: str, elastic_san_name: str, **kwargs: Any) -> _models.ElasticSan: @@ -1018,12 +942,11 @@ def get(self, resource_group_name: str, elastic_san_name: str, **kwargs: Any) -> :type resource_group_name: str :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ElasticSan or the result of cls(response) :rtype: ~azure.mgmt.elasticsan.models.ElasticSan :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1037,21 +960,19 @@ def get(self, resource_group_name: str, elastic_san_name: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ElasticSan] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1061,13 +982,9 @@ def get(self, resource_group_name: str, elastic_san_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("ElasticSan", pipeline_response) + deserialized = self._deserialize("ElasticSan", 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.ElasticSan/elasticSans/{elasticSanName}" - } + return deserialized # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_operations.py index 5fa56ca8ae10..5240ae809f82 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) 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"]: """Gets a list of ElasticSan 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.elasticsan.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 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.ElasticSan/operations"} diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_private_endpoint_connections_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_private_endpoint_connections_operations.py index 2c376baede6a..d24e71a76cd5 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_private_endpoint_connections_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +54,7 @@ def build_create_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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -99,7 +104,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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -146,7 +151,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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -189,7 +194,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -247,10 +252,10 @@ def _create_initial( resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -263,7 +268,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -273,7 +278,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "PrivateEndpointConnection") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -282,40 +287,35 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - @overload def begin_create( self, @@ -341,14 +341,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] @@ -361,7 +353,7 @@ def begin_create( resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -376,18 +368,10 @@ def begin_create( :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. :type private_endpoint_connection_name: str :param parameters: Private Endpoint Connection Approval object. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] @@ -400,7 +384,7 @@ def begin_create( resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the Elastic San. @@ -413,19 +397,8 @@ def begin_create( :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. :type private_endpoint_connection_name: str :param parameters: Private Endpoint Connection Approval object. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection or IO[bytes] :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] @@ -453,12 +426,13 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -470,17 +444,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def get( @@ -495,12 +467,11 @@ def get( :type elastic_san_name: str :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.elasticsan.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -514,22 +485,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -539,21 +508,17 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, elastic_san_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -565,29 +530,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -596,12 +564,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -616,14 +584,6 @@ def begin_delete( :type elastic_san_name: str :param private_endpoint_connection_name: The name of the Private Endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -637,7 +597,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -647,11 +607,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( @@ -662,17 +623,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.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list( @@ -685,7 +642,6 @@ def list( :type resource_group_name: str :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.PrivateEndpointConnection] @@ -697,7 +653,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -708,17 +664,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -730,13 +684,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -746,11 +699,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -762,7 +715,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateEndpointConnections" - } diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_private_link_resources_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_private_link_resources_operations.py index f6cf2331754c..76f0ac43a0c3 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_private_link_resources_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_by_elastic_san_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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -104,12 +107,11 @@ def list_by_elastic_san( :type resource_group_name: str :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.elasticsan.models.PrivateLinkResourceListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -123,21 +125,19 @@ def list_by_elastic_san( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - request = build_list_by_elastic_san_request( + _request = build_list_by_elastic_san_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_elastic_san.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -147,13 +147,9 @@ def list_by_elastic_san( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_by_elastic_san.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/privateLinkResources" - } + return deserialized # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_skus_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_skus_operations.py index 2c17b5a11e09..e95063b652d0 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_skus_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_skus_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_request(subscription_id: str, *, filter: Optional[str] = None, ** _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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -90,7 +93,6 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models :param filter: Specify $filter='location eq :code:``' to filter on location. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.SkuInformation] :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +103,7 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SkuInformationList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,16 +114,14 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # 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("SkuInformationList", pipeline_response) @@ -149,11 +148,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -165,5 +164,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ElasticSan/skus"} diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volume_groups_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volume_groups_operations.py index bbe1ec449da1..f596a1e96811 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volume_groups_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volume_groups_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_list_by_elastic_san_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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -85,7 +90,7 @@ def build_create_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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -136,7 +141,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -187,7 +192,7 @@ def build_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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -235,7 +240,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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -307,7 +312,6 @@ def list_by_elastic_san( :type resource_group_name: str :param elastic_san_name: The name of the ElasticSan. Required. :type elastic_san_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VolumeGroup or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.VolumeGroup] :raises ~azure.core.exceptions.HttpResponseError: @@ -318,7 +322,7 @@ def list_by_elastic_san( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VolumeGroupList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -329,17 +333,15 @@ def list_by_elastic_san( def prepare_request(next_link=None): if not next_link: - request = build_list_by_elastic_san_request( + _request = build_list_by_elastic_san_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_elastic_san.metadata["url"], 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 @@ -351,13 +353,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("VolumeGroupList", pipeline_response) @@ -367,11 +368,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 @@ -384,19 +385,15 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_elastic_san.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumeGroups" - } - def _create_initial( self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, - parameters: Union[_models.VolumeGroup, IO], + parameters: Union[_models.VolumeGroup, IO[bytes]], **kwargs: Any - ) -> _models.VolumeGroup: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -409,7 +406,7 @@ def _create_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.VolumeGroup] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -419,7 +416,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "VolumeGroup") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -428,40 +425,35 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _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("VolumeGroup", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("VolumeGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" - } - @overload def begin_create( self, @@ -487,14 +479,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either VolumeGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] @@ -507,7 +491,7 @@ def begin_create( resource_group_name: str, elastic_san_name: str, volume_group_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -522,18 +506,10 @@ def begin_create( :param volume_group_name: The name of the VolumeGroup. Required. :type volume_group_name: str :param parameters: Volume Group object. 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 VolumeGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] @@ -546,7 +522,7 @@ def begin_create( resource_group_name: str, elastic_san_name: str, volume_group_name: str, - parameters: Union[_models.VolumeGroup, IO], + parameters: Union[_models.VolumeGroup, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VolumeGroup]: """Create a Volume Group. @@ -558,19 +534,9 @@ def begin_create( :type elastic_san_name: str :param volume_group_name: The name of the VolumeGroup. Required. :type volume_group_name: str - :param parameters: Volume Group object. Is either a VolumeGroup type or a IO type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroup or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Volume Group object. Is either a VolumeGroup type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroup or IO[bytes] :return: An instance of LROPoller that returns either VolumeGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] @@ -598,12 +564,13 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VolumeGroup", pipeline_response) + deserialized = self._deserialize("VolumeGroup", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -615,27 +582,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VolumeGroup].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" - } + return LROPoller[_models.VolumeGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, - parameters: Union[_models.VolumeGroupUpdate, IO], + parameters: Union[_models.VolumeGroupUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.VolumeGroup]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -648,7 +613,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.VolumeGroup]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -658,7 +623,7 @@ def _update_initial( else: _json = self._serialize.body(parameters, "VolumeGroupUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -667,41 +632,38 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("VolumeGroup", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -728,14 +690,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 VolumeGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] @@ -748,7 +702,7 @@ def begin_update( resource_group_name: str, elastic_san_name: str, volume_group_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -763,18 +717,10 @@ def begin_update( :param volume_group_name: The name of the VolumeGroup. Required. :type volume_group_name: str :param parameters: Volume Group object. 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 VolumeGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] @@ -787,7 +733,7 @@ def begin_update( resource_group_name: str, elastic_san_name: str, volume_group_name: str, - parameters: Union[_models.VolumeGroupUpdate, IO], + parameters: Union[_models.VolumeGroupUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VolumeGroup]: """Update an VolumeGroup. @@ -799,20 +745,9 @@ def begin_update( :type elastic_san_name: str :param volume_group_name: The name of the VolumeGroup. Required. :type volume_group_name: str - :param parameters: Volume Group object. Is either a VolumeGroupUpdate type or a IO type. + :param parameters: Volume Group object. Is either a VolumeGroupUpdate type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroupUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeGroupUpdate or IO[bytes] :return: An instance of LROPoller that returns either VolumeGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.VolumeGroup] @@ -840,12 +775,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("VolumeGroup", pipeline_response) + deserialized = self._deserialize("VolumeGroup", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -857,22 +793,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VolumeGroup].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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" - } + return LROPoller[_models.VolumeGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -884,29 +818,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _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) @@ -915,12 +852,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -935,14 +872,6 @@ def begin_delete( :type elastic_san_name: str :param volume_group_name: The name of the VolumeGroup. Required. :type volume_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -956,7 +885,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -966,11 +895,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( @@ -981,17 +911,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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get( @@ -1006,12 +932,11 @@ def get( :type elastic_san_name: str :param volume_group_name: The name of the VolumeGroup. Required. :type volume_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VolumeGroup or the result of cls(response) :rtype: ~azure.mgmt.elasticsan.models.VolumeGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1025,22 +950,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VolumeGroup] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1050,13 +973,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("VolumeGroup", pipeline_response) + deserialized = self._deserialize("VolumeGroup", 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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}" - } + return deserialized # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volume_snapshots_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volume_snapshots_operations.py index 274ce77c64c4..3bf4c8750b5b 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volume_snapshots_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volume_snapshots_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]] @@ -51,7 +56,7 @@ def build_list_by_volume_group_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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,7 +111,7 @@ def build_create_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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -170,7 +175,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -231,7 +236,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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -322,7 +327,6 @@ def list_by_volume_group( :param filter: Specify $filter='volumeName eq :code:``' to filter on volume. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Snapshot or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: @@ -333,7 +337,7 @@ def list_by_volume_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SnapshotList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -344,19 +348,17 @@ def list_by_volume_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_volume_group_request( + _request = build_list_by_volume_group_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_volume_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -368,13 +370,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("SnapshotList", pipeline_response) @@ -384,11 +385,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 @@ -401,20 +402,16 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_volume_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots" - } - def _create_initial( self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, snapshot_name: str, - parameters: Union[_models.Snapshot, IO], + parameters: Union[_models.Snapshot, IO[bytes]], **kwargs: Any - ) -> _models.Snapshot: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -427,7 +424,7 @@ def _create_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.Snapshot] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -437,7 +434,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "Snapshot") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -447,40 +444,35 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _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("Snapshot", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Snapshot", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots/{snapshotName}" - } - @overload def begin_create( self, @@ -509,14 +501,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: @@ -529,7 +513,7 @@ def begin_create( elastic_san_name: str, volume_group_name: str, snapshot_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -546,18 +530,10 @@ def begin_create( :param snapshot_name: The name of the volume snapshot within the given volume group. Required. :type snapshot_name: str :param parameters: Snapshot object. 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 Snapshot or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: @@ -570,7 +546,7 @@ def begin_create( elastic_san_name: str, volume_group_name: str, snapshot_name: str, - parameters: Union[_models.Snapshot, IO], + parameters: Union[_models.Snapshot, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Snapshot]: """Create a Volume Snapshot. @@ -584,19 +560,8 @@ def begin_create( :type volume_group_name: str :param snapshot_name: The name of the volume snapshot within the given volume group. Required. :type snapshot_name: str - :param parameters: Snapshot object. Is either a Snapshot type or a IO type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.Snapshot or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Snapshot object. Is either a Snapshot type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.elasticsan.models.Snapshot or IO[bytes] :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: @@ -624,12 +589,13 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Snapshot", pipeline_response) + deserialized = self._deserialize("Snapshot", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -641,22 +607,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Snapshot].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots/{snapshotName}" - } + return LROPoller[_models.Snapshot]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, elastic_san_name: str, volume_group_name: str, snapshot_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -668,30 +632,33 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -700,12 +667,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots/{snapshotName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -722,14 +689,6 @@ def begin_delete( :type volume_group_name: str :param snapshot_name: The name of the volume snapshot within the given volume group. Required. :type snapshot_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: @@ -743,7 +702,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -754,11 +713,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( @@ -769,17 +729,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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots/{snapshotName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get( @@ -796,12 +752,11 @@ def get( :type volume_group_name: str :param snapshot_name: The name of the volume snapshot within the given volume group. Required. :type snapshot_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Snapshot or the result of cls(response) :rtype: ~azure.mgmt.elasticsan.models.Snapshot :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -815,23 +770,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -841,13 +794,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Snapshot", pipeline_response) + deserialized = self._deserialize("Snapshot", 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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/snapshots/{snapshotName}" - } + return deserialized # type: ignore diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volumes_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volumes_operations.py index 53b4813333d4..1248014a59ae 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volumes_operations.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/azure/mgmt/elasticsan/operations/_volumes_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]] @@ -50,7 +55,7 @@ def build_create_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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -109,7 +114,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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -171,7 +176,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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -231,7 +236,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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -282,7 +287,7 @@ def build_list_by_volume_group_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-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -349,10 +354,10 @@ def _create_initial( elastic_san_name: str, volume_group_name: str, volume_name: str, - parameters: Union[_models.Volume, IO], + parameters: Union[_models.Volume, IO[bytes]], **kwargs: Any - ) -> _models.Volume: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -365,7 +370,7 @@ def _create_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.Volume] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -375,7 +380,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "Volume") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -385,40 +390,35 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _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("Volume", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Volume", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" - } - @overload def begin_create( self, @@ -447,14 +447,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] :raises ~azure.core.exceptions.HttpResponseError: @@ -467,7 +459,7 @@ def begin_create( elastic_san_name: str, volume_group_name: str, volume_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -484,18 +476,10 @@ def begin_create( :param volume_name: The name of the Volume. Required. :type volume_name: str :param parameters: Volume object. 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 Volume or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] :raises ~azure.core.exceptions.HttpResponseError: @@ -508,7 +492,7 @@ def begin_create( elastic_san_name: str, volume_group_name: str, volume_name: str, - parameters: Union[_models.Volume, IO], + parameters: Union[_models.Volume, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Volume]: """Create a Volume. @@ -522,19 +506,8 @@ def begin_create( :type volume_group_name: str :param volume_name: The name of the Volume. Required. :type volume_name: str - :param parameters: Volume object. Is either a Volume type or a IO type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.Volume or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Volume object. Is either a Volume type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.elasticsan.models.Volume or IO[bytes] :return: An instance of LROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] :raises ~azure.core.exceptions.HttpResponseError: @@ -562,12 +535,13 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Volume", pipeline_response) + deserialized = self._deserialize("Volume", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -579,17 +553,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Volume].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" - } + return LROPoller[_models.Volume]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, @@ -597,10 +569,10 @@ def _update_initial( elastic_san_name: str, volume_group_name: str, volume_name: str, - parameters: Union[_models.VolumeUpdate, IO], + parameters: Union[_models.VolumeUpdate, IO[bytes]], **kwargs: Any - ) -> Optional[_models.Volume]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -613,7 +585,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.Volume]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -623,7 +595,7 @@ def _update_initial( else: _json = self._serialize.body(parameters, "VolumeUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -633,41 +605,38 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Volume", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -697,14 +666,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 Volume or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] :raises ~azure.core.exceptions.HttpResponseError: @@ -717,7 +678,7 @@ def begin_update( elastic_san_name: str, volume_group_name: str, volume_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -734,18 +695,10 @@ def begin_update( :param volume_name: The name of the Volume. Required. :type volume_name: str :param parameters: Volume object. 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 Volume or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] :raises ~azure.core.exceptions.HttpResponseError: @@ -758,7 +711,7 @@ def begin_update( elastic_san_name: str, volume_group_name: str, volume_name: str, - parameters: Union[_models.VolumeUpdate, IO], + parameters: Union[_models.VolumeUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Volume]: """Update an Volume. @@ -772,19 +725,8 @@ def begin_update( :type volume_group_name: str :param volume_name: The name of the Volume. Required. :type volume_name: str - :param parameters: Volume object. Is either a VolumeUpdate type or a IO type. Required. - :type parameters: ~azure.mgmt.elasticsan.models.VolumeUpdate or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Volume object. Is either a VolumeUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.elasticsan.models.VolumeUpdate or IO[bytes] :return: An instance of LROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.elasticsan.models.Volume] :raises ~azure.core.exceptions.HttpResponseError: @@ -812,12 +754,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("Volume", pipeline_response) + deserialized = self._deserialize("Volume", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -829,19 +772,17 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Volume].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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" - } + return LROPoller[_models.Volume]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, elastic_san_name: str, @@ -850,8 +791,8 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements x_ms_delete_snapshots: Optional[Union[str, _models.XMsDeleteSnapshots]] = None, x_ms_force_delete: Optional[Union[str, _models.XMsForceDelete]] = None, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -863,9 +804,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -874,21 +815,24 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements x_ms_delete_snapshots=x_ms_delete_snapshots, x_ms_force_delete=x_ms_force_delete, 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) @@ -897,12 +841,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -934,14 +878,6 @@ def begin_delete( value are only true or false. Default value is false. Known values are: "true" and "false". Default value is None. :type x_ms_force_delete: str or ~azure.mgmt.elasticsan.models.XMsForceDelete - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: 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: @@ -955,7 +891,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, @@ -968,11 +904,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( @@ -983,17 +920,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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get( @@ -1010,12 +943,11 @@ def get( :type volume_group_name: str :param volume_name: The name of the Volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Volume or the result of cls(response) :rtype: ~azure.mgmt.elasticsan.models.Volume :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1029,23 +961,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Volume] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1055,16 +985,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Volume", pipeline_response) + deserialized = self._deserialize("Volume", 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.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}" - } + return deserialized # type: ignore @distributed_trace def list_by_volume_group( @@ -1079,7 +1005,6 @@ def list_by_volume_group( :type elastic_san_name: str :param volume_group_name: The name of the VolumeGroup. Required. :type volume_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Volume or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.elasticsan.models.Volume] :raises ~azure.core.exceptions.HttpResponseError: @@ -1090,7 +1015,7 @@ def list_by_volume_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VolumeList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1101,18 +1026,16 @@ def list_by_volume_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_volume_group_request( + _request = build_list_by_volume_group_request( resource_group_name=resource_group_name, elastic_san_name=elastic_san_name, volume_group_name=volume_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_volume_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1124,13 +1047,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("VolumeList", pipeline_response) @@ -1140,11 +1062,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 @@ -1156,7 +1078,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_volume_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes" - } diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/dev_requirements.txt b/sdk/elasticsan/azure-mgmt-elasticsan/dev_requirements.txt index 69e7fdd3cc96..181b6632ed60 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/dev_requirements.txt +++ b/sdk/elasticsan/azure-mgmt-elasticsan/dev_requirements.txt @@ -1,2 +1,3 @@ -e ../../../tools/azure-sdk-tools -../../identity/azure-identity \ No newline at end of file +../../identity/azure-identity +aiohttp \ No newline at end of file diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_create_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_create_maximum_set_gen.py index c82eeedbd37e..7a0936a2ddf6 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_create_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_create_maximum_set_gen.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -47,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/ElasticSans_Create_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/ElasticSans_Create_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_create_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_create_minimum_set_gen.py index 871ac1b310a5..8e3a205a7011 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_create_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_create_minimum_set_gen.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -40,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/ElasticSans_Create_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/ElasticSans_Create_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_delete_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_delete_maximum_set_gen.py index ca40686e1482..b34f7790a1e6 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_delete_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_delete_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/ElasticSans_Delete_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/ElasticSans_Delete_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_delete_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_delete_minimum_set_gen.py index 1a3aa1e20535..e8a98fe9d98a 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_delete_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_delete_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/ElasticSans_Delete_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/ElasticSans_Delete_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_get_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_get_maximum_set_gen.py index 33d5b3601ffa..8069c396eef5 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_get_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_get_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/ElasticSans_Get_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/ElasticSans_Get_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_get_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_get_minimum_set_gen.py index ec9d4d13f923..f8b04747d756 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_get_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_get_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/ElasticSans_Get_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/ElasticSans_Get_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_resource_group_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_resource_group_maximum_set_gen.py index 300402c869ad..dd4bfa259712 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_resource_group_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_resource_group_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/ElasticSans_ListByResourceGroup_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/ElasticSans_ListByResourceGroup_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_resource_group_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_resource_group_minimum_set_gen.py index 5c2d9c99d441..e6c94a4c78f3 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_resource_group_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_resource_group_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/ElasticSans_ListByResourceGroup_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/ElasticSans_ListByResourceGroup_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_subscription_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_subscription_maximum_set_gen.py index 0b6cebee9bd2..7ed08944d138 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_subscription_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_subscription_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/ElasticSans_ListBySubscription_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/ElasticSans_ListBySubscription_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_subscription_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_subscription_minimum_set_gen.py index 0f38f9c7580e..a08195de4f76 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_subscription_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_list_by_subscription_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/ElasticSans_ListBySubscription_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/ElasticSans_ListBySubscription_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_update_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_update_maximum_set_gen.py index 7aa0697b3dee..3dc50d6f5aa4 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_update_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/elastic_sans_update_maximum_set_gen.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -40,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/ElasticSans_Update_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/ElasticSans_Update_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/operations_list_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/operations_list_maximum_set_gen.py index 4ff25ef71abf..8eb9d40822df 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/operations_list_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/operations_list_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/Operations_List_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/Operations_List_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/operations_list_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/operations_list_minimum_set_gen.py index dd171e31ec43..748d80c49e50 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/operations_list_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/operations_list_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/Operations_List_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/Operations_List_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_create_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_create_maximum_set_gen.py index c8dbbe8d8756..4e2d2db785cf 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_create_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_create_maximum_set_gen.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -48,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/PrivateEndpointConnections_Create_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/PrivateEndpointConnections_Create_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_create_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_create_minimum_set_gen.py index 42f1941ce22a..f3fbb12a06ae 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_create_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_create_minimum_set_gen.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/PrivateEndpointConnections_Create_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/PrivateEndpointConnections_Create_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_delete_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_delete_maximum_set_gen.py index 27d41e6c54e8..d34ae2718520 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_delete_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_delete_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/PrivateEndpointConnections_Delete_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/PrivateEndpointConnections_Delete_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_delete_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_delete_minimum_set_gen.py index 275767d0629f..82ecfd929a91 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_delete_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_delete_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/PrivateEndpointConnections_Delete_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/PrivateEndpointConnections_Delete_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_get_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_get_maximum_set_gen.py index e186b7e27e64..cbc30f9f82be 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_get_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_get_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/PrivateEndpointConnections_Get_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/PrivateEndpointConnections_Get_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_get_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_get_minimum_set_gen.py index 3dce6258a6ea..86ab80cd2111 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_get_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_get_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/PrivateEndpointConnections_Get_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/PrivateEndpointConnections_Get_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_list_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_list_maximum_set_gen.py index 8b48ff24577b..29b4a9cffa4e 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_list_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_list_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/PrivateEndpointConnections_List_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/PrivateEndpointConnections_List_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_list_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_list_minimum_set_gen.py index c029e6d263e9..bb8d17cdfe76 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_list_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_endpoint_connections_list_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/PrivateEndpointConnections_List_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/PrivateEndpointConnections_List_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_link_resources_list_by_elastic_san_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_link_resources_list_by_elastic_san_maximum_set_gen.py index 9289d3a5733e..75cb7fb932b6 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_link_resources_list_by_elastic_san_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_link_resources_list_by_elastic_san_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/PrivateLinkResources_ListByElasticSan_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/PrivateLinkResources_ListByElasticSan_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_link_resources_list_by_elastic_san_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_link_resources_list_by_elastic_san_minimum_set_gen.py index 44dd080b2f30..f49a99b6b163 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_link_resources_list_by_elastic_san_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/private_link_resources_list_by_elastic_san_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/PrivateLinkResources_ListByElasticSan_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/PrivateLinkResources_ListByElasticSan_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/skus_list_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/skus_list_maximum_set_gen.py index 77a9cf9f0b58..d032e7a92a6b 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/skus_list_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/skus_list_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/Skus_List_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/Skus_List_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/skus_list_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/skus_list_minimum_set_gen.py index 386e2d607796..711cd1fbb8b6 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/skus_list_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/skus_list_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/Skus_List_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/Skus_List_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_create_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_create_maximum_set_gen.py index e5763f5edbd9..d50c1b1e3ea4 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_create_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_create_maximum_set_gen.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -34,25 +37,19 @@ def main(): elastic_san_name="elasticsanname", volume_group_name="volumegroupname", parameters={ - "identity": {"type": "None", "userAssignedIdentities": {"key7482": {}}}, + "identity": {"type": "None", "userAssignedIdentities": {"key1006": {}}}, "properties": { - "encryption": "EncryptionAtRestWithCustomerManagedKey", + "encryption": "EncryptionAtRestWithPlatformKey", "encryptionProperties": { - "identity": {"userAssignedIdentity": "im"}, + "identity": {"userAssignedIdentity": "gfhkfbozahmmwluqndfgxunssafa"}, "keyVaultProperties": { - "keyName": "sftaiernmrzypnrkpakrrawxcbsqzc", - "keyVaultUri": "https://microsoft.com/axmblwp", - "keyVersion": "c", + "keyName": "lunpapamzeimppgobraxjt", + "keyVaultUri": "https://microsoft.com/a", + "keyVersion": "oemygbnfmqhijmonkqfqmy", }, }, - "networkAcls": { - "virtualNetworkRules": [ - { - "action": "Allow", - "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}", - } - ] - }, + "enforceDataIntegrityCheckForIscsi": True, + "networkAcls": {"virtualNetworkRules": [{"action": "Allow", "id": "bkhwaiqvvaguymsmnzzbzz"}]}, "protocolType": "Iscsi", }, }, @@ -60,6 +57,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/VolumeGroups_Create_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/VolumeGroups_Create_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_delete_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_delete_maximum_set_gen.py index 4242f602325e..cdc56fe84495 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_delete_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_delete_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/VolumeGroups_Delete_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/VolumeGroups_Delete_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_delete_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_delete_minimum_set_gen.py index 738117e06f40..fab60897e2b3 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_delete_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_delete_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/VolumeGroups_Delete_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/VolumeGroups_Delete_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_get_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_get_maximum_set_gen.py index 6f71dbf72588..9fb28756525d 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_get_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_get_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/VolumeGroups_Get_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/VolumeGroups_Get_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_get_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_get_minimum_set_gen.py index be792a84af47..b931a0ef4215 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_get_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_get_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/VolumeGroups_Get_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/VolumeGroups_Get_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_list_by_elastic_san_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_list_by_elastic_san_maximum_set_gen.py index f772ccef2c45..8b03cef55626 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_list_by_elastic_san_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_list_by_elastic_san_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/VolumeGroups_ListByElasticSan_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/VolumeGroups_ListByElasticSan_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_list_by_elastic_san_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_list_by_elastic_san_minimum_set_gen.py index 6c8ac293834f..c731bdd7c7cc 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_list_by_elastic_san_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_list_by_elastic_san_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/VolumeGroups_ListByElasticSan_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/VolumeGroups_ListByElasticSan_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_update_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_update_maximum_set_gen.py index 890d1952ed03..d4f5324ee07a 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_update_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_groups_update_maximum_set_gen.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -34,25 +37,19 @@ def main(): elastic_san_name="elasticsanname", volume_group_name="volumegroupname", parameters={ - "identity": {"type": "None", "userAssignedIdentities": {"key7482": {}}}, + "identity": {"type": "None", "userAssignedIdentities": {"key1006": {}}}, "properties": { "encryption": "EncryptionAtRestWithPlatformKey", "encryptionProperties": { - "identity": {"userAssignedIdentity": "im"}, + "identity": {"userAssignedIdentity": "gfhkfbozahmmwluqndfgxunssafa"}, "keyVaultProperties": { - "keyName": "sftaiernmrzypnrkpakrrawxcbsqzc", - "keyVaultUri": "https://microsoft.com/axmblwp", - "keyVersion": "c", + "keyName": "lunpapamzeimppgobraxjt", + "keyVaultUri": "https://microsoft.com/a", + "keyVersion": "oemygbnfmqhijmonkqfqmy", }, }, - "networkAcls": { - "virtualNetworkRules": [ - { - "action": "Allow", - "id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}", - } - ] - }, + "enforceDataIntegrityCheckForIscsi": True, + "networkAcls": {"virtualNetworkRules": [{"action": "Allow", "id": "bkhwaiqvvaguymsmnzzbzz"}]}, "protocolType": "Iscsi", }, }, @@ -60,6 +57,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/VolumeGroups_Update_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/VolumeGroups_Update_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_create_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_create_maximum_set_gen.py index a4063914fb0e..d24d20a5c226 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_create_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_create_maximum_set_gen.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -45,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/VolumeSnapshots_Create_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/VolumeSnapshots_Create_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_create_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_create_minimum_set_gen.py index 4b5543a963ce..184d573ca48c 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_create_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_create_minimum_set_gen.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -45,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/VolumeSnapshots_Create_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/VolumeSnapshots_Create_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_delete_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_delete_maximum_set_gen.py index 205e2feaede7..3c1e13dfed57 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_delete_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_delete_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/VolumeSnapshots_Delete_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/VolumeSnapshots_Delete_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_delete_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_delete_minimum_set_gen.py index 80a18ee83b44..05eb662dedf5 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_delete_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_delete_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/VolumeSnapshots_Delete_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/VolumeSnapshots_Delete_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_get_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_get_maximum_set_gen.py index 6caf772f0ff5..092d395c80b8 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_get_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_get_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/VolumeSnapshots_Get_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/VolumeSnapshots_Get_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_get_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_get_minimum_set_gen.py index 150ce46347bb..e9502fe742fe 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_get_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_get_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/VolumeSnapshots_Get_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/VolumeSnapshots_Get_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_list_by_volume_group_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_list_by_volume_group_maximum_set_gen.py index e4014efd11f4..e4802021cae2 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_list_by_volume_group_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_list_by_volume_group_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/VolumeSnapshots_ListByVolumeGroup_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/VolumeSnapshots_ListByVolumeGroup_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_list_by_volume_group_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_list_by_volume_group_minimum_set_gen.py index 96abc463aac9..e5771fc4f13e 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_list_by_volume_group_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volume_snapshots_list_by_volume_group_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/VolumeSnapshots_ListByVolumeGroup_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/VolumeSnapshots_ListByVolumeGroup_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_create_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_create_maximum_set_gen.py index 3aa5bf969a97..1f7013e6dcc5 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_create_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_create_maximum_set_gen.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -45,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/Volumes_Create_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/Volumes_Create_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_create_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_create_minimum_set_gen.py index c46304ec6991..5250e6b4fcce 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_create_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_create_minimum_set_gen.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -39,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/Volumes_Create_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/Volumes_Create_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_delete_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_delete_maximum_set_gen.py index f24374dae334..3ce765f657c5 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_delete_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_delete_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/Volumes_Delete_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/Volumes_Delete_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_delete_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_delete_minimum_set_gen.py index c7031464292e..fed8caecfd7f 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_delete_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_delete_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/Volumes_Delete_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/Volumes_Delete_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_get_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_get_maximum_set_gen.py index 4ecad17bfdcf..4c7a526186be 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_get_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_get_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/Volumes_Get_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/Volumes_Get_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_get_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_get_minimum_set_gen.py index 8ea341a3fb29..dc991ca70727 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_get_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_get_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/Volumes_Get_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/Volumes_Get_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_list_by_volume_group_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_list_by_volume_group_maximum_set_gen.py index 5aa804bbb093..827c6d549ee4 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_list_by_volume_group_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_list_by_volume_group_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/Volumes_ListByVolumeGroup_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/Volumes_ListByVolumeGroup_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_list_by_volume_group_minimum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_list_by_volume_group_minimum_set_gen.py index d9c194fcb167..1d9975ca8ab6 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_list_by_volume_group_minimum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_list_by_volume_group_minimum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/Volumes_ListByVolumeGroup_MinimumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/Volumes_ListByVolumeGroup_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_update_maximum_set_gen.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_update_maximum_set_gen.py index eaeba94bd11d..1dae1140f49d 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_update_maximum_set_gen.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_samples/volumes_update_maximum_set_gen.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.elasticsan import ElasticSanMgmtClient """ @@ -39,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2023-01-01/examples/Volumes_Update_MaximumSet_Gen.json +# x-ms-original-file: specification/elasticsan/resource-manager/Microsoft.ElasticSan/stable/2024-05-01/examples/Volumes_Update_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/conftest.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/conftest.py new file mode 100644 index 000000000000..7ec9aeefd918 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + elasticsanmgmt_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + elasticsanmgmt_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + elasticsanmgmt_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + elasticsanmgmt_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=elasticsanmgmt_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=elasticsanmgmt_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=elasticsanmgmt_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=elasticsanmgmt_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/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_elastic_sans_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_elastic_sans_operations.py new file mode 100644 index 000000000000..75ff1a07b020 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_elastic_sans_operations.py @@ -0,0 +1,145 @@ +# 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.elasticsan import ElasticSanMgmtClient + +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 TestElasticSanMgmtElasticSansOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_subscription(self, resource_group): + response = self.client.elastic_sans.list_by_subscription( + api_version="2024-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.elastic_sans.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.elastic_sans.begin_create( + resource_group_name=resource_group.name, + elastic_san_name="str", + parameters={ + "location": "str", + "properties": { + "baseSizeTiB": 0, + "extendedCapacitySizeTiB": 0, + "sku": {"name": "str", "tier": "str"}, + "availabilityZones": ["str"], + "privateEndpointConnections": [ + { + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", + }, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "str", + "totalIops": 0, + "totalMBps": 0, + "totalSizeTiB": 0, + "totalVolumeSizeGiB": 0, + "volumeGroupCount": 0, + }, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.elastic_sans.begin_update( + resource_group_name=resource_group.name, + elastic_san_name="str", + parameters={ + "properties": {"baseSizeTiB": 0, "extendedCapacitySizeTiB": 0, "publicNetworkAccess": "str"}, + "tags": {"str": "str"}, + }, + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.elastic_sans.begin_delete( + resource_group_name=resource_group.name, + elastic_san_name="str", + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.elastic_sans.get( + resource_group_name=resource_group.name, + elastic_san_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_elastic_sans_operations_async.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_elastic_sans_operations_async.py new file mode 100644 index 000000000000..409d4e210652 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_elastic_sans_operations_async.py @@ -0,0 +1,152 @@ +# 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.elasticsan.aio import ElasticSanMgmtClient + +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 TestElasticSanMgmtElasticSansOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_subscription(self, resource_group): + response = self.client.elastic_sans.list_by_subscription( + api_version="2024-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.elastic_sans.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.elastic_sans.begin_create( + resource_group_name=resource_group.name, + elastic_san_name="str", + parameters={ + "location": "str", + "properties": { + "baseSizeTiB": 0, + "extendedCapacitySizeTiB": 0, + "sku": {"name": "str", "tier": "str"}, + "availabilityZones": ["str"], + "privateEndpointConnections": [ + { + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", + }, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "str", + "totalIops": 0, + "totalMBps": 0, + "totalSizeTiB": 0, + "totalVolumeSizeGiB": 0, + "volumeGroupCount": 0, + }, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.elastic_sans.begin_update( + resource_group_name=resource_group.name, + elastic_san_name="str", + parameters={ + "properties": {"baseSizeTiB": 0, "extendedCapacitySizeTiB": 0, "publicNetworkAccess": "str"}, + "tags": {"str": "str"}, + }, + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.elastic_sans.begin_delete( + resource_group_name=resource_group.name, + elastic_san_name="str", + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.elastic_sans.get( + resource_group_name=resource_group.name, + elastic_san_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_operations.py new file mode 100644 index 000000000000..955e1fc7e23e --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_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.elasticsan import ElasticSanMgmtClient + +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 TestElasticSanMgmtOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_operations_async.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_operations_async.py new file mode 100644 index 000000000000..2b49c0d6fa0a --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_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.elasticsan.aio import ElasticSanMgmtClient + +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 TestElasticSanMgmtOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient, 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-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_endpoint_connections_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..2651f2922d3b --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_endpoint_connections_operations.py @@ -0,0 +1,93 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elasticsan import ElasticSanMgmtClient + +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 TestElasticSanMgmtPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.private_endpoint_connections.begin_create( + resource_group_name=resource_group.name, + elastic_san_name="str", + private_endpoint_connection_name="str", + parameters={ + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", + }, + "id": "str", + "name": "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-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + elastic_san_name="str", + private_endpoint_connection_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + elastic_san_name="str", + private_endpoint_connection_name="str", + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.private_endpoint_connections.list( + resource_group_name=resource_group.name, + elastic_san_name="str", + api_version="2024-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_endpoint_connections_operations_async.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_endpoint_connections_operations_async.py new file mode 100644 index 000000000000..9ecd34da7fdd --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_endpoint_connections_operations_async.py @@ -0,0 +1,98 @@ +# 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.elasticsan.aio import ElasticSanMgmtClient + +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 TestElasticSanMgmtPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_create( + resource_group_name=resource_group.name, + elastic_san_name="str", + private_endpoint_connection_name="str", + parameters={ + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", + }, + "id": "str", + "name": "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-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + elastic_san_name="str", + private_endpoint_connection_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + elastic_san_name="str", + private_endpoint_connection_name="str", + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.private_endpoint_connections.list( + resource_group_name=resource_group.name, + elastic_san_name="str", + api_version="2024-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_link_resources_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_link_resources_operations.py new file mode 100644 index 000000000000..4387a11023ae --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_link_resources_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elasticsan import ElasticSanMgmtClient + +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 TestElasticSanMgmtPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_elastic_san(self, resource_group): + response = self.client.private_link_resources.list_by_elastic_san( + resource_group_name=resource_group.name, + elastic_san_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_link_resources_operations_async.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_link_resources_operations_async.py new file mode 100644 index 000000000000..40d90045260f --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_private_link_resources_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elasticsan.aio import ElasticSanMgmtClient + +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 TestElasticSanMgmtPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_elastic_san(self, resource_group): + response = await self.client.private_link_resources.list_by_elastic_san( + resource_group_name=resource_group.name, + elastic_san_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_skus_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_skus_operations.py new file mode 100644 index 000000000000..71549e42e6e5 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_skus_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.elasticsan import ElasticSanMgmtClient + +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 TestElasticSanMgmtSkusOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.skus.list( + api_version="2024-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_skus_operations_async.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_skus_operations_async.py new file mode 100644 index 000000000000..b4b5ef6a4e28 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_skus_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.elasticsan.aio import ElasticSanMgmtClient + +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 TestElasticSanMgmtSkusOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.skus.list( + api_version="2024-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_groups_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_groups_operations.py new file mode 100644 index 000000000000..7a43072b4842 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_groups_operations.py @@ -0,0 +1,170 @@ +# 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.elasticsan import ElasticSanMgmtClient + +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 TestElasticSanMgmtVolumeGroupsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_elastic_san(self, resource_group): + response = self.client.volume_groups.list_by_elastic_san( + resource_group_name=resource_group.name, + elastic_san_name="str", + api_version="2024-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.volume_groups.begin_create( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + parameters={ + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "properties": { + "encryption": "str", + "encryptionProperties": { + "identity": {"userAssignedIdentity": "str"}, + "keyVaultProperties": { + "currentVersionedKeyExpirationTimestamp": "2020-02-20 00:00:00", + "currentVersionedKeyIdentifier": "str", + "keyName": "str", + "keyVaultUri": "str", + "keyVersion": "str", + "lastKeyRotationTimestamp": "2020-02-20 00:00:00", + }, + }, + "enforceDataIntegrityCheckForIscsi": bool, + "networkAcls": {"virtualNetworkRules": [{"id": "str", "action": "Allow"}]}, + "privateEndpointConnections": [ + { + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", + }, + "id": "str", + "name": "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", + } + ], + "protocolType": "str", + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.volume_groups.begin_update( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + parameters={ + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "properties": { + "encryption": "str", + "encryptionProperties": { + "identity": {"userAssignedIdentity": "str"}, + "keyVaultProperties": { + "currentVersionedKeyExpirationTimestamp": "2020-02-20 00:00:00", + "currentVersionedKeyIdentifier": "str", + "keyName": "str", + "keyVaultUri": "str", + "keyVersion": "str", + "lastKeyRotationTimestamp": "2020-02-20 00:00:00", + }, + }, + "enforceDataIntegrityCheckForIscsi": bool, + "networkAcls": {"virtualNetworkRules": [{"id": "str", "action": "Allow"}]}, + "protocolType": "str", + }, + }, + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.volume_groups.begin_delete( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.volume_groups.get( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_groups_operations_async.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_groups_operations_async.py new file mode 100644 index 000000000000..33c032b1d6db --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_groups_operations_async.py @@ -0,0 +1,177 @@ +# 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.elasticsan.aio import ElasticSanMgmtClient + +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 TestElasticSanMgmtVolumeGroupsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_elastic_san(self, resource_group): + response = self.client.volume_groups.list_by_elastic_san( + resource_group_name=resource_group.name, + elastic_san_name="str", + api_version="2024-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.volume_groups.begin_create( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + parameters={ + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "name": "str", + "properties": { + "encryption": "str", + "encryptionProperties": { + "identity": {"userAssignedIdentity": "str"}, + "keyVaultProperties": { + "currentVersionedKeyExpirationTimestamp": "2020-02-20 00:00:00", + "currentVersionedKeyIdentifier": "str", + "keyName": "str", + "keyVaultUri": "str", + "keyVersion": "str", + "lastKeyRotationTimestamp": "2020-02-20 00:00:00", + }, + }, + "enforceDataIntegrityCheckForIscsi": bool, + "networkAcls": {"virtualNetworkRules": [{"id": "str", "action": "Allow"}]}, + "privateEndpointConnections": [ + { + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", + }, + "id": "str", + "name": "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", + } + ], + "protocolType": "str", + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.volume_groups.begin_update( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + parameters={ + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "properties": { + "encryption": "str", + "encryptionProperties": { + "identity": {"userAssignedIdentity": "str"}, + "keyVaultProperties": { + "currentVersionedKeyExpirationTimestamp": "2020-02-20 00:00:00", + "currentVersionedKeyIdentifier": "str", + "keyName": "str", + "keyVaultUri": "str", + "keyVersion": "str", + "lastKeyRotationTimestamp": "2020-02-20 00:00:00", + }, + }, + "enforceDataIntegrityCheckForIscsi": bool, + "networkAcls": {"virtualNetworkRules": [{"id": "str", "action": "Allow"}]}, + "protocolType": "str", + }, + }, + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.volume_groups.begin_delete( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.volume_groups.get( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_snapshots_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_snapshots_operations.py new file mode 100644 index 000000000000..caeaf24a0869 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_snapshots_operations.py @@ -0,0 +1,93 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elasticsan import ElasticSanMgmtClient + +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 TestElasticSanMgmtVolumeSnapshotsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_volume_group(self, resource_group): + response = self.client.volume_snapshots.list_by_volume_group( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + api_version="2024-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.volume_snapshots.begin_create( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + snapshot_name="str", + parameters={ + "properties": { + "creationData": {"sourceId": "str"}, + "provisioningState": "str", + "sourceVolumeSizeGiB": 0, + "volumeName": "str", + }, + "id": "str", + "name": "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-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.volume_snapshots.begin_delete( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + snapshot_name="str", + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.volume_snapshots.get( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + snapshot_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_snapshots_operations_async.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_snapshots_operations_async.py new file mode 100644 index 000000000000..7552ff613f28 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volume_snapshots_operations_async.py @@ -0,0 +1,98 @@ +# 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.elasticsan.aio import ElasticSanMgmtClient + +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 TestElasticSanMgmtVolumeSnapshotsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_volume_group(self, resource_group): + response = self.client.volume_snapshots.list_by_volume_group( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + api_version="2024-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.volume_snapshots.begin_create( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + snapshot_name="str", + parameters={ + "properties": { + "creationData": {"sourceId": "str"}, + "provisioningState": "str", + "sourceVolumeSizeGiB": 0, + "volumeName": "str", + }, + "id": "str", + "name": "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-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.volume_snapshots.begin_delete( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + snapshot_name="str", + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.volume_snapshots.get( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + snapshot_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volumes_operations.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volumes_operations.py new file mode 100644 index 000000000000..370300f6215c --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volumes_operations.py @@ -0,0 +1,116 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elasticsan import ElasticSanMgmtClient + +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 TestElasticSanMgmtVolumesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.volumes.begin_create( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + volume_name="str", + parameters={ + "properties": { + "sizeGiB": 0, + "creationData": {"createSource": "str", "sourceId": "str"}, + "managedBy": {"resourceId": "str"}, + "provisioningState": "str", + "storageTarget": { + "provisioningState": "str", + "status": "str", + "targetIqn": "str", + "targetPortalHostname": "str", + "targetPortalPort": 0, + }, + "volumeId": "str", + }, + "id": "str", + "name": "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-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.volumes.begin_update( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + volume_name="str", + parameters={"properties": {"managedBy": {"resourceId": "str"}, "sizeGiB": 0}}, + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.volumes.begin_delete( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + volume_name="str", + api_version="2024-05-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.volumes.get( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + volume_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_volume_group(self, resource_group): + response = self.client.volumes.list_by_volume_group( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + api_version="2024-05-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volumes_operations_async.py b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volumes_operations_async.py new file mode 100644 index 000000000000..ce1260b298b5 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/generated_tests/test_elastic_san_mgmt_volumes_operations_async.py @@ -0,0 +1,123 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.elasticsan.aio import ElasticSanMgmtClient + +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 TestElasticSanMgmtVolumesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.volumes.begin_create( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + volume_name="str", + parameters={ + "properties": { + "sizeGiB": 0, + "creationData": {"createSource": "str", "sourceId": "str"}, + "managedBy": {"resourceId": "str"}, + "provisioningState": "str", + "storageTarget": { + "provisioningState": "str", + "status": "str", + "targetIqn": "str", + "targetPortalHostname": "str", + "targetPortalPort": 0, + }, + "volumeId": "str", + }, + "id": "str", + "name": "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-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.volumes.begin_update( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + volume_name="str", + parameters={"properties": {"managedBy": {"resourceId": "str"}, "sizeGiB": 0}}, + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.volumes.begin_delete( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + volume_name="str", + api_version="2024-05-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.volumes.get( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + volume_name="str", + api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_volume_group(self, resource_group): + response = self.client.volumes.list_by_volume_group( + resource_group_name=resource_group.name, + elastic_san_name="str", + volume_group_name="str", + api_version="2024-05-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/setup.py b/sdk/elasticsan/azure-mgmt-elasticsan/setup.py index 53d9f2817b68..21ef4d816588 100644 --- a/sdk/elasticsan/azure-mgmt-elasticsan/setup.py +++ b/sdk/elasticsan/azure-mgmt-elasticsan/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/elasticsan/azure-mgmt-elasticsan/tests/conftest.py b/sdk/elasticsan/azure-mgmt-elasticsan/tests/conftest.py new file mode 100644 index 000000000000..7ec9aeefd918 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + elasticsanmgmt_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + elasticsanmgmt_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + elasticsanmgmt_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + elasticsanmgmt_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=elasticsanmgmt_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=elasticsanmgmt_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=elasticsanmgmt_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=elasticsanmgmt_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/elasticsan/azure-mgmt-elasticsan/tests/test_elastic_san_mgmt_elastic_sans_operations_async_test.py b/sdk/elasticsan/azure-mgmt-elasticsan/tests/test_elastic_san_mgmt_elastic_sans_operations_async_test.py new file mode 100644 index 000000000000..618989121207 --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/tests/test_elastic_san_mgmt_elastic_sans_operations_async_test.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.elasticsan.aio import ElasticSanMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestElasticSanMgmtElasticSansOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.elastic_sans.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] + \ No newline at end of file diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/tests/test_elastic_san_mgmt_elastic_sans_operations_test.py b/sdk/elasticsan/azure-mgmt-elasticsan/tests/test_elastic_san_mgmt_elastic_sans_operations_test.py new file mode 100644 index 000000000000..72666bb6ca5e --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/tests/test_elastic_san_mgmt_elastic_sans_operations_test.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.elasticsan import ElasticSanMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestElasticSanMgmtElasticSansOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.elastic_sans.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] + \ No newline at end of file diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/tests/test_elastic_san_mgmt_operations_async_test.py b/sdk/elasticsan/azure-mgmt-elasticsan/tests/test_elastic_san_mgmt_operations_async_test.py new file mode 100644 index 000000000000..039610d3aacf --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/tests/test_elastic_san_mgmt_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.elasticsan.aio import ElasticSanMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestElasticSanMgmtOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient, 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 + diff --git a/sdk/elasticsan/azure-mgmt-elasticsan/tests/test_elastic_san_mgmt_operations_test.py b/sdk/elasticsan/azure-mgmt-elasticsan/tests/test_elastic_san_mgmt_operations_test.py new file mode 100644 index 000000000000..64d3c6d32fcc --- /dev/null +++ b/sdk/elasticsan/azure-mgmt-elasticsan/tests/test_elastic_san_mgmt_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.elasticsan import ElasticSanMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestElasticSanMgmtOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ElasticSanMgmtClient) + + @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 +