diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/README.md b/sdk/dataprotection/azure-mgmt-dataprotection/README.md index 05b5553fe7f4..c874cebbaa51 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/README.md +++ b/sdk/dataprotection/azure-mgmt-dataprotection/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Data Protection Management Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/_meta.json b/sdk/dataprotection/azure-mgmt-dataprotection/_meta.json index d5cc741fa28b..21b7e97aa4db 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/_meta.json +++ b/sdk/dataprotection/azure-mgmt-dataprotection/_meta.json @@ -1,11 +1,11 @@ { - "commit": "9c7722c82ca6c894e3d5931f074c4f025598af08", + "commit": "9e00eb06b7b961f32582d71af319ed7ffc8d78b8", "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.15.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/dataprotection/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/dataprotection/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.15.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/dataprotection/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_configuration.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_configuration.py index 308ec2a95ea2..cbd666b18f43 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_configuration.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_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 DataProtectionMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class DataProtectionMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for DataProtectionMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class DataProtectionMgmtClientConfiguration(Configuration): # pylint: disable=t :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-11-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-04-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(DataProtectionMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-11-01") + api_version: str = kwargs.pop("api_version", "2024-04-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-dataprotection/{}".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/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_data_protection_mgmt_client.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_data_protection_mgmt_client.py index 4e40b6d1233d..2bb658e0cbc2 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_data_protection_mgmt_client.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_data_protection_mgmt_client.py @@ -8,14 +8,18 @@ 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 DataProtectionMgmtClientConfiguration from ._serialization import Deserializer, Serializer from .operations import ( + BackupInstancesExtensionRoutingOperations, BackupInstancesOperations, BackupPoliciesOperations, BackupVaultOperationResultsOperations, @@ -84,6 +88,9 @@ class DataProtectionMgmtClient: # pylint: disable=client-accepts-api-version-ke :ivar fetch_cross_region_restore_jobs: FetchCrossRegionRestoreJobsOperations operations :vartype fetch_cross_region_restore_jobs: azure.mgmt.dataprotection.operations.FetchCrossRegionRestoreJobsOperations + :ivar backup_instances_extension_routing: BackupInstancesExtensionRoutingOperations operations + :vartype backup_instances_extension_routing: + azure.mgmt.dataprotection.operations.BackupInstancesExtensionRoutingOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.dataprotection.operations.JobsOperations :ivar restorable_time_ranges: RestorableTimeRangesOperations operations @@ -108,7 +115,7 @@ class DataProtectionMgmtClient: # pylint: disable=client-accepts-api-version-ke :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-11-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-04-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 @@ -125,7 +132,25 @@ def __init__( self._config = DataProtectionMgmtClientConfiguration( 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) @@ -165,6 +190,9 @@ def __init__( self.fetch_cross_region_restore_jobs = FetchCrossRegionRestoreJobsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.backup_instances_extension_routing = BackupInstancesExtensionRoutingOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) self.restorable_time_ranges = RestorableTimeRangesOperations( self._client, self._config, self._serialize, self._deserialize @@ -181,7 +209,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 @@ -201,12 +229,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) -> "DataProtectionMgmtClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_serialization.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_serialization.py index 4bae2292227b..8139854b97bb 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_serialization.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_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/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_vendor.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_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/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_version.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_version.py index bd1665239c5a..e5754a47ce68 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_version.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.3.0" +VERSION = "1.0.0b1" diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_configuration.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_configuration.py index fad44bc26231..4809b5ab60c7 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_configuration.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/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 DataProtectionMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class DataProtectionMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for DataProtectionMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class DataProtectionMgmtClientConfiguration(Configuration): # pylint: disable=t :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-11-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-04-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(DataProtectionMgmtClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-11-01") + api_version: str = kwargs.pop("api_version", "2024-04-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-dataprotection/{}".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/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_data_protection_mgmt_client.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_data_protection_mgmt_client.py index 275719fddf7f..8227949ac488 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_data_protection_mgmt_client.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/_data_protection_mgmt_client.py @@ -8,14 +8,18 @@ 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 from ._configuration import DataProtectionMgmtClientConfiguration from .operations import ( + BackupInstancesExtensionRoutingOperations, BackupInstancesOperations, BackupPoliciesOperations, BackupVaultOperationResultsOperations, @@ -84,6 +88,9 @@ class DataProtectionMgmtClient: # pylint: disable=client-accepts-api-version-ke :ivar fetch_cross_region_restore_jobs: FetchCrossRegionRestoreJobsOperations operations :vartype fetch_cross_region_restore_jobs: azure.mgmt.dataprotection.aio.operations.FetchCrossRegionRestoreJobsOperations + :ivar backup_instances_extension_routing: BackupInstancesExtensionRoutingOperations operations + :vartype backup_instances_extension_routing: + azure.mgmt.dataprotection.aio.operations.BackupInstancesExtensionRoutingOperations :ivar jobs: JobsOperations operations :vartype jobs: azure.mgmt.dataprotection.aio.operations.JobsOperations :ivar restorable_time_ranges: RestorableTimeRangesOperations operations @@ -108,7 +115,7 @@ class DataProtectionMgmtClient: # pylint: disable=client-accepts-api-version-ke :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-11-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-04-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 @@ -125,7 +132,25 @@ def __init__( self._config = DataProtectionMgmtClientConfiguration( 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) @@ -165,6 +190,9 @@ def __init__( self.fetch_cross_region_restore_jobs = FetchCrossRegionRestoreJobsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.backup_instances_extension_routing = BackupInstancesExtensionRoutingOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) self.restorable_time_ranges = RestorableTimeRangesOperations( self._client, self._config, self._serialize, self._deserialize @@ -181,7 +209,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 @@ -201,12 +231,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) -> "DataProtectionMgmtClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/__init__.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/__init__.py index 3080328f08e9..42904f5f3feb 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/__init__.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/__init__.py @@ -20,6 +20,7 @@ from ._fetch_secondary_recovery_points_operations import FetchSecondaryRecoveryPointsOperations from ._fetch_cross_region_restore_job_operations import FetchCrossRegionRestoreJobOperations from ._fetch_cross_region_restore_jobs_operations import FetchCrossRegionRestoreJobsOperations +from ._backup_instances_extension_routing_operations import BackupInstancesExtensionRoutingOperations from ._jobs_operations import JobsOperations from ._restorable_time_ranges_operations import RestorableTimeRangesOperations from ._export_jobs_operations import ExportJobsOperations @@ -47,6 +48,7 @@ "FetchSecondaryRecoveryPointsOperations", "FetchCrossRegionRestoreJobOperations", "FetchCrossRegionRestoreJobsOperations", + "BackupInstancesExtensionRoutingOperations", "JobsOperations", "RestorableTimeRangesOperations", "ExportJobsOperations", diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_instances_extension_routing_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_instances_extension_routing_operations.py new file mode 100644 index 000000000000..d279719e6d5a --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_instances_extension_routing_operations.py @@ -0,0 +1,135 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +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 ...operations._backup_instances_extension_routing_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]] + + +class BackupInstancesExtensionRoutingOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.aio.DataProtectionMgmtClient`'s + :attr:`backup_instances_extension_routing` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_id: str, **kwargs: Any) -> AsyncIterable["_models.BackupInstanceResource"]: + """Gets a list of backup instances associated with a tracked resource. + + :param resource_id: ARM path of the resource to be protected using Microsoft.DataProtection. + Required. + :type resource_id: str + :return: An iterator like instance of either BackupInstanceResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.BackupInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BackupInstanceResourceList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_id=resource_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BackupInstanceResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_instances_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_instances_operations.py index 0e4442504a91..3c599f15b7b3 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_instances_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_instances_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 @@ -20,9 +21,8 @@ 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 +30,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._backup_instances_operations import ( build_adhoc_backup_request, build_create_or_update_request, @@ -51,6 +50,10 @@ build_validate_for_restore_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]] @@ -85,7 +88,6 @@ def list( :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BackupInstanceResource or the result of cls(response) :rtype: @@ -98,7 +100,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackupInstanceResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -109,17 +111,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, vault_name=vault_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 @@ -131,13 +131,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BackupInstanceResourceList", pipeline_response) @@ -147,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 @@ -163,10 +162,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances" - } - @distributed_trace_async async def get( self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any @@ -180,12 +175,11 @@ async def get( :type vault_name: str :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BackupInstanceResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BackupInstanceResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -199,22 +193,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackupInstanceResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_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 @@ -223,26 +215,23 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BackupInstanceResource", pipeline_response) + deserialized = self._deserialize("BackupInstanceResource", 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.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.BackupInstanceResource, IO], + parameters: Union[_models.BackupInstanceResource, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.BackupInstanceResource]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +244,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.BackupInstanceResource]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -265,40 +254,39 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "BackupInstanceResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, subscription_id=self._config.subscription_id, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize("BackupInstanceResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 201: - deserialized = self._deserialize("BackupInstanceResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -306,14 +294,12 @@ async def _create_or_update_initial( "str", response.headers.get("Azure-AsyncOperation") ) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -322,6 +308,7 @@ async def begin_create_or_update( vault_name: str, backup_instance_name: str, parameters: _models.BackupInstanceResource, + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -337,17 +324,11 @@ async def begin_create_or_update( :type backup_instance_name: str :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.BackupInstanceResource + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either BackupInstanceResource or the result of cls(response) :rtype: @@ -361,7 +342,8 @@ async def begin_create_or_update( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: IO, + parameters: IO[bytes], + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -376,18 +358,12 @@ async def begin_create_or_update( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either BackupInstanceResource or the result of cls(response) :rtype: @@ -401,7 +377,8 @@ async def begin_create_or_update( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.BackupInstanceResource, IO], + parameters: Union[_models.BackupInstanceResource, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[_models.BackupInstanceResource]: """Create or update a backup instance in a backup vault. @@ -413,20 +390,11 @@ async def begin_create_or_update( :type vault_name: str :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str - :param parameters: Request body for operation. Is either a BackupInstanceResource type or a IO - type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.BackupInstanceResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Request body for operation. Is either a BackupInstanceResource type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.BackupInstanceResource or IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :return: An instance of AsyncLROPoller that returns either BackupInstanceResource or the result of cls(response) :rtype: @@ -448,6 +416,7 @@ async def begin_create_or_update( vault_name=vault_name, backup_instance_name=backup_instance_name, parameters=parameters, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -455,12 +424,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BackupInstanceResource", pipeline_response) + deserialized = self._deserialize("BackupInstanceResource", 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,22 +440,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BackupInstanceResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}" - } + return AsyncLROPoller[_models.BackupInstanceResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any - ) -> None: - error_map = { + async def _delete_initial( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -497,33 +470,36 @@ 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, vault_name=vault_name, backup_instance_name=backup_instance_name, subscription_id=self._config.subscription_id, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, 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 + _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]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( @@ -531,16 +507,24 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline) + + if response.status_code == 204: + deserialized = response.stream_download(self._client._pipeline) + 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.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( - self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a backup instance in a backup vault. @@ -551,14 +535,8 @@ async def begin_delete( :type vault_name: str :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_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. + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :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: @@ -572,21 +550,23 @@ 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, vault_name=vault_name, backup_instance_name=backup_instance_name, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -595,27 +575,23 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _adhoc_backup_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.TriggerBackupRequest, IO], + parameters: Union[_models.TriggerBackupRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OperationJobExtendedInfo]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -628,7 +604,7 @@ async def _adhoc_backup_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.OperationJobExtendedInfo]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -638,7 +614,7 @@ async def _adhoc_backup_initial( else: _json = self._serialize.body(parameters, "TriggerBackupRequest") - request = build_adhoc_backup_request( + _request = build_adhoc_backup_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -647,28 +623,26 @@ async def _adhoc_backup_initial( content_type=content_type, json=_json, content=_content, - template_url=self._adhoc_backup_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -677,14 +651,12 @@ async def _adhoc_backup_initial( ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _adhoc_backup_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/backup" - } + return deserialized # type: ignore @overload async def begin_adhoc_backup( @@ -711,14 +683,6 @@ async def begin_adhoc_backup( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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 OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -732,7 +696,7 @@ async def begin_adhoc_backup( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -747,18 +711,10 @@ async def begin_adhoc_backup( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -772,7 +728,7 @@ async def begin_adhoc_backup( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.TriggerBackupRequest, IO], + parameters: Union[_models.TriggerBackupRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: """Trigger adhoc backup. @@ -784,20 +740,9 @@ async def begin_adhoc_backup( :type vault_name: str :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str - :param parameters: Request body for operation. Is either a TriggerBackupRequest type or a IO - type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.TriggerBackupRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Request body for operation. Is either a TriggerBackupRequest type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.TriggerBackupRequest or IO[bytes] :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -826,12 +771,13 @@ async def begin_adhoc_backup( 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("OperationJobExtendedInfo", pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -843,26 +789,24 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.OperationJobExtendedInfo].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_adhoc_backup.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/backup" - } + return AsyncLROPoller[_models.OperationJobExtendedInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _validate_for_backup_initial( self, resource_group_name: str, vault_name: str, - parameters: Union[_models.ValidateForBackupRequest, IO], + parameters: Union[_models.ValidateForBackupRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OperationJobExtendedInfo]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -875,7 +819,7 @@ async def _validate_for_backup_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.OperationJobExtendedInfo]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -885,7 +829,7 @@ async def _validate_for_backup_initial( else: _json = self._serialize.body(parameters, "ValidateForBackupRequest") - request = build_validate_for_backup_request( + _request = build_validate_for_backup_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, @@ -893,28 +837,26 @@ async def _validate_for_backup_initial( content_type=content_type, json=_json, content=_content, - template_url=self._validate_for_backup_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -923,14 +865,12 @@ async def _validate_for_backup_initial( ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _validate_for_backup_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/validateForBackup" - } + return deserialized # type: ignore @overload async def begin_validate_for_backup( @@ -954,14 +894,6 @@ async def begin_validate_for_backup( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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 OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -974,7 +906,7 @@ async def begin_validate_for_backup( self, resource_group_name: str, vault_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -987,18 +919,10 @@ async def begin_validate_for_backup( :param vault_name: The name of the backup vault. Required. :type vault_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1011,7 +935,7 @@ async def begin_validate_for_backup( self, resource_group_name: str, vault_name: str, - parameters: Union[_models.ValidateForBackupRequest, IO], + parameters: Union[_models.ValidateForBackupRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: """Validate whether adhoc backup will be successful or not. @@ -1022,19 +946,8 @@ async def begin_validate_for_backup( :param vault_name: The name of the backup vault. Required. :type vault_name: str :param parameters: Request body for operation. Is either a ValidateForBackupRequest type or a - IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.ValidateForBackupRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ValidateForBackupRequest or IO[bytes] :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1062,12 +975,13 @@ async def begin_validate_for_backup( 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("OperationJobExtendedInfo", pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1079,17 +993,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.OperationJobExtendedInfo].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_validate_for_backup.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/validateForBackup" - } + return AsyncLROPoller[_models.OperationJobExtendedInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def get_backup_instance_operation_result( @@ -1106,12 +1018,11 @@ async def get_backup_instance_operation_result( :type backup_instance_name: str :param operation_id: Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BackupInstanceResource or None or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BackupInstanceResource or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1125,23 +1036,21 @@ async def get_backup_instance_operation_result( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.BackupInstanceResource]] = kwargs.pop("cls", None) - request = build_get_backup_instance_operation_result_request( + _request = build_get_backup_instance_operation_result_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_backup_instance_operation_result.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1152,25 +1061,21 @@ async def get_backup_instance_operation_result( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("BackupInstanceResource", pipeline_response) + deserialized = self._deserialize("BackupInstanceResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_backup_instance_operation_result.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/operationResults/{operationId}" - } + return deserialized # type: ignore async def _trigger_cross_region_restore_initial( self, resource_group_name: str, location: str, - parameters: Union[_models.CrossRegionRestoreRequestObject, IO], + parameters: Union[_models.CrossRegionRestoreRequestObject, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OperationJobExtendedInfo]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1183,7 +1088,7 @@ async def _trigger_cross_region_restore_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.OperationJobExtendedInfo]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1193,7 +1098,7 @@ async def _trigger_cross_region_restore_initial( else: _json = self._serialize.body(parameters, "CrossRegionRestoreRequestObject") - request = build_trigger_cross_region_restore_request( + _request = build_trigger_cross_region_restore_request( resource_group_name=resource_group_name, location=location, subscription_id=self._config.subscription_id, @@ -1201,29 +1106,27 @@ async def _trigger_cross_region_restore_initial( content_type=content_type, json=_json, content=_content, - template_url=self._trigger_cross_region_restore_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + await response.read() # Load the body in memory and close the socket 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("OperationJobExtendedInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -1232,14 +1135,12 @@ async def _trigger_cross_region_restore_initial( ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _trigger_cross_region_restore_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/crossRegionRestore" - } + return deserialized # type: ignore @overload async def begin_trigger_cross_region_restore( @@ -1263,14 +1164,6 @@ async def begin_trigger_cross_region_restore( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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 OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1283,7 +1176,7 @@ async def begin_trigger_cross_region_restore( self, resource_group_name: str, location: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1296,18 +1189,10 @@ async def begin_trigger_cross_region_restore( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for trigger CRR operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1320,7 +1205,7 @@ async def begin_trigger_cross_region_restore( self, resource_group_name: str, location: str, - parameters: Union[_models.CrossRegionRestoreRequestObject, IO], + parameters: Union[_models.CrossRegionRestoreRequestObject, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: """Triggers Cross Region Restore for BackupInstance. @@ -1331,19 +1216,9 @@ async def begin_trigger_cross_region_restore( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for trigger CRR operation. Is either a - CrossRegionRestoreRequestObject type or a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.CrossRegionRestoreRequestObject or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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. + CrossRegionRestoreRequestObject type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.CrossRegionRestoreRequestObject or + IO[bytes] :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1371,12 +1246,13 @@ async def begin_trigger_cross_region_restore( 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("OperationJobExtendedInfo", pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1388,26 +1264,24 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.OperationJobExtendedInfo].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_trigger_cross_region_restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/crossRegionRestore" - } + return AsyncLROPoller[_models.OperationJobExtendedInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _validate_cross_region_restore_initial( self, resource_group_name: str, location: str, - parameters: Union[_models.ValidateCrossRegionRestoreRequestObject, IO], + parameters: Union[_models.ValidateCrossRegionRestoreRequestObject, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OperationJobExtendedInfo]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1420,7 +1294,7 @@ async def _validate_cross_region_restore_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.OperationJobExtendedInfo]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1430,7 +1304,7 @@ async def _validate_cross_region_restore_initial( else: _json = self._serialize.body(parameters, "ValidateCrossRegionRestoreRequestObject") - request = build_validate_cross_region_restore_request( + _request = build_validate_cross_region_restore_request( resource_group_name=resource_group_name, location=location, subscription_id=self._config.subscription_id, @@ -1438,29 +1312,27 @@ async def _validate_cross_region_restore_initial( content_type=content_type, json=_json, content=_content, - template_url=self._validate_cross_region_restore_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + await response.read() # Load the body in memory and close the socket 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("OperationJobExtendedInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -1469,14 +1341,12 @@ async def _validate_cross_region_restore_initial( ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _validate_cross_region_restore_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/validateCrossRegionRestore" - } + return deserialized # type: ignore @overload async def begin_validate_cross_region_restore( @@ -1500,14 +1370,6 @@ async def begin_validate_cross_region_restore( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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 OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1520,7 +1382,7 @@ async def begin_validate_cross_region_restore( self, resource_group_name: str, location: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1533,18 +1395,10 @@ async def begin_validate_cross_region_restore( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1557,7 +1411,7 @@ async def begin_validate_cross_region_restore( self, resource_group_name: str, location: str, - parameters: Union[_models.ValidateCrossRegionRestoreRequestObject, IO], + parameters: Union[_models.ValidateCrossRegionRestoreRequestObject, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: """Validates whether Cross Region Restore can be triggered for DataSource. @@ -1568,20 +1422,9 @@ async def begin_validate_cross_region_restore( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for operation. Is either a - ValidateCrossRegionRestoreRequestObject type or a IO type. Required. + ValidateCrossRegionRestoreRequestObject type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.dataprotection.models.ValidateCrossRegionRestoreRequestObject or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1609,12 +1452,13 @@ async def begin_validate_cross_region_restore( 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("OperationJobExtendedInfo", pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1626,27 +1470,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.OperationJobExtendedInfo].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_validate_cross_region_restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/validateCrossRegionRestore" - } + return AsyncLROPoller[_models.OperationJobExtendedInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _trigger_rehydrate_initial( # pylint: disable=inconsistent-return-statements + async def _trigger_rehydrate_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.AzureBackupRehydrationRequest, IO], + parameters: Union[_models.AzureBackupRehydrationRequest, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1659,7 +1501,7 @@ async def _trigger_rehydrate_initial( # pylint: disable=inconsistent-return-sta 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[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1669,7 +1511,7 @@ async def _trigger_rehydrate_initial( # pylint: disable=inconsistent-return-sta else: _json = self._serialize.body(parameters, "AzureBackupRehydrationRequest") - request = build_trigger_rehydrate_request( + _request = build_trigger_rehydrate_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -1678,21 +1520,20 @@ async def _trigger_rehydrate_initial( # pylint: disable=inconsistent-return-sta content_type=content_type, json=_json, content=_content, - template_url=self._trigger_rehydrate_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -1704,12 +1545,15 @@ async def _trigger_rehydrate_initial( # pylint: disable=inconsistent-return-sta ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline) + + if response.status_code == 204: + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _trigger_rehydrate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/rehydrate" - } + return deserialized # type: ignore @overload async def begin_trigger_rehydrate( @@ -1736,14 +1580,6 @@ async def begin_trigger_rehydrate( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -1755,7 +1591,7 @@ async def begin_trigger_rehydrate( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1770,18 +1606,10 @@ async def begin_trigger_rehydrate( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1793,7 +1621,7 @@ async def begin_trigger_rehydrate( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.AzureBackupRehydrationRequest, IO], + parameters: Union[_models.AzureBackupRehydrationRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[None]: """rehydrate recovery point for restore for a BackupInstance. @@ -1806,19 +1634,8 @@ async def begin_trigger_rehydrate( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Is either a AzureBackupRehydrationRequest type - or a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRehydrationRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRehydrationRequest or IO[bytes] :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1833,7 +1650,7 @@ async def begin_trigger_rehydrate( 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._trigger_rehydrate_initial( # type: ignore + raw_result = await self._trigger_rehydrate_initial( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -1845,11 +1662,12 @@ async def begin_trigger_rehydrate( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -1858,27 +1676,24 @@ 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_trigger_rehydrate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/rehydrate" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _trigger_restore_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.AzureBackupRestoreRequest, IO], + parameters: Union[_models.AzureBackupRestoreRequest, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.OperationJobExtendedInfo]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1891,7 +1706,7 @@ async def _trigger_restore_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.OperationJobExtendedInfo]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1901,37 +1716,36 @@ async def _trigger_restore_initial( else: _json = self._serialize.body(parameters, "AzureBackupRestoreRequest") - request = build_trigger_restore_request( + _request = build_trigger_restore_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, subscription_id=self._config.subscription_id, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._trigger_restore_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -1940,14 +1754,12 @@ async def _trigger_restore_initial( ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _trigger_restore_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/restore" - } + return deserialized # type: ignore @overload async def begin_trigger_restore( @@ -1956,6 +1768,7 @@ async def begin_trigger_restore( vault_name: str, backup_instance_name: str, parameters: _models.AzureBackupRestoreRequest, + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1971,17 +1784,11 @@ async def begin_trigger_restore( :type backup_instance_name: str :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1995,7 +1802,8 @@ async def begin_trigger_restore( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: IO, + parameters: IO[bytes], + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2010,18 +1818,12 @@ async def begin_trigger_restore( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -2035,7 +1837,8 @@ async def begin_trigger_restore( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.AzureBackupRestoreRequest, IO], + parameters: Union[_models.AzureBackupRestoreRequest, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: """Triggers restore for a BackupInstance. @@ -2048,19 +1851,10 @@ async def begin_trigger_restore( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Is either a AzureBackupRestoreRequest type or a - IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest or IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -2082,6 +1876,7 @@ async def begin_trigger_restore( vault_name=vault_name, backup_instance_name=backup_instance_name, parameters=parameters, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2089,12 +1884,13 @@ async def begin_trigger_restore( 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("OperationJobExtendedInfo", pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2106,22 +1902,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.OperationJobExtendedInfo].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_trigger_restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/restore" - } + return AsyncLROPoller[_models.OperationJobExtendedInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _resume_backups_initial( # pylint: disable=inconsistent-return-statements + async def _resume_backups_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2133,33 +1927,35 @@ async def _resume_backups_initial( # pylint: disable=inconsistent-return-statem _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_resume_backups_request( + _request = build_resume_backups_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._resume_backups_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( @@ -2167,12 +1963,12 @@ async def _resume_backups_initial( # pylint: disable=inconsistent-return-statem ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _resume_backups_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeBackups" - } + return deserialized # type: ignore @distributed_trace_async async def begin_resume_backups( @@ -2187,14 +1983,6 @@ async def begin_resume_backups( :type vault_name: str :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_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: @@ -2208,7 +1996,7 @@ async def begin_resume_backups( 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._resume_backups_initial( # type: ignore + raw_result = await self._resume_backups_initial( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -2218,11 +2006,12 @@ async def begin_resume_backups( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -2231,22 +2020,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_resume_backups.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeBackups" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _resume_protection_initial( # pylint: disable=inconsistent-return-statements + async def _resume_protection_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2258,33 +2043,35 @@ async def _resume_protection_initial( # pylint: disable=inconsistent-return-sta _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_resume_protection_request( + _request = build_resume_protection_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._resume_protection_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( @@ -2292,12 +2079,12 @@ async def _resume_protection_initial( # pylint: disable=inconsistent-return-sta ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _resume_protection_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeProtection" - } + return deserialized # type: ignore @distributed_trace_async async def begin_resume_protection( @@ -2312,14 +2099,6 @@ async def begin_resume_protection( :type vault_name: str :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_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: @@ -2333,7 +2112,7 @@ async def begin_resume_protection( 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._resume_protection_initial( # type: ignore + raw_result = await self._resume_protection_initial( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -2343,11 +2122,12 @@ async def begin_resume_protection( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -2356,22 +2136,24 @@ 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 + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_resume_protection.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeProtection" - } - - async def _stop_protection_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any - ) -> None: - error_map = { + async def _stop_protection_initial( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + parameters: Optional[Union[_models.StopProtectionRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2379,37 +2161,55 @@ async def _stop_protection_initial( # pylint: disable=inconsistent-return-state } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_stop_protection_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "StopProtectionRequest") + else: + _json = None + + _request = build_stop_protection_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, subscription_id=self._config.subscription_id, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, - template_url=self._stop_protection_initial.metadata["url"], + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( @@ -2417,16 +2217,88 @@ async def _stop_protection_initial( # pylint: disable=inconsistent-return-state ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_stop_protection( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + parameters: Optional[_models.StopProtectionRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """This operation will stop protection of a backup instance and data will be held forever. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str + :param parameters: Request body for operation. Default value is None. + :type parameters: ~azure.mgmt.dataprotection.models.StopProtectionRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_stop_protection( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """This operation will stop protection of a backup instance and data will be held forever. - _stop_protection_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/stopProtection" - } + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str + :param parameters: Request body for operation. Default value is None. + :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 + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_stop_protection( - self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + parameters: Optional[Union[_models.StopProtectionRequest, IO[bytes]]] = None, + **kwargs: Any ) -> AsyncLROPoller[None]: """This operation will stop protection of a backup instance and data will be held forever. @@ -2437,42 +2309,44 @@ async def begin_stop_protection( :type vault_name: str :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_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. + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str + :param parameters: Request body for operation. Is either a StopProtectionRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.dataprotection.models.StopProtectionRequest or IO[bytes] :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._stop_protection_initial( # type: ignore + raw_result = await self._stop_protection_initial( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, + parameters=parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -2481,22 +2355,24 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_stop_protection.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/stopProtection" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _suspend_backups_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any - ) -> None: - error_map = { + async def _suspend_backups_initial( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + parameters: Optional[Union[_models.SuspendBackupRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2504,37 +2380,55 @@ async def _suspend_backups_initial( # pylint: disable=inconsistent-return-state } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "SuspendBackupRequest") + else: + _json = None - request = build_suspend_backups_request( + _request = build_suspend_backups_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, subscription_id=self._config.subscription_id, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, - template_url=self._suspend_backups_initial.metadata["url"], + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( @@ -2542,16 +2436,90 @@ async def _suspend_backups_initial( # pylint: disable=inconsistent-return-state ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _suspend_backups_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/suspendBackups" - } + return deserialized # type: ignore + + @overload + async def begin_suspend_backups( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + parameters: Optional[_models.SuspendBackupRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """This operation will stop backup for a backup instance and retains the backup data as per the + policy (except latest Recovery point, which will be retained forever). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str + :param parameters: Request body for operation. Default value is None. + :type parameters: ~azure.mgmt.dataprotection.models.SuspendBackupRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_suspend_backups( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """This operation will stop backup for a backup instance and retains the backup data as per the + policy (except latest Recovery point, which will be retained forever). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str + :param parameters: Request body for operation. Default value is None. + :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 + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_suspend_backups( - self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + parameters: Optional[Union[_models.SuspendBackupRequest, IO[bytes]]] = None, + **kwargs: Any ) -> AsyncLROPoller[None]: """This operation will stop backup for a backup instance and retains the backup data as per the policy (except latest Recovery point, which will be retained forever). @@ -2563,42 +2531,44 @@ async def begin_suspend_backups( :type vault_name: str :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_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. + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str + :param parameters: Request body for operation. Is either a SuspendBackupRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.dataprotection.models.SuspendBackupRequest or IO[bytes] :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._suspend_backups_initial( # type: ignore + raw_result = await self._suspend_backups_initial( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, + parameters=parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -2607,27 +2577,23 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_suspend_backups.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/suspendBackups" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _sync_backup_instance_initial( # pylint: disable=inconsistent-return-statements + async def _sync_backup_instance_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.SyncBackupInstanceRequest, IO], + parameters: Union[_models.SyncBackupInstanceRequest, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2640,7 +2606,7 @@ async def _sync_backup_instance_initial( # pylint: disable=inconsistent-return- 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[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -2650,7 +2616,7 @@ async def _sync_backup_instance_initial( # pylint: disable=inconsistent-return- else: _json = self._serialize.body(parameters, "SyncBackupInstanceRequest") - request = build_sync_backup_instance_request( + _request = build_sync_backup_instance_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -2659,25 +2625,27 @@ async def _sync_backup_instance_initial( # pylint: disable=inconsistent-return- content_type=content_type, json=_json, content=_content, - template_url=self._sync_backup_instance_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( @@ -2685,12 +2653,12 @@ async def _sync_backup_instance_initial( # pylint: disable=inconsistent-return- ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _sync_backup_instance_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/sync" - } + return deserialized # type: ignore @overload async def begin_sync_backup_instance( @@ -2718,14 +2686,6 @@ async def begin_sync_backup_instance( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -2737,7 +2697,7 @@ async def begin_sync_backup_instance( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2753,18 +2713,10 @@ async def begin_sync_backup_instance( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2776,7 +2728,7 @@ async def begin_sync_backup_instance( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.SyncBackupInstanceRequest, IO], + parameters: Union[_models.SyncBackupInstanceRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[None]: """Sync backup instance again in case of failure @@ -2790,19 +2742,8 @@ async def begin_sync_backup_instance( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Is either a SyncBackupInstanceRequest type or a - IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.SyncBackupInstanceRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.SyncBackupInstanceRequest or IO[bytes] :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2817,7 +2758,7 @@ async def begin_sync_backup_instance( 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._sync_backup_instance_initial( # type: ignore + raw_result = await self._sync_backup_instance_initial( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -2829,11 +2770,12 @@ async def begin_sync_backup_instance( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -2842,27 +2784,23 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_sync_backup_instance.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/sync" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _validate_for_restore_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.ValidateRestoreRequestObject, IO], + parameters: Union[_models.ValidateRestoreRequestObject, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OperationJobExtendedInfo]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2875,7 +2813,7 @@ async def _validate_for_restore_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.OperationJobExtendedInfo]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -2885,7 +2823,7 @@ async def _validate_for_restore_initial( else: _json = self._serialize.body(parameters, "ValidateRestoreRequestObject") - request = build_validate_for_restore_request( + _request = build_validate_for_restore_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -2894,28 +2832,26 @@ async def _validate_for_restore_initial( content_type=content_type, json=_json, content=_content, - template_url=self._validate_for_restore_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -2924,14 +2860,12 @@ async def _validate_for_restore_initial( ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _validate_for_restore_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/validateRestore" - } + return deserialized # type: ignore @overload async def begin_validate_for_restore( @@ -2958,14 +2892,6 @@ async def begin_validate_for_restore( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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 OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -2979,7 +2905,7 @@ async def begin_validate_for_restore( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2994,18 +2920,10 @@ async def begin_validate_for_restore( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -3019,7 +2937,7 @@ async def begin_validate_for_restore( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.ValidateRestoreRequestObject, IO], + parameters: Union[_models.ValidateRestoreRequestObject, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.OperationJobExtendedInfo]: """Validates if Restore can be triggered for a DataSource. @@ -3032,19 +2950,8 @@ async def begin_validate_for_restore( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Is either a ValidateRestoreRequestObject type or - a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.ValidateRestoreRequestObject or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ValidateRestoreRequestObject or IO[bytes] :return: An instance of AsyncLROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -3073,12 +2980,13 @@ async def begin_validate_for_restore( 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("OperationJobExtendedInfo", pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -3090,14 +2998,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.OperationJobExtendedInfo].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_validate_for_restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/validateRestore" - } + return AsyncLROPoller[_models.OperationJobExtendedInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_policies_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_policies_operations.py index 23fc8fa2df01..362678d3a887 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_policies_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_policies_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, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._backup_policies_operations import ( build_create_or_update_request, build_delete_request, @@ -36,6 +35,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]] @@ -70,7 +73,6 @@ def list( :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BaseBackupPolicyResource or the result of cls(response) :rtype: @@ -83,7 +85,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BaseBackupPolicyResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,17 +96,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, vault_name=vault_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -116,13 +116,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BaseBackupPolicyResourceList", pipeline_response) @@ -132,11 +131,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -148,10 +147,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies" - } - @distributed_trace_async async def get( self, resource_group_name: str, vault_name: str, backup_policy_name: str, **kwargs: Any @@ -167,12 +162,11 @@ async def get( :type vault_name: str :param backup_policy_name: Required. :type backup_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BaseBackupPolicyResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -186,22 +180,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BaseBackupPolicyResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_policy_name=backup_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -210,16 +202,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BaseBackupPolicyResource", pipeline_response) + deserialized = self._deserialize("BaseBackupPolicyResource", 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.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -248,7 +236,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BaseBackupPolicyResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource :raises ~azure.core.exceptions.HttpResponseError: @@ -260,7 +247,7 @@ async def create_or_update( resource_group_name: str, vault_name: str, backup_policy_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -277,11 +264,10 @@ async def create_or_update( :param backup_policy_name: Name of the policy. Required. :type backup_policy_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BaseBackupPolicyResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource :raises ~azure.core.exceptions.HttpResponseError: @@ -293,7 +279,7 @@ async def create_or_update( resource_group_name: str, vault_name: str, backup_policy_name: str, - parameters: Union[_models.BaseBackupPolicyResource, IO], + parameters: Union[_models.BaseBackupPolicyResource, IO[bytes]], **kwargs: Any ) -> _models.BaseBackupPolicyResource: """Creates or Updates a backup policy belonging to a backup vault. @@ -308,17 +294,13 @@ async def create_or_update( :param backup_policy_name: Name of the policy. Required. :type backup_policy_name: str :param parameters: Request body for operation. Is either a BaseBackupPolicyResource type or a - IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource or IO[bytes] :return: BaseBackupPolicyResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,7 +323,7 @@ async def create_or_update( else: _json = self._serialize.body(parameters, "BaseBackupPolicyResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_policy_name=backup_policy_name, @@ -350,16 +332,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -368,16 +348,12 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BaseBackupPolicyResource", pipeline_response) + deserialized = self._deserialize("BaseBackupPolicyResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -394,12 +370,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type vault_name: str :param backup_policy_name: Required. :type backup_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -413,22 +388,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_policy_name=backup_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -438,8 +411,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_vault_operation_results_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_vault_operation_results_operations.py index 45fc64bfb1ac..da18d6f2bff7 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_vault_operation_results_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_vault_operation_results_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._backup_vault_operation_results_operations import build_get_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,12 +66,11 @@ async def get( :type vault_name: str :param operation_id: Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BackupVaultResource or None or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BackupVaultResource or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,22 +84,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.BackupVaultResource]] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -109,7 +109,7 @@ async def get( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize("BackupVaultResource", pipeline_response) + deserialized = self._deserialize("BackupVaultResource", pipeline_response.http_response) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -119,10 +119,6 @@ async def get( response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/operationResults/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_vaults_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_vaults_operations.py index 1d9824462935..160ff710220b 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_vaults_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_backup_vaults_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 @@ -20,9 +21,8 @@ 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 +30,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._backup_vaults_operations import ( build_check_name_availability_request, build_create_or_update_request, @@ -41,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,7 +71,6 @@ def __init__(self, *args, **kwargs) -> None: def get_in_subscription(self, **kwargs: Any) -> AsyncIterable["_models.BackupVaultResource"]: """Returns resource collection belonging to a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BackupVaultResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.BackupVaultResource] @@ -80,7 +82,7 @@ def get_in_subscription(self, **kwargs: Any) -> AsyncIterable["_models.BackupVau api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackupVaultResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,15 +93,13 @@ def get_in_subscription(self, **kwargs: Any) -> AsyncIterable["_models.BackupVau def prepare_request(next_link=None): if not next_link: - request = build_get_in_subscription_request( + _request = build_get_in_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_in_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 @@ -111,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("BackupVaultResourceList", pipeline_response) @@ -127,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 @@ -143,10 +142,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - get_in_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/backupVaults" - } - @distributed_trace def get_in_resource_group( self, resource_group_name: str, **kwargs: Any @@ -156,7 +151,6 @@ def get_in_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BackupVaultResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.BackupVaultResource] @@ -168,7 +162,7 @@ def get_in_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackupVaultResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -179,16 +173,14 @@ def get_in_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_get_in_resource_group_request( + _request = build_get_in_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_in_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 @@ -200,13 +192,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("BackupVaultResourceList", pipeline_response) @@ -216,11 +207,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 @@ -232,10 +223,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - get_in_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults" - } - @distributed_trace_async async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _models.BackupVaultResource: """Returns a resource belonging to a resource group. @@ -245,12 +232,11 @@ async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BackupVaultResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BackupVaultResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -264,21 +250,19 @@ async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackupVaultResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_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 @@ -287,25 +271,22 @@ async def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BackupVaultResource", pipeline_response) + deserialized = self._deserialize("BackupVaultResource", 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.DataProtection/backupVaults/{vaultName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, vault_name: str, - parameters: Union[_models.BackupVaultResource, IO], + parameters: Union[_models.BackupVaultResource, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any - ) -> _models.BackupVaultResource: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -318,7 +299,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.BackupVaultResource] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -328,53 +309,50 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "BackupVaultResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("BackupVaultResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 201: - deserialized = self._deserialize("BackupVaultResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}" - } - @overload async def begin_create_or_update( self, resource_group_name: str, vault_name: str, parameters: _models.BackupVaultResource, + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -388,17 +366,11 @@ async def begin_create_or_update( :type vault_name: str :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.BackupVaultResource + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either BackupVaultResource or the result of cls(response) :rtype: @@ -411,7 +383,8 @@ async def begin_create_or_update( self, resource_group_name: str, vault_name: str, - parameters: IO, + parameters: IO[bytes], + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -424,18 +397,12 @@ async def begin_create_or_update( :param vault_name: The name of the backup vault. Required. :type vault_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either BackupVaultResource or the result of cls(response) :rtype: @@ -448,7 +415,8 @@ async def begin_create_or_update( self, resource_group_name: str, vault_name: str, - parameters: Union[_models.BackupVaultResource, IO], + parameters: Union[_models.BackupVaultResource, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[_models.BackupVaultResource]: """Creates or updates a BackupVault resource belonging to a resource group. @@ -458,20 +426,11 @@ async def begin_create_or_update( :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_name: str - :param parameters: Request body for operation. Is either a BackupVaultResource type or a IO - type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.BackupVaultResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Request body for operation. Is either a BackupVaultResource type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.BackupVaultResource or IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :return: An instance of AsyncLROPoller that returns either BackupVaultResource or the result of cls(response) :rtype: @@ -492,6 +451,7 @@ async def begin_create_or_update( resource_group_name=resource_group_name, vault_name=vault_name, parameters=parameters, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -499,12 +459,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BackupVaultResource", pipeline_response) + deserialized = self._deserialize("BackupVaultResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -514,22 +475,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BackupVaultResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}" - } + return AsyncLROPoller[_models.BackupVaultResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> None: - error_map = { + async def _delete_initial(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -541,37 +498,43 @@ 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, vault_name=vault_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 + _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]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + + if response.status_code == 202: + deserialized = response.stream_download(self._client._pipeline) + + if response.status_code == 204: + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -582,14 +545,6 @@ async def begin_delete(self, resource_group_name: str, vault_name: str, **kwargs :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_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: @@ -603,7 +558,7 @@ async def begin_delete(self, resource_group_name: str, vault_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 = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, vault_name=vault_name, api_version=api_version, @@ -612,11 +567,12 @@ async def begin_delete(self, resource_group_name: str, vault_name: str, **kwargs params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -625,26 +581,23 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _update_initial( self, resource_group_name: str, vault_name: str, - parameters: Union[_models.PatchResourceRequestInput, IO], + parameters: Union[_models.PatchResourceRequestInput, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.BackupVaultResource]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -657,7 +610,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.BackupVaultResource]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -667,44 +620,42 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "PatchResourceRequestInput") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize("BackupVaultResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) - if cls: - return cls(pipeline_response, deserialized, {}) + if response.status_code == 202: + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -712,6 +663,7 @@ async def begin_update( resource_group_name: str, vault_name: str, parameters: _models.PatchResourceRequestInput, + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -726,17 +678,11 @@ async def begin_update( :type vault_name: str :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceRequestInput + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either BackupVaultResource or the result of cls(response) :rtype: @@ -749,7 +695,8 @@ async def begin_update( self, resource_group_name: str, vault_name: str, - parameters: IO, + parameters: IO[bytes], + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -763,18 +710,12 @@ async def begin_update( :param vault_name: The name of the backup vault. Required. :type vault_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either BackupVaultResource or the result of cls(response) :rtype: @@ -787,7 +728,8 @@ async def begin_update( self, resource_group_name: str, vault_name: str, - parameters: Union[_models.PatchResourceRequestInput, IO], + parameters: Union[_models.PatchResourceRequestInput, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[_models.BackupVaultResource]: """Updates a BackupVault resource belonging to a resource group. For example, updating tags for a @@ -799,19 +741,10 @@ async def begin_update( :param vault_name: The name of the backup vault. Required. :type vault_name: str :param parameters: Request body for operation. Is either a PatchResourceRequestInput type or a - IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceRequestInput or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceRequestInput or IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :return: An instance of AsyncLROPoller that returns either BackupVaultResource or the result of cls(response) :rtype: @@ -832,6 +765,7 @@ async def begin_update( resource_group_name=resource_group_name, vault_name=vault_name, parameters=parameters, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -839,12 +773,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("BackupVaultResource", pipeline_response) + deserialized = self._deserialize("BackupVaultResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -854,17 +789,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BackupVaultResource].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.DataProtection/backupVaults/{vaultName}" - } + return AsyncLROPoller[_models.BackupVaultResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @overload async def check_name_availability( @@ -890,7 +823,6 @@ async def check_name_availability( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -901,7 +833,7 @@ async def check_name_availability( self, resource_group_name: str, location: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -916,11 +848,10 @@ async def check_name_availability( :param location: The location in which uniqueness will be verified. Required. :type location: str :param parameters: Check name availability request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -931,7 +862,7 @@ async def check_name_availability( self, resource_group_name: str, location: str, - parameters: Union[_models.CheckNameAvailabilityRequest, IO], + parameters: Union[_models.CheckNameAvailabilityRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """API to check for resource name availability. @@ -944,17 +875,13 @@ async def check_name_availability( :param location: The location in which uniqueness will be verified. Required. :type location: str :param parameters: Check name availability request. Is either a CheckNameAvailabilityRequest - type or a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityRequest or IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -977,7 +904,7 @@ async def check_name_availability( else: _json = self._serialize.body(parameters, "CheckNameAvailabilityRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, location=location, subscription_id=self._config.subscription_id, @@ -985,16 +912,14 @@ async def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1003,13 +928,9 @@ async def check_name_availability( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_data_protection_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_data_protection_operations.py index d6c58de38cec..c55821448460 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_data_protection_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_data_protection_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, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._data_protection_operations import build_check_feature_support_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +74,6 @@ async def check_feature_support( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FeatureValidationResponseBase or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.FeatureValidationResponseBase :raises ~azure.core.exceptions.HttpResponseError: @@ -79,7 +81,7 @@ async def check_feature_support( @overload async def check_feature_support( - self, location: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.FeatureValidationResponseBase: """Validates if a feature is supported. @@ -88,11 +90,10 @@ async def check_feature_support( :param location: Required. :type location: str :param parameters: Feature support request 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 :return: FeatureValidationResponseBase or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.FeatureValidationResponseBase :raises ~azure.core.exceptions.HttpResponseError: @@ -100,7 +101,7 @@ async def check_feature_support( @distributed_trace_async async def check_feature_support( - self, location: str, parameters: Union[_models.FeatureValidationRequestBase, IO], **kwargs: Any + self, location: str, parameters: Union[_models.FeatureValidationRequestBase, IO[bytes]], **kwargs: Any ) -> _models.FeatureValidationResponseBase: """Validates if a feature is supported. @@ -109,17 +110,13 @@ async def check_feature_support( :param location: Required. :type location: str :param parameters: Feature support request object. Is either a FeatureValidationRequestBase - type or a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.FeatureValidationRequestBase or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.FeatureValidationRequestBase or IO[bytes] :return: FeatureValidationResponseBase or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.FeatureValidationResponseBase :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -142,23 +139,21 @@ async def check_feature_support( else: _json = self._serialize.body(parameters, "FeatureValidationRequestBase") - request = build_check_feature_support_request( + _request = build_check_feature_support_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_feature_support.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -167,13 +162,9 @@ async def check_feature_support( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("FeatureValidationResponseBase", pipeline_response) + deserialized = self._deserialize("FeatureValidationResponseBase", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_feature_support.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/checkFeatureSupport" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_data_protection_operations_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_data_protection_operations_operations.py index 345e0d4d1f75..75b131208523 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_data_protection_operations_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_data_protection_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._data_protection_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.ClientDiscoveryValueForSingleApi"]: """Returns the list of available operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ClientDiscoveryValueForSingleApi or the result of cls(response) :rtype: @@ -69,7 +71,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ClientDiscoveryValueForS api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ClientDiscoveryResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +82,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ClientDiscoveryValueForS 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 @@ -99,13 +99,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("ClientDiscoveryResponse", pipeline_response) @@ -115,11 +114,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -130,5 +129,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.DataProtection/operations"} diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_deleted_backup_instances_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_deleted_backup_instances_operations.py index 1cc65d1f39c8..0ef91094145f 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_deleted_backup_instances_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_deleted_backup_instances_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, Union, cast +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, Optional, Type, TypeVar, Union, cast import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,9 +20,8 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,13 +29,16 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._deleted_backup_instances_operations import ( build_get_request, build_list_request, build_undelete_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]] @@ -70,7 +73,6 @@ def list( :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedBackupInstanceResource or the result of cls(response) :rtype: @@ -83,7 +85,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DeletedBackupInstanceResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,17 +96,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, vault_name=vault_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -116,13 +116,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DeletedBackupInstanceResourceList", pipeline_response) @@ -132,11 +131,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -148,10 +147,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances" - } - @distributed_trace_async async def get( self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any @@ -165,12 +160,11 @@ async def get( :type vault_name: str :param backup_instance_name: The name of the deleted backup instance. Required. :type backup_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedBackupInstanceResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DeletedBackupInstanceResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -184,22 +178,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DeletedBackupInstanceResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -208,21 +200,17 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DeletedBackupInstanceResource", pipeline_response) + deserialized = self._deserialize("DeletedBackupInstanceResource", 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.DataProtection/backupVaults/{vaultName}/deletedBackupInstances/{backupInstanceName}" - } + return deserialized # type: ignore - async def _undelete_initial( # pylint: disable=inconsistent-return-statements + async def _undelete_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -234,38 +222,41 @@ async def _undelete_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_undelete_request( + _request = build_undelete_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._undelete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + + if response.status_code == 202: + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _undelete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances/{backupInstanceName}/undelete" - } + return deserialized # type: ignore @distributed_trace_async async def begin_undelete( @@ -280,14 +271,6 @@ async def begin_undelete( :type vault_name: str :param backup_instance_name: The name of the deleted backup instance. Required. :type backup_instance_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: @@ -301,7 +284,7 @@ async def begin_undelete( 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._undelete_initial( # type: ignore + raw_result = await self._undelete_initial( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -311,11 +294,12 @@ async def begin_undelete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -324,14 +308,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_undelete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances/{backupInstanceName}/undelete" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_dpp_resource_guard_proxy_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_dpp_resource_guard_proxy_operations.py index b2c4a9d8f8d6..0d8ad39defac 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_dpp_resource_guard_proxy_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_dpp_resource_guard_proxy_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, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._dpp_resource_guard_proxy_operations import ( build_create_or_update_request, build_delete_request, @@ -37,6 +36,10 @@ build_unlock_delete_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 +76,6 @@ def list( :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceGuardProxyBaseResource or the result of cls(response) :rtype: @@ -86,7 +88,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceGuardProxyBaseResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,17 +99,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, vault_name=vault_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 @@ -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 async def extract_data(pipeline_response): deserialized = self._deserialize("ResourceGuardProxyBaseResourceList", pipeline_response) @@ -135,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 @@ -151,10 +150,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies" - } - @distributed_trace_async async def get( self, resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, **kwargs: Any @@ -172,12 +167,11 @@ async def get( :type vault_name: str :param resource_guard_proxy_name: name of the resource guard proxy. Required. :type resource_guard_proxy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceGuardProxyBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -191,22 +185,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceGuardProxyBaseResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, resource_guard_proxy_name=resource_guard_proxy_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 @@ -215,16 +207,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ResourceGuardProxyBaseResource", pipeline_response) + deserialized = self._deserialize("ResourceGuardProxyBaseResource", 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.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -253,7 +241,6 @@ async def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceGuardProxyBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource :raises ~azure.core.exceptions.HttpResponseError: @@ -265,7 +252,7 @@ async def create_or_update( resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -282,11 +269,10 @@ async def create_or_update( :param resource_guard_proxy_name: name of the resource guard proxy. Required. :type resource_guard_proxy_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceGuardProxyBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource :raises ~azure.core.exceptions.HttpResponseError: @@ -298,7 +284,7 @@ async def create_or_update( resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, - parameters: Union[_models.ResourceGuardProxyBaseResource, IO], + parameters: Union[_models.ResourceGuardProxyBaseResource, IO[bytes]], **kwargs: Any ) -> _models.ResourceGuardProxyBaseResource: """Creates or Updates a ResourceGuardProxy. @@ -313,17 +299,13 @@ async def create_or_update( :param resource_guard_proxy_name: name of the resource guard proxy. Required. :type resource_guard_proxy_name: str :param parameters: Request body for operation. Is either a ResourceGuardProxyBaseResource type - or a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource or IO[bytes] :return: ResourceGuardProxyBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -346,7 +328,7 @@ async def create_or_update( else: _json = self._serialize.body(parameters, "ResourceGuardProxyBaseResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, vault_name=vault_name, resource_guard_proxy_name=resource_guard_proxy_name, @@ -355,16 +337,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -373,16 +353,12 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ResourceGuardProxyBaseResource", pipeline_response) + deserialized = self._deserialize("ResourceGuardProxyBaseResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -399,12 +375,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type vault_name: str :param resource_guard_proxy_name: name of the resource guard proxy. Required. :type resource_guard_proxy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -418,22 +393,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, vault_name=vault_name, resource_guard_proxy_name=resource_guard_proxy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -443,11 +416,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def unlock_delete( @@ -456,6 +425,7 @@ async def unlock_delete( vault_name: str, resource_guard_proxy_name: str, parameters: _models.UnlockDeleteRequest, + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -473,10 +443,11 @@ async def unlock_delete( :type resource_guard_proxy_name: str :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.UnlockDeleteRequest + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: UnlockDeleteResponse or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -488,7 +459,8 @@ async def unlock_delete( resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, - parameters: IO, + parameters: IO[bytes], + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -505,11 +477,12 @@ async def unlock_delete( :param resource_guard_proxy_name: name of the resource guard proxy. Required. :type resource_guard_proxy_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: UnlockDeleteResponse or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -521,7 +494,8 @@ async def unlock_delete( resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, - parameters: Union[_models.UnlockDeleteRequest, IO], + parameters: Union[_models.UnlockDeleteRequest, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any ) -> _models.UnlockDeleteResponse: """UnlockDelete call for ResourceGuardProxy, executed before one can delete it. @@ -535,18 +509,16 @@ async def unlock_delete( :type vault_name: str :param resource_guard_proxy_name: name of the resource guard proxy. Required. :type resource_guard_proxy_name: str - :param parameters: Request body for operation. Is either a UnlockDeleteRequest type or a IO - type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.UnlockDeleteRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: Request body for operation. Is either a UnlockDeleteRequest type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.UnlockDeleteRequest or IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :return: UnlockDeleteResponse or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -569,25 +541,24 @@ async def unlock_delete( else: _json = self._serialize.body(parameters, "UnlockDeleteRequest") - request = build_unlock_delete_request( + _request = build_unlock_delete_request( resource_group_name=resource_group_name, vault_name=vault_name, resource_guard_proxy_name=resource_guard_proxy_name, subscription_id=self._config.subscription_id, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.unlock_delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -596,13 +567,9 @@ async def unlock_delete( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("UnlockDeleteResponse", pipeline_response) + deserialized = self._deserialize("UnlockDeleteResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - unlock_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}/unlockDelete" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_export_jobs_operation_result_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_export_jobs_operation_result_operations.py index ebe41aa48e6b..ff33c73ad06a 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_export_jobs_operation_result_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_export_jobs_operation_result_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._export_jobs_operation_result_operations import build_get_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]] @@ -65,12 +68,11 @@ async def get( :type vault_name: str :param operation_id: OperationID which represents the export job. Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ExportJobsResult or None or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ExportJobsResult or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,22 +86,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.ExportJobsResult]] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -110,13 +110,9 @@ async def get( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("ExportJobsResult", pipeline_response) + deserialized = self._deserialize("ExportJobsResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs/operations/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_export_jobs_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_export_jobs_operations.py index 014d94bbc1d4..4bdd976c2a8f 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_export_jobs_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_export_jobs_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, Union, cast +import sys +from typing import Any, AsyncIterator, Callable, Dict, Optional, Type, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,18 +18,20 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._export_jobs_operations import build_trigger_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]] @@ -52,10 +55,8 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _trigger_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> None: - error_map = { + async def _trigger_initial(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -67,28 +68,27 @@ async def _trigger_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_trigger_request( + _request = build_trigger_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._trigger_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -97,12 +97,15 @@ async def _trigger_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline) + + if response.status_code == 204: + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _trigger_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/exportBackupJobs" - } + return deserialized # type: ignore @distributed_trace_async async def begin_trigger(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -113,14 +116,6 @@ async def begin_trigger(self, resource_group_name: str, vault_name: str, **kwarg :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_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: @@ -134,7 +129,7 @@ async def begin_trigger(self, resource_group_name: str, vault_name: str, **kwarg 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._trigger_initial( # type: ignore + raw_result = await self._trigger_initial( resource_group_name=resource_group_name, vault_name=vault_name, api_version=api_version, @@ -143,11 +138,12 @@ async def begin_trigger(self, resource_group_name: str, vault_name: str, **kwarg 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( @@ -158,14 +154,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_trigger.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/exportBackupJobs" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_fetch_cross_region_restore_job_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_fetch_cross_region_restore_job_operations.py index 6cba32e15ad2..207da5e64dbc 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_fetch_cross_region_restore_job_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_fetch_cross_region_restore_job_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, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,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._fetch_cross_region_restore_job_operations import build_get_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 +76,6 @@ async def get( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AzureBackupJobResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupJobResource :raises ~azure.core.exceptions.HttpResponseError: @@ -84,7 +86,7 @@ async def get( self, resource_group_name: str, location: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -97,11 +99,10 @@ async def get( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AzureBackupJobResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupJobResource :raises ~azure.core.exceptions.HttpResponseError: @@ -112,7 +113,7 @@ async def get( self, resource_group_name: str, location: str, - parameters: Union[_models.CrossRegionRestoreJobRequest, IO], + parameters: Union[_models.CrossRegionRestoreJobRequest, IO[bytes]], **kwargs: Any ) -> _models.AzureBackupJobResource: """Fetches the Cross Region Restore Job. @@ -123,17 +124,13 @@ async def get( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for operation. Is either a CrossRegionRestoreJobRequest type or - a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.CrossRegionRestoreJobRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.CrossRegionRestoreJobRequest or IO[bytes] :return: AzureBackupJobResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupJobResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -156,7 +153,7 @@ async def get( else: _json = self._serialize.body(parameters, "CrossRegionRestoreJobRequest") - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, location=location, subscription_id=self._config.subscription_id, @@ -164,16 +161,14 @@ async def get( content_type=content_type, json=_json, content=_content, - 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 @@ -182,13 +177,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AzureBackupJobResource", pipeline_response) + deserialized = self._deserialize("AzureBackupJobResource", 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.DataProtection/locations/{location}/fetchCrossRegionRestoreJob" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_fetch_cross_region_restore_jobs_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_fetch_cross_region_restore_jobs_operations.py index f168b57b95dd..78ae749bacd2 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_fetch_cross_region_restore_jobs_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_fetch_cross_region_restore_jobs_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, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,16 +21,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._fetch_cross_region_restore_jobs_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]] @@ -78,7 +81,6 @@ def list( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureBackupJobResource or the result of cls(response) :rtype: @@ -91,7 +93,7 @@ def list( self, resource_group_name: str, location: str, - parameters: IO, + parameters: IO[bytes], filter: Optional[str] = None, *, content_type: str = "application/json", @@ -105,13 +107,12 @@ def list( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param filter: OData filter options. Default value is None. :type filter: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureBackupJobResource or the result of cls(response) :rtype: @@ -124,7 +125,7 @@ def list( self, resource_group_name: str, location: str, - parameters: Union[_models.CrossRegionRestoreJobsRequest, IO], + parameters: Union[_models.CrossRegionRestoreJobsRequest, IO[bytes]], filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AzureBackupJobResource"]: @@ -136,14 +137,10 @@ def list( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for operation. Is either a CrossRegionRestoreJobsRequest type - or a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.CrossRegionRestoreJobsRequest or IO + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.CrossRegionRestoreJobsRequest or IO[bytes] :param filter: OData filter options. Default value is None. :type filter: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureBackupJobResource or the result of cls(response) :rtype: @@ -157,7 +154,7 @@ def list( content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AzureBackupJobResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -175,7 +172,7 @@ 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, location=location, subscription_id=self._config.subscription_id, @@ -184,12 +181,10 @@ def prepare_request(next_link=None): content_type=content_type, json=_json, content=_content, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -201,13 +196,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("AzureBackupJobResourceList", pipeline_response) @@ -217,11 +211,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 @@ -232,7 +226,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.DataProtection/locations/{location}/fetchCrossRegionRestoreJobs" - } diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_fetch_secondary_recovery_points_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_fetch_secondary_recovery_points_operations.py index bbd21b972195..e224e672a26c 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_fetch_secondary_recovery_points_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_fetch_secondary_recovery_points_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, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,16 +21,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._fetch_secondary_recovery_points_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]] @@ -82,7 +85,6 @@ def list( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureBackupRecoveryPointResource or the result of cls(response) :rtype: @@ -95,7 +97,7 @@ def list( self, resource_group_name: str, location: str, - parameters: IO, + parameters: IO[bytes], filter: Optional[str] = None, skip_token: Optional[str] = None, *, @@ -111,7 +113,7 @@ def list( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param filter: OData filter options. Default value is None. :type filter: str :param skip_token: skipToken Filter. Default value is None. @@ -119,7 +121,6 @@ def list( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureBackupRecoveryPointResource or the result of cls(response) :rtype: @@ -132,7 +133,7 @@ def list( self, resource_group_name: str, location: str, - parameters: Union[_models.FetchSecondaryRPsRequestParameters, IO], + parameters: Union[_models.FetchSecondaryRPsRequestParameters, IO[bytes]], filter: Optional[str] = None, skip_token: Optional[str] = None, **kwargs: Any @@ -146,16 +147,13 @@ def list( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for operation. Is either a FetchSecondaryRPsRequestParameters - type or a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.FetchSecondaryRPsRequestParameters or IO + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.FetchSecondaryRPsRequestParameters or + IO[bytes] :param filter: OData filter options. Default value is None. :type filter: str :param skip_token: skipToken Filter. Default value is None. :type skip_token: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureBackupRecoveryPointResource or the result of cls(response) :rtype: @@ -169,7 +167,7 @@ def list( content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AzureBackupRecoveryPointResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,7 +185,7 @@ 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, location=location, subscription_id=self._config.subscription_id, @@ -197,12 +195,10 @@ def prepare_request(next_link=None): content_type=content_type, json=_json, content=_content, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -214,13 +210,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("AzureBackupRecoveryPointResourceList", pipeline_response) @@ -230,11 +225,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 @@ -245,7 +240,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.DataProtection/locations/{location}/fetchSecondaryRecoveryPoints" - } diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_jobs_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_jobs_operations.py index 2a959e7644e1..3760b1caec6d 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_jobs_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_jobs_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,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._jobs_operations import build_get_request, build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,7 +67,6 @@ def list( :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureBackupJobResource or the result of cls(response) :rtype: @@ -77,7 +79,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AzureBackupJobResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,17 +90,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, vault_name=vault_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 @@ -110,13 +110,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("AzureBackupJobResourceList", pipeline_response) @@ -126,11 +125,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,10 +141,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs" - } - @distributed_trace_async async def get( self, resource_group_name: str, vault_name: str, job_id: str, **kwargs: Any @@ -160,12 +155,11 @@ async def get( :param job_id: The Job ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). Required. :type job_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AzureBackupJobResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupJobResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -179,22 +173,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AzureBackupJobResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, job_id=job_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -203,13 +195,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AzureBackupJobResource", pipeline_response) + deserialized = self._deserialize("AzureBackupJobResource", 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.DataProtection/backupVaults/{vaultName}/backupJobs/{jobId}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_result_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_result_operations.py index ca45f75b3e43..ac8fe95df15e 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_result_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_result_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._operation_result_operations import build_get_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]] @@ -60,12 +63,11 @@ async def get(self, operation_id: str, location: str, **kwargs: Any) -> Optional :type operation_id: str :param location: Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationJobExtendedInfo or None or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.OperationJobExtendedInfo or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,21 +81,19 @@ async def get(self, operation_id: str, location: str, **kwargs: Any) -> Optional api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.OperationJobExtendedInfo]] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( operation_id=operation_id, location=location, 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 @@ -105,7 +105,7 @@ async def get(self, operation_id: str, location: str, **kwargs: Any) -> Optional deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response.http_response) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -115,10 +115,6 @@ async def get(self, operation_id: str, location: str, **kwargs: Any) -> Optional response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/operationResults/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_backup_vault_context_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_backup_vault_context_operations.py index b63ed87f7efd..3cc6d591ddf4 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_backup_vault_context_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_backup_vault_context_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,21 +18,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operation_status_backup_vault_context_operations import build_get_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OperationStatusBackupVaultContextOperations: +class OperationStatusBackupVaultContextOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -65,12 +68,11 @@ async def get( :type vault_name: str :param operation_id: Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.OperationResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,22 +86,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -108,13 +108,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationResource", pipeline_response) + deserialized = self._deserialize("OperationResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/operationStatus/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_operations.py index 1f2a9ff2d137..47cc4e12e9bd 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_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._operation_status_operations import build_get_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]] @@ -60,12 +63,11 @@ async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models. :type location: str :param operation_id: Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.OperationResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,21 +81,19 @@ async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models. api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( location=location, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -102,13 +102,9 @@ async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models. map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationResource", pipeline_response) + deserialized = self._deserialize("OperationResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/operationStatus/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_resource_group_context_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_resource_group_context_operations.py index c88e1e728c2e..cbb094a11bd5 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_resource_group_context_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_operation_status_resource_group_context_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,21 +18,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operation_status_resource_group_context_operations import build_get_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OperationStatusResourceGroupContextOperations: +class OperationStatusResourceGroupContextOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -61,12 +64,11 @@ async def get(self, resource_group_name: str, operation_id: str, **kwargs: Any) :type resource_group_name: str :param operation_id: Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.OperationResource :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 get(self, resource_group_name: str, operation_id: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -103,13 +103,9 @@ async def get(self, resource_group_name: str, operation_id: str, **kwargs: Any) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationResource", pipeline_response) + deserialized = self._deserialize("OperationResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/operationStatus/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_recovery_points_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_recovery_points_operations.py index 3b50b18e7750..9e681a28b0d4 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_recovery_points_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_recovery_points_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,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._recovery_points_operations import build_get_request, build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -76,7 +79,6 @@ def list( :type filter: str :param skip_token: skipToken Filter. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureBackupRecoveryPointResource or the result of cls(response) :rtype: @@ -89,7 +91,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AzureBackupRecoveryPointResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,7 +102,7 @@ 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, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -108,12 +110,10 @@ def prepare_request(next_link=None): filter=filter, skip_token=skip_token, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,13 +125,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("AzureBackupRecoveryPointResourceList", pipeline_response) @@ -141,11 +140,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 @@ -157,10 +156,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/recoveryPoints" - } - @distributed_trace_async async def get( self, @@ -181,12 +176,11 @@ async def get( :type backup_instance_name: str :param recovery_point_id: Required. :type recovery_point_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AzureBackupRecoveryPointResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupRecoveryPointResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -200,23 +194,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AzureBackupRecoveryPointResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, recovery_point_id=recovery_point_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -225,13 +217,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AzureBackupRecoveryPointResource", pipeline_response) + deserialized = self._deserialize("AzureBackupRecoveryPointResource", 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.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/recoveryPoints/{recoveryPointId}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_resource_guards_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_resource_guards_operations.py index 31bd25361b56..b3ffbb0d7c28 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_resource_guards_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_resource_guards_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, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._resource_guards_operations import ( build_delete_request, build_get_backup_security_pin_requests_objects_request, @@ -50,6 +49,10 @@ build_put_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]] @@ -79,7 +82,6 @@ def get_resources_in_subscription(self, **kwargs: Any) -> AsyncIterable["_models Returns ResourceGuards collection belonging to a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceGuardResource or the result of cls(response) :rtype: @@ -92,7 +94,7 @@ def get_resources_in_subscription(self, **kwargs: Any) -> AsyncIterable["_models api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceGuardResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -103,15 +105,13 @@ def get_resources_in_subscription(self, **kwargs: Any) -> AsyncIterable["_models def prepare_request(next_link=None): if not next_link: - request = build_get_resources_in_subscription_request( + _request = build_get_resources_in_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resources_in_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 @@ -123,13 +123,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("ResourceGuardResourceList", pipeline_response) @@ -139,11 +138,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 @@ -155,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - get_resources_in_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/resourceGuards" - } - @distributed_trace def get_resources_in_resource_group( self, resource_group_name: str, **kwargs: Any @@ -170,7 +165,6 @@ def get_resources_in_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceGuardResource or the result of cls(response) :rtype: @@ -183,7 +177,7 @@ def get_resources_in_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceGuardResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,16 +188,14 @@ def get_resources_in_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_get_resources_in_resource_group_request( + _request = build_get_resources_in_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resources_in_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 @@ -215,13 +207,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("ResourceGuardResourceList", pipeline_response) @@ -231,11 +222,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 @@ -247,10 +238,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - get_resources_in_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards" - } - @overload async def put( self, @@ -275,7 +262,6 @@ async def put( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource :raises ~azure.core.exceptions.HttpResponseError: @@ -286,7 +272,7 @@ async def put( self, resource_group_name: str, resource_guards_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -301,11 +287,10 @@ async def put( :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource :raises ~azure.core.exceptions.HttpResponseError: @@ -316,7 +301,7 @@ async def put( self, resource_group_name: str, resource_guards_name: str, - parameters: Union[_models.ResourceGuardResource, IO], + parameters: Union[_models.ResourceGuardResource, IO[bytes]], **kwargs: Any ) -> _models.ResourceGuardResource: """Creates or updates a ResourceGuard resource belonging to a resource group. @@ -328,18 +313,14 @@ async def put( :type resource_group_name: str :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str - :param parameters: Request body for operation. Is either a ResourceGuardResource type or a IO - type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: Request body for operation. Is either a ResourceGuardResource type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardResource or IO[bytes] :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -362,7 +343,7 @@ async def put( else: _json = self._serialize.body(parameters, "ResourceGuardResource") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, @@ -370,16 +351,14 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -389,20 +368,16 @@ async def put( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("ResourceGuardResource", pipeline_response) + deserialized = self._deserialize("ResourceGuardResource", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("ResourceGuardResource", pipeline_response) + deserialized = self._deserialize("ResourceGuardResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}" - } - @distributed_trace_async async def get( self, resource_group_name: str, resource_guards_name: str, **kwargs: Any @@ -416,12 +391,11 @@ async def get( :type resource_group_name: str :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -435,21 +409,19 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceGuardResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_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 @@ -458,16 +430,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ResourceGuardResource", pipeline_response) + deserialized = self._deserialize("ResourceGuardResource", 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.DataProtection/resourceGuards/{resourceGuardsName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -482,12 +450,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -501,21 +468,19 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -525,11 +490,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def patch( @@ -557,7 +518,6 @@ async def patch( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource :raises ~azure.core.exceptions.HttpResponseError: @@ -568,7 +528,7 @@ async def patch( self, resource_group_name: str, resource_guards_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -585,11 +545,10 @@ async def patch( :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource :raises ~azure.core.exceptions.HttpResponseError: @@ -600,7 +559,7 @@ async def patch( self, resource_group_name: str, resource_guards_name: str, - parameters: Union[_models.PatchResourceGuardInput, IO], + parameters: Union[_models.PatchResourceGuardInput, IO[bytes]], **kwargs: Any ) -> _models.ResourceGuardResource: """Updates a ResourceGuard resource belonging to a resource group. For example, updating tags for @@ -614,18 +573,14 @@ async def patch( :type resource_group_name: str :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str - :param parameters: Request body for operation. Is either a PatchResourceGuardInput type or a IO - type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceGuardInput or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: Request body for operation. Is either a PatchResourceGuardInput type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceGuardInput or IO[bytes] :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -648,7 +603,7 @@ async def patch( else: _json = self._serialize.body(parameters, "PatchResourceGuardInput") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, @@ -656,16 +611,14 @@ async def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -674,16 +627,12 @@ async def patch( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ResourceGuardResource", pipeline_response) + deserialized = self._deserialize("ResourceGuardResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}" - } + return deserialized # type: ignore @distributed_trace def get_disable_soft_delete_requests_objects( @@ -700,7 +649,6 @@ def get_disable_soft_delete_requests_objects( :type resource_group_name: str :param resource_guards_name: Required. :type resource_guards_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DppBaseResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] @@ -712,7 +660,7 @@ def get_disable_soft_delete_requests_objects( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -723,17 +671,15 @@ def get_disable_soft_delete_requests_objects( def prepare_request(next_link=None): if not next_link: - request = build_get_disable_soft_delete_requests_objects_request( + _request = build_get_disable_soft_delete_requests_objects_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_disable_soft_delete_requests_objects.metadata["url"], 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 @@ -745,13 +691,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("DppBaseResourceList", pipeline_response) @@ -761,11 +706,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 @@ -777,12 +722,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - get_disable_soft_delete_requests_objects.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/disableSoftDeleteRequests" - } - @distributed_trace - def get_delete_resource_guard_proxy_requests_objects( + def get_delete_resource_guard_proxy_requests_objects( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, **kwargs: Any ) -> AsyncIterable["_models.DppBaseResource"]: """Returns collection of operation request objects for a critical operation protected by the given @@ -796,7 +737,6 @@ def get_delete_resource_guard_proxy_requests_objects( :type resource_group_name: str :param resource_guards_name: Required. :type resource_guards_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DppBaseResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] @@ -808,7 +748,7 @@ def get_delete_resource_guard_proxy_requests_objects( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -819,17 +759,15 @@ def get_delete_resource_guard_proxy_requests_objects( def prepare_request(next_link=None): if not next_link: - request = build_get_delete_resource_guard_proxy_requests_objects_request( + _request = build_get_delete_resource_guard_proxy_requests_objects_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_delete_resource_guard_proxy_requests_objects.metadata["url"], 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 @@ -841,13 +779,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("DppBaseResourceList", pipeline_response) @@ -857,11 +794,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 @@ -873,10 +810,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - get_delete_resource_guard_proxy_requests_objects.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteResourceGuardProxyRequests" - } - @distributed_trace def get_backup_security_pin_requests_objects( self, resource_group_name: str, resource_guards_name: str, **kwargs: Any @@ -892,7 +825,6 @@ def get_backup_security_pin_requests_objects( :type resource_group_name: str :param resource_guards_name: Required. :type resource_guards_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DppBaseResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] @@ -904,7 +836,7 @@ def get_backup_security_pin_requests_objects( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -915,17 +847,15 @@ def get_backup_security_pin_requests_objects( def prepare_request(next_link=None): if not next_link: - request = build_get_backup_security_pin_requests_objects_request( + _request = build_get_backup_security_pin_requests_objects_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_backup_security_pin_requests_objects.metadata["url"], 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 @@ -937,13 +867,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("DppBaseResourceList", pipeline_response) @@ -953,11 +882,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 @@ -969,12 +898,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - get_backup_security_pin_requests_objects.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/getBackupSecurityPINRequests" - } - @distributed_trace - def get_delete_protected_item_requests_objects( + def get_delete_protected_item_requests_objects( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, **kwargs: Any ) -> AsyncIterable["_models.DppBaseResource"]: """Returns collection of operation request objects for a critical operation protected by the given @@ -988,7 +913,6 @@ def get_delete_protected_item_requests_objects( :type resource_group_name: str :param resource_guards_name: Required. :type resource_guards_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DppBaseResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] @@ -1000,7 +924,7 @@ def get_delete_protected_item_requests_objects( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1011,17 +935,15 @@ def get_delete_protected_item_requests_objects( def prepare_request(next_link=None): if not next_link: - request = build_get_delete_protected_item_requests_objects_request( + _request = build_get_delete_protected_item_requests_objects_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_delete_protected_item_requests_objects.metadata["url"], 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 @@ -1033,13 +955,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("DppBaseResourceList", pipeline_response) @@ -1049,11 +970,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 @@ -1065,12 +986,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - get_delete_protected_item_requests_objects.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteProtectedItemRequests" - } - @distributed_trace - def get_update_protection_policy_requests_objects( + def get_update_protection_policy_requests_objects( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, **kwargs: Any ) -> AsyncIterable["_models.DppBaseResource"]: """Returns collection of operation request objects for a critical operation protected by the given @@ -1084,7 +1001,6 @@ def get_update_protection_policy_requests_objects( :type resource_group_name: str :param resource_guards_name: Required. :type resource_guards_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DppBaseResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] @@ -1096,7 +1012,7 @@ def get_update_protection_policy_requests_objects( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1107,17 +1023,15 @@ def get_update_protection_policy_requests_objects( def prepare_request(next_link=None): if not next_link: - request = build_get_update_protection_policy_requests_objects_request( + _request = build_get_update_protection_policy_requests_objects_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_update_protection_policy_requests_objects.metadata["url"], 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 @@ -1129,13 +1043,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("DppBaseResourceList", pipeline_response) @@ -1145,11 +1058,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 @@ -1161,12 +1074,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - get_update_protection_policy_requests_objects.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectionPolicyRequests" - } - @distributed_trace - def get_update_protected_item_requests_objects( + def get_update_protected_item_requests_objects( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, **kwargs: Any ) -> AsyncIterable["_models.DppBaseResource"]: """Returns collection of operation request objects for a critical operation protected by the given @@ -1180,7 +1089,6 @@ def get_update_protected_item_requests_objects( :type resource_group_name: str :param resource_guards_name: Required. :type resource_guards_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DppBaseResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] @@ -1192,7 +1100,7 @@ def get_update_protected_item_requests_objects( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1203,17 +1111,15 @@ def get_update_protected_item_requests_objects( def prepare_request(next_link=None): if not next_link: - request = build_get_update_protected_item_requests_objects_request( + _request = build_get_update_protected_item_requests_objects_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_update_protected_item_requests_objects.metadata["url"], 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 @@ -1225,13 +1131,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("DppBaseResourceList", pipeline_response) @@ -1241,11 +1146,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 @@ -1257,12 +1162,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - get_update_protected_item_requests_objects.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectedItemRequests" - } - @distributed_trace_async - async def get_default_disable_soft_delete_requests_object( + async def get_default_disable_soft_delete_requests_object( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any ) -> _models.DppBaseResource: """Returns collection of operation request objects for a critical operation protected by the given @@ -1278,12 +1179,11 @@ async def get_default_disable_soft_delete_requests_object( :type resource_guards_name: str :param request_name: Required. :type request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1297,22 +1197,20 @@ async def get_default_disable_soft_delete_requests_object( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResource] = kwargs.pop("cls", None) - request = build_get_default_disable_soft_delete_requests_object_request( + _request = build_get_default_disable_soft_delete_requests_object_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, request_name=request_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_default_disable_soft_delete_requests_object.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -1321,19 +1219,15 @@ async def get_default_disable_soft_delete_requests_object( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DppBaseResource", pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_default_disable_soft_delete_requests_object.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/disableSoftDeleteRequests/{requestName}" - } + return deserialized # type: ignore @distributed_trace_async - async def get_default_delete_resource_guard_proxy_requests_object( + async def get_default_delete_resource_guard_proxy_requests_object( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any ) -> _models.DppBaseResource: """Returns collection of operation request objects for a critical operation protected by the given @@ -1349,12 +1243,11 @@ async def get_default_delete_resource_guard_proxy_requests_object( :type resource_guards_name: str :param request_name: Required. :type request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1368,22 +1261,20 @@ async def get_default_delete_resource_guard_proxy_requests_object( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResource] = kwargs.pop("cls", None) - request = build_get_default_delete_resource_guard_proxy_requests_object_request( + _request = build_get_default_delete_resource_guard_proxy_requests_object_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, request_name=request_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_default_delete_resource_guard_proxy_requests_object.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -1392,19 +1283,15 @@ async def get_default_delete_resource_guard_proxy_requests_object( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DppBaseResource", pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_default_delete_resource_guard_proxy_requests_object.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteResourceGuardProxyRequests/{requestName}" - } + return deserialized # type: ignore @distributed_trace_async - async def get_default_backup_security_pin_requests_object( + async def get_default_backup_security_pin_requests_object( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any ) -> _models.DppBaseResource: """Returns collection of operation request objects for a critical operation protected by the given @@ -1420,12 +1307,11 @@ async def get_default_backup_security_pin_requests_object( :type resource_guards_name: str :param request_name: Required. :type request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1439,22 +1325,20 @@ async def get_default_backup_security_pin_requests_object( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResource] = kwargs.pop("cls", None) - request = build_get_default_backup_security_pin_requests_object_request( + _request = build_get_default_backup_security_pin_requests_object_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, request_name=request_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_default_backup_security_pin_requests_object.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -1463,19 +1347,15 @@ async def get_default_backup_security_pin_requests_object( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DppBaseResource", pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_default_backup_security_pin_requests_object.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/getBackupSecurityPINRequests/{requestName}" - } + return deserialized # type: ignore @distributed_trace_async - async def get_default_delete_protected_item_requests_object( + async def get_default_delete_protected_item_requests_object( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any ) -> _models.DppBaseResource: """Returns collection of operation request objects for a critical operation protected by the given @@ -1491,12 +1371,11 @@ async def get_default_delete_protected_item_requests_object( :type resource_guards_name: str :param request_name: Required. :type request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1510,22 +1389,20 @@ async def get_default_delete_protected_item_requests_object( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResource] = kwargs.pop("cls", None) - request = build_get_default_delete_protected_item_requests_object_request( + _request = build_get_default_delete_protected_item_requests_object_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, request_name=request_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_default_delete_protected_item_requests_object.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -1534,19 +1411,15 @@ async def get_default_delete_protected_item_requests_object( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DppBaseResource", pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_default_delete_protected_item_requests_object.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteProtectedItemRequests/{requestName}" - } + return deserialized # type: ignore @distributed_trace_async - async def get_default_update_protection_policy_requests_object( + async def get_default_update_protection_policy_requests_object( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any ) -> _models.DppBaseResource: """Returns collection of operation request objects for a critical operation protected by the given @@ -1562,12 +1435,11 @@ async def get_default_update_protection_policy_requests_object( :type resource_guards_name: str :param request_name: Required. :type request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1581,22 +1453,20 @@ async def get_default_update_protection_policy_requests_object( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResource] = kwargs.pop("cls", None) - request = build_get_default_update_protection_policy_requests_object_request( + _request = build_get_default_update_protection_policy_requests_object_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, request_name=request_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_default_update_protection_policy_requests_object.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -1605,19 +1475,15 @@ async def get_default_update_protection_policy_requests_object( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DppBaseResource", pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_default_update_protection_policy_requests_object.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectionPolicyRequests/{requestName}" - } + return deserialized # type: ignore @distributed_trace_async - async def get_default_update_protected_item_requests_object( + async def get_default_update_protected_item_requests_object( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any ) -> _models.DppBaseResource: """Returns collection of operation request objects for a critical operation protected by the given @@ -1633,12 +1499,11 @@ async def get_default_update_protected_item_requests_object( :type resource_guards_name: str :param request_name: Required. :type request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1652,22 +1517,20 @@ async def get_default_update_protected_item_requests_object( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResource] = kwargs.pop("cls", None) - request = build_get_default_update_protected_item_requests_object_request( + _request = build_get_default_update_protected_item_requests_object_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, request_name=request_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_default_update_protected_item_requests_object.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -1676,13 +1539,9 @@ async def get_default_update_protected_item_requests_object( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DppBaseResource", pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_default_update_protected_item_requests_object.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectedItemRequests/{requestName}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_restorable_time_ranges_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_restorable_time_ranges_operations.py index 994419782c93..421737f60d7b 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_restorable_time_ranges_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/aio/operations/_restorable_time_ranges_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, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,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._restorable_time_ranges_operations import build_find_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]] @@ -76,7 +79,6 @@ async def find( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AzureBackupFindRestorableTimeRangesResponseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesResponseResource :raises ~azure.core.exceptions.HttpResponseError: @@ -88,7 +90,7 @@ async def find( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -103,11 +105,10 @@ async def find( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AzureBackupFindRestorableTimeRangesResponseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesResponseResource :raises ~azure.core.exceptions.HttpResponseError: @@ -119,7 +120,7 @@ async def find( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.AzureBackupFindRestorableTimeRangesRequest, IO], + parameters: Union[_models.AzureBackupFindRestorableTimeRangesRequest, IO[bytes]], **kwargs: Any ) -> _models.AzureBackupFindRestorableTimeRangesResponseResource: """find. @@ -132,18 +133,14 @@ async def find( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Is either a - AzureBackupFindRestorableTimeRangesRequest type or a IO type. Required. + AzureBackupFindRestorableTimeRangesRequest type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesRequest - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: AzureBackupFindRestorableTimeRangesResponseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesResponseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -166,7 +163,7 @@ async def find( else: _json = self._serialize.body(parameters, "AzureBackupFindRestorableTimeRangesRequest") - request = build_find_request( + _request = build_find_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -175,16 +172,14 @@ async def find( content_type=content_type, json=_json, content=_content, - template_url=self.find.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -193,13 +188,11 @@ async def find( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AzureBackupFindRestorableTimeRangesResponseResource", pipeline_response) + deserialized = self._deserialize( + "AzureBackupFindRestorableTimeRangesResponseResource", pipeline_response.http_response + ) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - find.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/findRestorableTimeRanges" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/__init__.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/__init__.py index 1ae2d847393b..52f37de6ee55 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/__init__.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/__init__.py @@ -58,6 +58,8 @@ from ._models_py3 import ClientDiscoveryForServiceSpecification from ._models_py3 import ClientDiscoveryResponse from ._models_py3 import ClientDiscoveryValueForSingleApi +from ._models_py3 import CmkKekIdentity +from ._models_py3 import CmkKeyVaultProperties from ._models_py3 import CopyOnExpiryOption from ._models_py3 import CopyOption from ._models_py3 import CrossRegionRestoreDetails @@ -88,6 +90,7 @@ from ._models_py3 import DppTrackedResource from ._models_py3 import DppTrackedResourceList from ._models_py3 import DppWorkerRequest +from ._models_py3 import EncryptionSettings from ._models_py3 import Error from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail @@ -149,8 +152,10 @@ from ._models_py3 import SecuritySettings from ._models_py3 import SoftDeleteSettings from ._models_py3 import SourceLifeCycle +from ._models_py3 import StopProtectionRequest from ._models_py3 import StorageSetting from ._models_py3 import SupportedFeature +from ._models_py3 import SuspendBackupRequest from ._models_py3 import SyncBackupInstanceRequest from ._models_py3 import SystemData from ._models_py3 import TaggingCriteria @@ -169,16 +174,20 @@ from ._data_protection_mgmt_client_enums import AbsoluteMarker from ._data_protection_mgmt_client_enums import AlertsState +from ._data_protection_mgmt_client_enums import BCDRSecurityLevel from ._data_protection_mgmt_client_enums import CreatedByType from ._data_protection_mgmt_client_enums import CrossRegionRestoreState from ._data_protection_mgmt_client_enums import CrossSubscriptionRestoreState from ._data_protection_mgmt_client_enums import CurrentProtectionState from ._data_protection_mgmt_client_enums import DataStoreTypes from ._data_protection_mgmt_client_enums import DayOfWeek +from ._data_protection_mgmt_client_enums import EncryptionState from ._data_protection_mgmt_client_enums import ExistingResourcePolicy from ._data_protection_mgmt_client_enums import FeatureSupportStatus from ._data_protection_mgmt_client_enums import FeatureType +from ._data_protection_mgmt_client_enums import IdentityType from ._data_protection_mgmt_client_enums import ImmutabilityState +from ._data_protection_mgmt_client_enums import InfrastructureEncryptionState from ._data_protection_mgmt_client_enums import Month from ._data_protection_mgmt_client_enums import PersistentVolumeRestoreMode from ._data_protection_mgmt_client_enums import ProvisioningState @@ -257,6 +266,8 @@ "ClientDiscoveryForServiceSpecification", "ClientDiscoveryResponse", "ClientDiscoveryValueForSingleApi", + "CmkKekIdentity", + "CmkKeyVaultProperties", "CopyOnExpiryOption", "CopyOption", "CrossRegionRestoreDetails", @@ -287,6 +298,7 @@ "DppTrackedResource", "DppTrackedResourceList", "DppWorkerRequest", + "EncryptionSettings", "Error", "ErrorAdditionalInfo", "ErrorDetail", @@ -348,8 +360,10 @@ "SecuritySettings", "SoftDeleteSettings", "SourceLifeCycle", + "StopProtectionRequest", "StorageSetting", "SupportedFeature", + "SuspendBackupRequest", "SyncBackupInstanceRequest", "SystemData", "TaggingCriteria", @@ -367,16 +381,20 @@ "ValidateRestoreRequestObject", "AbsoluteMarker", "AlertsState", + "BCDRSecurityLevel", "CreatedByType", "CrossRegionRestoreState", "CrossSubscriptionRestoreState", "CurrentProtectionState", "DataStoreTypes", "DayOfWeek", + "EncryptionState", "ExistingResourcePolicy", "FeatureSupportStatus", "FeatureType", + "IdentityType", "ImmutabilityState", + "InfrastructureEncryptionState", "Month", "PersistentVolumeRestoreMode", "ProvisioningState", diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_data_protection_mgmt_client_enums.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_data_protection_mgmt_client_enums.py index 0a9706bdeb99..4cb5779c5255 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_data_protection_mgmt_client_enums.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_data_protection_mgmt_client_enums.py @@ -27,6 +27,16 @@ class AlertsState(str, Enum, metaclass=CaseInsensitiveEnumMeta): DISABLED = "Disabled" +class BCDRSecurityLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Security Level of Backup Vault.""" + + POOR = "Poor" + FAIR = "Fair" + GOOD = "Good" + EXCELLENT = "Excellent" + NOT_SUPPORTED = "NotSupported" + + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource.""" @@ -88,6 +98,19 @@ class DayOfWeek(str, Enum, metaclass=CaseInsensitiveEnumMeta): WEDNESDAY = "Wednesday" +class EncryptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Encryption state of the Backup Vault.""" + + ENABLED = "Enabled" + """CMK encryption is enabled on the Backup Vault""" + DISABLED = "Disabled" + """CMK encryption is disabled on the Backup Vault. User can not set this state once Encryption + State is 'Enabled'.""" + INCONSISTENT = "Inconsistent" + """CMK encryption is in inconsistent state on the Backup Vault. This state indicates that user + needs to retry the encryption settings operation immediately to correct the state.""" + + class ExistingResourcePolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the Conflict Policy property. This property sets policy during conflict of resources during restore. @@ -115,6 +138,15 @@ class FeatureType(str, Enum, metaclass=CaseInsensitiveEnumMeta): DATA_SOURCE_TYPE = "DataSourceType" +class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type. 'SystemAssigned' and 'UserAssigned' are mutually exclusive. 'SystemAssigned' + will use implicitly created managed identity. + """ + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + + class ImmutabilityState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Immutability state.""" @@ -123,6 +155,13 @@ class ImmutabilityState(str, Enum, metaclass=CaseInsensitiveEnumMeta): LOCKED = "Locked" +class InfrastructureEncryptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enabling/Disabling the Double Encryption state.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + class Month(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Month.""" diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_models_py3.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_models_py3.py index 2765855c042a..d8d4e2f07212 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_models_py3.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/models/_models_py3.py @@ -23,7 +23,7 @@ class DeleteOption(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: AbsoluteDeleteOption - 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 duration: Duration of deletion after given timespan. Required. :vartype duration: str @@ -56,7 +56,7 @@ def __init__(self, *, duration: str, **kwargs: Any) -> None: class AbsoluteDeleteOption(DeleteOption): """Delete option with duration. - 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 duration: Duration of deletion after given timespan. Required. :vartype duration: str @@ -86,7 +86,7 @@ def __init__(self, *, duration: str, **kwargs: Any) -> None: class AdHocBackupRuleOptions(_serialization.Model): """Adhoc backup rules. - 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 rule_name: Required. :vartype rule_name: str @@ -162,7 +162,7 @@ class TriggerContext(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: AdhocBasedTriggerContext, ScheduleBasedTriggerContext - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -192,7 +192,7 @@ def __init__(self, **kwargs: Any) -> None: class AdhocBasedTriggerContext(TriggerContext): """Adhoc trigger context. - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -227,7 +227,7 @@ class AuthCredentials(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: SecretStoreBasedAuthCredentials - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -255,7 +255,7 @@ class AzureBackupRecoveryPoint(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: AzureBackupDiscreteRecoveryPoint - 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 object_type: Required. :vartype object_type: str @@ -282,7 +282,7 @@ class AzureBackupDiscreteRecoveryPoint(AzureBackupRecoveryPoint): # pylint: dis 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 object_type: Required. :vartype object_type: str @@ -394,10 +394,10 @@ def __init__( self.recovery_point_state = recovery_point_state -class AzureBackupFindRestorableTimeRangesRequest(_serialization.Model): +class AzureBackupFindRestorableTimeRangesRequest(_serialization.Model): # pylint: disable=name-too-long """List Restore Ranges 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 source_data_store_type: Gets or sets the type of the source data store. Required. Known values are: "OperationalStore", "VaultStore", and "ArchiveStore". @@ -512,7 +512,7 @@ def __init__( self.http_method = http_method -class AzureBackupFindRestorableTimeRangesRequestResource(DppWorkerRequest): +class AzureBackupFindRestorableTimeRangesRequestResource(DppWorkerRequest): # pylint: disable=name-too-long """List Restore Ranges Request. :ivar subscription_id: @@ -591,7 +591,7 @@ def __init__( self.content = content -class AzureBackupFindRestorableTimeRangesResponse(_serialization.Model): +class AzureBackupFindRestorableTimeRangesResponse(_serialization.Model): # pylint: disable=name-too-long """List Restore Ranges Response. :ivar restorable_time_ranges: Returns the Restore Ranges available on the Backup Instance. @@ -662,7 +662,7 @@ def __init__(self, **kwargs: Any) -> None: self.system_data = None -class AzureBackupFindRestorableTimeRangesResponseResource(DppResource): +class AzureBackupFindRestorableTimeRangesResponseResource(DppResource): # pylint: disable=name-too-long """List Restore Ranges Response. Variables are only populated by the server, and will be ignored when sending a request. @@ -713,7 +713,7 @@ class AzureBackupJob(_serialization.Model): # pylint: disable=too-many-instance 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 activity_id: Job Activity Id. Required. :vartype activity_id: str @@ -1061,7 +1061,7 @@ class BackupParameters(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: AzureBackupParams - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -1086,7 +1086,7 @@ def __init__(self, **kwargs: Any) -> None: class AzureBackupParams(BackupParameters): """Azure backup parameters. - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -1120,7 +1120,7 @@ class AzureBackupRestoreRequest(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: AzureBackupRecoveryPointBasedRestoreRequest, AzureBackupRecoveryTimeBasedRestoreRequest - 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 object_type: Required. :vartype object_type: str @@ -1132,6 +1132,9 @@ class AzureBackupRestoreRequest(_serialization.Model): :ivar source_resource_id: Fully qualified Azure Resource Manager ID of the datasource which is being recovered. :vartype source_resource_id: str + :ivar resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check will + be performed. + :vartype resource_guard_operation_requests: list[str] :ivar identity_details: Contains information of the Identity Details for the BI. If it is null, default will be considered as System Assigned. :vartype identity_details: ~azure.mgmt.dataprotection.models.IdentityDetails @@ -1148,6 +1151,7 @@ class AzureBackupRestoreRequest(_serialization.Model): "restore_target_info": {"key": "restoreTargetInfo", "type": "RestoreTargetInfoBase"}, "source_data_store_type": {"key": "sourceDataStoreType", "type": "str"}, "source_resource_id": {"key": "sourceResourceId", "type": "str"}, + "resource_guard_operation_requests": {"key": "resourceGuardOperationRequests", "type": "[str]"}, "identity_details": {"key": "identityDetails", "type": "IdentityDetails"}, } @@ -1164,6 +1168,7 @@ def __init__( restore_target_info: "_models.RestoreTargetInfoBase", source_data_store_type: Union[str, "_models.SourceDataStoreType"], source_resource_id: Optional[str] = None, + resource_guard_operation_requests: Optional[List[str]] = None, identity_details: Optional["_models.IdentityDetails"] = None, **kwargs: Any ) -> None: @@ -1176,6 +1181,9 @@ def __init__( :keyword source_resource_id: Fully qualified Azure Resource Manager ID of the datasource which is being recovered. :paramtype source_resource_id: str + :keyword resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check + will be performed. + :paramtype resource_guard_operation_requests: list[str] :keyword identity_details: Contains information of the Identity Details for the BI. If it is null, default will be considered as System Assigned. :paramtype identity_details: ~azure.mgmt.dataprotection.models.IdentityDetails @@ -1185,16 +1193,17 @@ def __init__( self.restore_target_info = restore_target_info self.source_data_store_type = source_data_store_type self.source_resource_id = source_resource_id + self.resource_guard_operation_requests = resource_guard_operation_requests self.identity_details = identity_details -class AzureBackupRecoveryPointBasedRestoreRequest(AzureBackupRestoreRequest): +class AzureBackupRecoveryPointBasedRestoreRequest(AzureBackupRestoreRequest): # pylint: disable=name-too-long """Azure backup recoveryPoint based restore request. You probably want to use the sub-classes and not this class directly. Known sub-classes are: AzureBackupRestoreWithRehydrationRequest - 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 object_type: Required. :vartype object_type: str @@ -1206,6 +1215,9 @@ class AzureBackupRecoveryPointBasedRestoreRequest(AzureBackupRestoreRequest): :ivar source_resource_id: Fully qualified Azure Resource Manager ID of the datasource which is being recovered. :vartype source_resource_id: str + :ivar resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check will + be performed. + :vartype resource_guard_operation_requests: list[str] :ivar identity_details: Contains information of the Identity Details for the BI. If it is null, default will be considered as System Assigned. :vartype identity_details: ~azure.mgmt.dataprotection.models.IdentityDetails @@ -1225,6 +1237,7 @@ class AzureBackupRecoveryPointBasedRestoreRequest(AzureBackupRestoreRequest): "restore_target_info": {"key": "restoreTargetInfo", "type": "RestoreTargetInfoBase"}, "source_data_store_type": {"key": "sourceDataStoreType", "type": "str"}, "source_resource_id": {"key": "sourceResourceId", "type": "str"}, + "resource_guard_operation_requests": {"key": "resourceGuardOperationRequests", "type": "[str]"}, "identity_details": {"key": "identityDetails", "type": "IdentityDetails"}, "recovery_point_id": {"key": "recoveryPointId", "type": "str"}, } @@ -1240,6 +1253,7 @@ def __init__( source_data_store_type: Union[str, "_models.SourceDataStoreType"], recovery_point_id: str, source_resource_id: Optional[str] = None, + resource_guard_operation_requests: Optional[List[str]] = None, identity_details: Optional["_models.IdentityDetails"] = None, **kwargs: Any ) -> None: @@ -1252,6 +1266,9 @@ def __init__( :keyword source_resource_id: Fully qualified Azure Resource Manager ID of the datasource which is being recovered. :paramtype source_resource_id: str + :keyword resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check + will be performed. + :paramtype resource_guard_operation_requests: list[str] :keyword identity_details: Contains information of the Identity Details for the BI. If it is null, default will be considered as System Assigned. :paramtype identity_details: ~azure.mgmt.dataprotection.models.IdentityDetails @@ -1262,6 +1279,7 @@ def __init__( restore_target_info=restore_target_info, source_data_store_type=source_data_store_type, source_resource_id=source_resource_id, + resource_guard_operation_requests=resource_guard_operation_requests, identity_details=identity_details, **kwargs ) @@ -1344,10 +1362,10 @@ def __init__( self.value = value -class AzureBackupRecoveryTimeBasedRestoreRequest(AzureBackupRestoreRequest): +class AzureBackupRecoveryTimeBasedRestoreRequest(AzureBackupRestoreRequest): # pylint: disable=name-too-long """AzureBackup RecoveryPointTime Based Restore 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 object_type: Required. :vartype object_type: str @@ -1359,6 +1377,9 @@ class AzureBackupRecoveryTimeBasedRestoreRequest(AzureBackupRestoreRequest): :ivar source_resource_id: Fully qualified Azure Resource Manager ID of the datasource which is being recovered. :vartype source_resource_id: str + :ivar resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check will + be performed. + :vartype resource_guard_operation_requests: list[str] :ivar identity_details: Contains information of the Identity Details for the BI. If it is null, default will be considered as System Assigned. :vartype identity_details: ~azure.mgmt.dataprotection.models.IdentityDetails @@ -1379,6 +1400,7 @@ class AzureBackupRecoveryTimeBasedRestoreRequest(AzureBackupRestoreRequest): "restore_target_info": {"key": "restoreTargetInfo", "type": "RestoreTargetInfoBase"}, "source_data_store_type": {"key": "sourceDataStoreType", "type": "str"}, "source_resource_id": {"key": "sourceResourceId", "type": "str"}, + "resource_guard_operation_requests": {"key": "resourceGuardOperationRequests", "type": "[str]"}, "identity_details": {"key": "identityDetails", "type": "IdentityDetails"}, "recovery_point_time": {"key": "recoveryPointTime", "type": "str"}, } @@ -1390,6 +1412,7 @@ def __init__( source_data_store_type: Union[str, "_models.SourceDataStoreType"], recovery_point_time: str, source_resource_id: Optional[str] = None, + resource_guard_operation_requests: Optional[List[str]] = None, identity_details: Optional["_models.IdentityDetails"] = None, **kwargs: Any ) -> None: @@ -1402,6 +1425,9 @@ def __init__( :keyword source_resource_id: Fully qualified Azure Resource Manager ID of the datasource which is being recovered. :paramtype source_resource_id: str + :keyword resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check + will be performed. + :paramtype resource_guard_operation_requests: list[str] :keyword identity_details: Contains information of the Identity Details for the BI. If it is null, default will be considered as System Assigned. :paramtype identity_details: ~azure.mgmt.dataprotection.models.IdentityDetails @@ -1413,6 +1439,7 @@ def __init__( restore_target_info=restore_target_info, source_data_store_type=source_data_store_type, source_resource_id=source_resource_id, + resource_guard_operation_requests=resource_guard_operation_requests, identity_details=identity_details, **kwargs ) @@ -1423,7 +1450,7 @@ def __init__( class AzureBackupRehydrationRequest(_serialization.Model): """Azure Backup Rehydrate 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 recovery_point_id: Id of the recovery point to be recovered. Required. :vartype recovery_point_id: str @@ -1473,7 +1500,7 @@ def __init__( class AzureBackupRestoreWithRehydrationRequest(AzureBackupRecoveryPointBasedRestoreRequest): """AzureBackup Restore with Rehydration 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 object_type: Required. :vartype object_type: str @@ -1485,6 +1512,9 @@ class AzureBackupRestoreWithRehydrationRequest(AzureBackupRecoveryPointBasedRest :ivar source_resource_id: Fully qualified Azure Resource Manager ID of the datasource which is being recovered. :vartype source_resource_id: str + :ivar resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check will + be performed. + :vartype resource_guard_operation_requests: list[str] :ivar identity_details: Contains information of the Identity Details for the BI. If it is null, default will be considered as System Assigned. :vartype identity_details: ~azure.mgmt.dataprotection.models.IdentityDetails @@ -1512,6 +1542,7 @@ class AzureBackupRestoreWithRehydrationRequest(AzureBackupRecoveryPointBasedRest "restore_target_info": {"key": "restoreTargetInfo", "type": "RestoreTargetInfoBase"}, "source_data_store_type": {"key": "sourceDataStoreType", "type": "str"}, "source_resource_id": {"key": "sourceResourceId", "type": "str"}, + "resource_guard_operation_requests": {"key": "resourceGuardOperationRequests", "type": "[str]"}, "identity_details": {"key": "identityDetails", "type": "IdentityDetails"}, "recovery_point_id": {"key": "recoveryPointId", "type": "str"}, "rehydration_priority": {"key": "rehydrationPriority", "type": "str"}, @@ -1527,6 +1558,7 @@ def __init__( rehydration_priority: Union[str, "_models.RehydrationPriority"], rehydration_retention_duration: str, source_resource_id: Optional[str] = None, + resource_guard_operation_requests: Optional[List[str]] = None, identity_details: Optional["_models.IdentityDetails"] = None, **kwargs: Any ) -> None: @@ -1539,6 +1571,9 @@ def __init__( :keyword source_resource_id: Fully qualified Azure Resource Manager ID of the datasource which is being recovered. :paramtype source_resource_id: str + :keyword resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check + will be performed. + :paramtype resource_guard_operation_requests: list[str] :keyword identity_details: Contains information of the Identity Details for the BI. If it is null, default will be considered as System Assigned. :paramtype identity_details: ~azure.mgmt.dataprotection.models.IdentityDetails @@ -1555,6 +1590,7 @@ def __init__( restore_target_info=restore_target_info, source_data_store_type=source_data_store_type, source_resource_id=source_resource_id, + resource_guard_operation_requests=resource_guard_operation_requests, identity_details=identity_details, recovery_point_id=recovery_point_id, **kwargs @@ -1570,7 +1606,7 @@ class BasePolicyRule(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: AzureBackupRule, AzureRetentionRule - 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: Required. :vartype name: str @@ -1603,7 +1639,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class AzureBackupRule(BasePolicyRule): """Azure backup 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 name: Required. :vartype name: str @@ -1686,7 +1722,7 @@ class DataStoreParameters(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: AzureOperationalStoreParameters - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -1721,7 +1757,7 @@ def __init__(self, *, data_store_type: Union[str, "_models.DataStoreTypes"], **k class AzureOperationalStoreParameters(DataStoreParameters): """Parameters for Operational-Tier DataStore. - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -1765,7 +1801,7 @@ def __init__( class AzureRetentionRule(BasePolicyRule): """Azure retention 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 name: Required. :vartype name: str @@ -1818,7 +1854,7 @@ class BackupCriteria(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: ScheduleBasedBackupCriteria - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -1846,7 +1882,7 @@ class BackupDatasourceParameters(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: BlobBackupDatasourceParameters, KubernetesClusterBackupDatasourceParameters - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -1878,7 +1914,7 @@ class BackupInstance(_serialization.Model): # pylint: disable=too-many-instance 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 friendly_name: Gets or sets the Backup Instance friendly name. :vartype friendly_name: str @@ -1888,6 +1924,9 @@ class BackupInstance(_serialization.Model): # pylint: disable=too-many-instance :vartype data_source_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet :ivar policy_info: Gets or sets the policy information. Required. :vartype policy_info: ~azure.mgmt.dataprotection.models.PolicyInfo + :ivar resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check will + be performed. + :vartype resource_guard_operation_requests: list[str] :ivar protection_status: Specifies the protection status of the resource. :vartype protection_status: ~azure.mgmt.dataprotection.models.ProtectionStatusDetails :ivar current_protection_state: Specifies the current protection state of the resource. Known @@ -1931,6 +1970,7 @@ class BackupInstance(_serialization.Model): # pylint: disable=too-many-instance "data_source_info": {"key": "dataSourceInfo", "type": "Datasource"}, "data_source_set_info": {"key": "dataSourceSetInfo", "type": "DatasourceSet"}, "policy_info": {"key": "policyInfo", "type": "PolicyInfo"}, + "resource_guard_operation_requests": {"key": "resourceGuardOperationRequests", "type": "[str]"}, "protection_status": {"key": "protectionStatus", "type": "ProtectionStatusDetails"}, "current_protection_state": {"key": "currentProtectionState", "type": "str"}, "protection_error_details": {"key": "protectionErrorDetails", "type": "UserFacingError"}, @@ -1949,6 +1989,7 @@ def __init__( object_type: str, friendly_name: Optional[str] = None, data_source_set_info: Optional["_models.DatasourceSet"] = None, + resource_guard_operation_requests: Optional[List[str]] = None, datasource_auth_credentials: Optional["_models.AuthCredentials"] = None, validation_type: Optional[Union[str, "_models.ValidationType"]] = None, identity_details: Optional["_models.IdentityDetails"] = None, @@ -1963,6 +2004,9 @@ def __init__( :paramtype data_source_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet :keyword policy_info: Gets or sets the policy information. Required. :paramtype policy_info: ~azure.mgmt.dataprotection.models.PolicyInfo + :keyword resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check + will be performed. + :paramtype resource_guard_operation_requests: list[str] :keyword datasource_auth_credentials: Credentials to use to authenticate with data source provider. :paramtype datasource_auth_credentials: ~azure.mgmt.dataprotection.models.AuthCredentials @@ -1981,6 +2025,7 @@ def __init__( self.data_source_info = data_source_info self.data_source_set_info = data_source_set_info self.policy_info = policy_info + self.resource_guard_operation_requests = resource_guard_operation_requests self.protection_status = None self.current_protection_state = None self.protection_error_details = None @@ -2129,7 +2174,7 @@ class BaseBackupPolicy(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: BackupPolicy - 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 datasource_types: Type of datasource for the backup management. Required. :vartype datasource_types: list[str] @@ -2162,7 +2207,7 @@ def __init__(self, *, datasource_types: List[str], **kwargs: Any) -> None: class BackupPolicy(BaseBackupPolicy): """Rule based backup policy. - 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 datasource_types: Type of datasource for the backup management. Required. :vartype datasource_types: list[str] @@ -2203,7 +2248,7 @@ def __init__( class BackupSchedule(_serialization.Model): """Schedule for backup. - 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 repeating_time_intervals: ISO 8601 repeating time interval format. Required. :vartype repeating_time_intervals: list[str] @@ -2232,12 +2277,12 @@ def __init__(self, *, repeating_time_intervals: List[str], time_zone: Optional[s self.time_zone = time_zone -class BackupVault(_serialization.Model): +class BackupVault(_serialization.Model): # pylint: disable=too-many-instance-attributes """Backup Vault. 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 monitoring_settings: Monitoring Settings. :vartype monitoring_settings: ~azure.mgmt.dataprotection.models.MonitoringSettings @@ -2261,6 +2306,12 @@ class BackupVault(_serialization.Model): :ivar secure_score: Secure Score of Backup Vault. Known values are: "None", "Minimum", "Adequate", "Maximum", and "NotSupported". :vartype secure_score: str or ~azure.mgmt.dataprotection.models.SecureScoreLevel + :ivar bcdr_security_level: Security Level of Backup Vault. Known values are: "Poor", "Fair", + "Good", "Excellent", and "NotSupported". + :vartype bcdr_security_level: str or ~azure.mgmt.dataprotection.models.BCDRSecurityLevel + :ivar resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check will + be performed. + :vartype resource_guard_operation_requests: list[str] :ivar replicated_regions: List of replicated regions for Backup Vault. :vartype replicated_regions: list[str] """ @@ -2272,6 +2323,7 @@ class BackupVault(_serialization.Model): "storage_settings": {"required": True}, "is_vault_protected_by_resource_guard": {"readonly": True}, "secure_score": {"readonly": True}, + "bcdr_security_level": {"readonly": True}, } _attribute_map = { @@ -2284,6 +2336,8 @@ class BackupVault(_serialization.Model): "is_vault_protected_by_resource_guard": {"key": "isVaultProtectedByResourceGuard", "type": "bool"}, "feature_settings": {"key": "featureSettings", "type": "FeatureSettings"}, "secure_score": {"key": "secureScore", "type": "str"}, + "bcdr_security_level": {"key": "bcdrSecurityLevel", "type": "str"}, + "resource_guard_operation_requests": {"key": "resourceGuardOperationRequests", "type": "[str]"}, "replicated_regions": {"key": "replicatedRegions", "type": "[str]"}, } @@ -2294,6 +2348,7 @@ def __init__( monitoring_settings: Optional["_models.MonitoringSettings"] = None, security_settings: Optional["_models.SecuritySettings"] = None, feature_settings: Optional["_models.FeatureSettings"] = None, + resource_guard_operation_requests: Optional[List[str]] = None, replicated_regions: Optional[List[str]] = None, **kwargs: Any ) -> None: @@ -2306,6 +2361,9 @@ def __init__( :paramtype storage_settings: list[~azure.mgmt.dataprotection.models.StorageSetting] :keyword feature_settings: Feature Settings. :paramtype feature_settings: ~azure.mgmt.dataprotection.models.FeatureSettings + :keyword resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check + will be performed. + :paramtype resource_guard_operation_requests: list[str] :keyword replicated_regions: List of replicated regions for Backup Vault. :paramtype replicated_regions: list[str] """ @@ -2319,6 +2377,8 @@ def __init__( self.is_vault_protected_by_resource_guard = None self.feature_settings = feature_settings self.secure_score = None + self.bcdr_security_level = None + self.resource_guard_operation_requests = resource_guard_operation_requests self.replicated_regions = replicated_regions @@ -2457,7 +2517,7 @@ class BackupVaultResource(DppTrackedResource): 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 e_tag: Optional ETag. :vartype e_tag: str @@ -2640,7 +2700,7 @@ class BaseResourceProperties(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: DefaultResourceProperties - 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 object_type: Type of the specific object - used for deserializing. Required. "DefaultResourceProperties" @@ -2666,7 +2726,7 @@ def __init__(self, **kwargs: Any) -> None: class BlobBackupDatasourceParameters(BackupDatasourceParameters): """Parameters to be used during configuration of backup of blobs. - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -2981,13 +3041,71 @@ def __init__( self.properties = properties +class CmkKekIdentity(_serialization.Model): + """The details of the managed identity used for CMK. + + :ivar identity_type: The identity type. 'SystemAssigned' and 'UserAssigned' are mutually + exclusive. 'SystemAssigned' will use implicitly created managed identity. Known values are: + "SystemAssigned" and "UserAssigned". + :vartype identity_type: str or ~azure.mgmt.dataprotection.models.IdentityType + :ivar identity_id: The managed identity to be used which has access permissions to the Key + Vault. Provide a value here in case identity types: 'UserAssigned' only. + :vartype identity_id: str + """ + + _attribute_map = { + "identity_type": {"key": "identityType", "type": "str"}, + "identity_id": {"key": "identityId", "type": "str"}, + } + + def __init__( + self, + *, + identity_type: Optional[Union[str, "_models.IdentityType"]] = None, + identity_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword identity_type: The identity type. 'SystemAssigned' and 'UserAssigned' are mutually + exclusive. 'SystemAssigned' will use implicitly created managed identity. Known values are: + "SystemAssigned" and "UserAssigned". + :paramtype identity_type: str or ~azure.mgmt.dataprotection.models.IdentityType + :keyword identity_id: The managed identity to be used which has access permissions to the Key + Vault. Provide a value here in case identity types: 'UserAssigned' only. + :paramtype identity_id: str + """ + super().__init__(**kwargs) + self.identity_type = identity_type + self.identity_id = identity_id + + +class CmkKeyVaultProperties(_serialization.Model): + """The properties of the Key Vault which hosts CMK. + + :ivar key_uri: The key uri of the Customer Managed Key. + :vartype key_uri: str + """ + + _attribute_map = { + "key_uri": {"key": "keyUri", "type": "str"}, + } + + def __init__(self, *, key_uri: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword key_uri: The key uri of the Customer Managed Key. + :paramtype key_uri: str + """ + super().__init__(**kwargs) + self.key_uri = key_uri + + class CopyOption(_serialization.Model): """Options to copy. You probably want to use the sub-classes and not this class directly. Known sub-classes are: CopyOnExpiryOption, CustomCopyOption, ImmediateCopyOption - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -3018,7 +3136,7 @@ def __init__(self, **kwargs: Any) -> None: class CopyOnExpiryOption(CopyOption): """Copy on Expiry Option. - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -3041,7 +3159,7 @@ def __init__(self, **kwargs: Any) -> None: class CrossRegionRestoreDetails(_serialization.Model): """Cross Region Restore details. - 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_region: Required. :vartype source_region: str @@ -3074,7 +3192,7 @@ def __init__(self, *, source_region: str, source_backup_instance_id: str, **kwar class CrossRegionRestoreJobRequest(_serialization.Model): """Details of CRR Job to be fetched. - 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_region: Required. :vartype source_region: str @@ -3114,7 +3232,7 @@ def __init__(self, *, source_region: str, source_backup_vault_id: str, job_id: s class CrossRegionRestoreJobsRequest(_serialization.Model): """Details of Backup Vault for which CRR Jobs are to be fetched. - 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_region: Required. :vartype source_region: str @@ -3147,7 +3265,7 @@ def __init__(self, *, source_region: str, source_backup_vault_id: str, **kwargs: class CrossRegionRestoreRequestObject(_serialization.Model): """Cross Region Restore Request Object. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar restore_request_object: Gets or sets the restore request object. Required. :vartype restore_request_object: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest @@ -3232,7 +3350,7 @@ def __init__( class CustomCopyOption(CopyOption): """Duration based custom options to copy. - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -3262,7 +3380,7 @@ def __init__(self, *, duration: Optional[str] = None, **kwargs: Any) -> None: class Datasource(_serialization.Model): """Datasource to be backed up. - 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 datasource_type: DatasourceType of the resource. :vartype datasource_type: str @@ -3344,7 +3462,7 @@ def __init__( class DatasourceSet(_serialization.Model): """DatasourceSet details of datasource to be backed up. - 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 datasource_type: DatasourceType of the resource. :vartype datasource_type: str @@ -3426,7 +3544,7 @@ def __init__( class DataStoreInfoBase(_serialization.Model): """DataStoreInfo base. - 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 data_store_type: type of datastore; Operational/Vault/Archive. Required. Known values are: "OperationalStore", "VaultStore", and "ArchiveStore". @@ -3491,7 +3609,7 @@ def __init__(self, *, date: Optional[int] = None, is_last: Optional[bool] = None class DefaultResourceProperties(BaseResourceProperties): """Default source properties. - 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 object_type: Type of the specific object - used for deserializing. Required. "DefaultResourceProperties" @@ -3517,7 +3635,7 @@ class DeletedBackupInstance(BackupInstance): # pylint: disable=too-many-instanc 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 friendly_name: Gets or sets the Backup Instance friendly name. :vartype friendly_name: str @@ -3527,6 +3645,9 @@ class DeletedBackupInstance(BackupInstance): # pylint: disable=too-many-instanc :vartype data_source_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet :ivar policy_info: Gets or sets the policy information. Required. :vartype policy_info: ~azure.mgmt.dataprotection.models.PolicyInfo + :ivar resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check will + be performed. + :vartype resource_guard_operation_requests: list[str] :ivar protection_status: Specifies the protection status of the resource. :vartype protection_status: ~azure.mgmt.dataprotection.models.ProtectionStatusDetails :ivar current_protection_state: Specifies the current protection state of the resource. Known @@ -3573,6 +3694,7 @@ class DeletedBackupInstance(BackupInstance): # pylint: disable=too-many-instanc "data_source_info": {"key": "dataSourceInfo", "type": "Datasource"}, "data_source_set_info": {"key": "dataSourceSetInfo", "type": "DatasourceSet"}, "policy_info": {"key": "policyInfo", "type": "PolicyInfo"}, + "resource_guard_operation_requests": {"key": "resourceGuardOperationRequests", "type": "[str]"}, "protection_status": {"key": "protectionStatus", "type": "ProtectionStatusDetails"}, "current_protection_state": {"key": "currentProtectionState", "type": "str"}, "protection_error_details": {"key": "protectionErrorDetails", "type": "UserFacingError"}, @@ -3592,6 +3714,7 @@ def __init__( object_type: str, friendly_name: Optional[str] = None, data_source_set_info: Optional["_models.DatasourceSet"] = None, + resource_guard_operation_requests: Optional[List[str]] = None, datasource_auth_credentials: Optional["_models.AuthCredentials"] = None, validation_type: Optional[Union[str, "_models.ValidationType"]] = None, identity_details: Optional["_models.IdentityDetails"] = None, @@ -3606,6 +3729,9 @@ def __init__( :paramtype data_source_set_info: ~azure.mgmt.dataprotection.models.DatasourceSet :keyword policy_info: Gets or sets the policy information. Required. :paramtype policy_info: ~azure.mgmt.dataprotection.models.PolicyInfo + :keyword resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check + will be performed. + :paramtype resource_guard_operation_requests: list[str] :keyword datasource_auth_credentials: Credentials to use to authenticate with data source provider. :paramtype datasource_auth_credentials: ~azure.mgmt.dataprotection.models.AuthCredentials @@ -3624,6 +3750,7 @@ def __init__( data_source_info=data_source_info, data_source_set_info=data_source_set_info, policy_info=policy_info, + resource_guard_operation_requests=resource_guard_operation_requests, datasource_auth_credentials=datasource_auth_credentials, validation_type=validation_type, identity_details=identity_details, @@ -3885,6 +4012,58 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: self.next_link = next_link +class EncryptionSettings(_serialization.Model): + """Customer Managed Key details of the resource. + + :ivar state: Encryption state of the Backup Vault. Known values are: "Enabled", "Disabled", and + "Inconsistent". + :vartype state: str or ~azure.mgmt.dataprotection.models.EncryptionState + :ivar key_vault_properties: The properties of the Key Vault which hosts CMK. + :vartype key_vault_properties: ~azure.mgmt.dataprotection.models.CmkKeyVaultProperties + :ivar kek_identity: The details of the managed identity used for CMK. + :vartype kek_identity: ~azure.mgmt.dataprotection.models.CmkKekIdentity + :ivar infrastructure_encryption: Enabling/Disabling the Double Encryption state. Known values + are: "Enabled" and "Disabled". + :vartype infrastructure_encryption: str or + ~azure.mgmt.dataprotection.models.InfrastructureEncryptionState + """ + + _attribute_map = { + "state": {"key": "state", "type": "str"}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "CmkKeyVaultProperties"}, + "kek_identity": {"key": "kekIdentity", "type": "CmkKekIdentity"}, + "infrastructure_encryption": {"key": "infrastructureEncryption", "type": "str"}, + } + + def __init__( + self, + *, + state: Optional[Union[str, "_models.EncryptionState"]] = None, + key_vault_properties: Optional["_models.CmkKeyVaultProperties"] = None, + kek_identity: Optional["_models.CmkKekIdentity"] = None, + infrastructure_encryption: Optional[Union[str, "_models.InfrastructureEncryptionState"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword state: Encryption state of the Backup Vault. Known values are: "Enabled", "Disabled", + and "Inconsistent". + :paramtype state: str or ~azure.mgmt.dataprotection.models.EncryptionState + :keyword key_vault_properties: The properties of the Key Vault which hosts CMK. + :paramtype key_vault_properties: ~azure.mgmt.dataprotection.models.CmkKeyVaultProperties + :keyword kek_identity: The details of the managed identity used for CMK. + :paramtype kek_identity: ~azure.mgmt.dataprotection.models.CmkKekIdentity + :keyword infrastructure_encryption: Enabling/Disabling the Double Encryption state. Known + values are: "Enabled" and "Disabled". + :paramtype infrastructure_encryption: str or + ~azure.mgmt.dataprotection.models.InfrastructureEncryptionState + """ + super().__init__(**kwargs) + self.state = state + self.key_vault_properties = key_vault_properties + self.kek_identity = kek_identity + self.infrastructure_encryption = infrastructure_encryption + + class Error(_serialization.Model): """The resource management error response. @@ -4103,7 +4282,7 @@ class FeatureValidationRequestBase(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: FeatureValidationRequest - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -4128,7 +4307,7 @@ def __init__(self, **kwargs: Any) -> None: class FeatureValidationRequest(FeatureValidationRequestBase): """Base class for feature object. - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -4175,7 +4354,7 @@ class FeatureValidationResponseBase(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: FeatureValidationResponse - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -4200,7 +4379,7 @@ def __init__(self, **kwargs: Any) -> None: class FeatureValidationResponse(FeatureValidationResponseBase): """Feature Validation Response. - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -4306,7 +4485,7 @@ def __init__( class ImmediateCopyOption(CopyOption): """Immediate copy Option. - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -4395,7 +4574,7 @@ class ItemLevelRestoreCriteria(_serialization.Model): KubernetesClusterVaultTierRestoreCriteria, KubernetesPVRestoreCriteria, KubernetesStorageClassRestoreCriteria, RangeBasedItemLevelRestoreCriteria - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -4432,7 +4611,7 @@ class RestoreTargetInfoBase(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: ItemLevelRestoreTargetInfo, RestoreFilesTargetInfo, RestoreTargetInfo - 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 object_type: Type of Datasource object, used to initialize the right inherited type. Required. @@ -4484,7 +4663,7 @@ def __init__( class ItemLevelRestoreTargetInfo(RestoreTargetInfoBase): """Restore target info for Item level restore operation. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar object_type: Type of Datasource object, used to initialize the right inherited type. Required. @@ -4558,7 +4737,7 @@ def __init__( class ItemPathBasedRestoreCriteria(ItemLevelRestoreCriteria): """Prefix criteria to be used to during restore. - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -4677,7 +4856,7 @@ class JobSubTask(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar additional_details: Additional details of Sub Tasks. :vartype additional_details: dict[str, str] @@ -4733,10 +4912,10 @@ def __init__( self.task_status = task_status -class KubernetesClusterBackupDatasourceParameters(BackupDatasourceParameters): +class KubernetesClusterBackupDatasourceParameters(BackupDatasourceParameters): # pylint: disable=name-too-long """Parameters for Kubernetes Cluster Backup Datasource. - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -4839,7 +5018,7 @@ def __init__( class KubernetesClusterRestoreCriteria(ItemLevelRestoreCriteria): # pylint: disable=too-many-instance-attributes """kubernetes Cluster Backup target info for restore operation. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -4876,6 +5055,9 @@ class KubernetesClusterRestoreCriteria(ItemLevelRestoreCriteria): # pylint: dis hook reference to be executed during restore. :vartype restore_hook_references: list[~azure.mgmt.dataprotection.models.NamespacedNameResource] + :ivar resource_modifier_reference: Gets or sets the resource modifier reference. This property + sets the reference for resource modifier during restore. + :vartype resource_modifier_reference: ~azure.mgmt.dataprotection.models.NamespacedNameResource """ _validation = { @@ -4895,6 +5077,7 @@ class KubernetesClusterRestoreCriteria(ItemLevelRestoreCriteria): # pylint: dis "conflict_policy": {"key": "conflictPolicy", "type": "str"}, "namespace_mappings": {"key": "namespaceMappings", "type": "{str}"}, "restore_hook_references": {"key": "restoreHookReferences", "type": "[NamespacedNameResource]"}, + "resource_modifier_reference": {"key": "resourceModifierReference", "type": "NamespacedNameResource"}, } def __init__( @@ -4910,6 +5093,7 @@ def __init__( conflict_policy: Optional[Union[str, "_models.ExistingResourcePolicy"]] = None, namespace_mappings: Optional[Dict[str, str]] = None, restore_hook_references: Optional[List["_models.NamespacedNameResource"]] = None, + resource_modifier_reference: Optional["_models.NamespacedNameResource"] = None, **kwargs: Any ) -> None: """ @@ -4946,6 +5130,10 @@ def __init__( the hook reference to be executed during restore. :paramtype restore_hook_references: list[~azure.mgmt.dataprotection.models.NamespacedNameResource] + :keyword resource_modifier_reference: Gets or sets the resource modifier reference. This + property sets the reference for resource modifier during restore. + :paramtype resource_modifier_reference: + ~azure.mgmt.dataprotection.models.NamespacedNameResource """ super().__init__(**kwargs) self.object_type: str = "KubernetesClusterRestoreCriteria" @@ -4959,14 +5147,15 @@ def __init__( self.conflict_policy = conflict_policy self.namespace_mappings = namespace_mappings self.restore_hook_references = restore_hook_references + self.resource_modifier_reference = resource_modifier_reference class KubernetesClusterVaultTierRestoreCriteria( ItemLevelRestoreCriteria -): # pylint: disable=too-many-instance-attributes +): # pylint: disable=too-many-instance-attributes,name-too-long """kubernetes Cluster Backup target info for restore operation from vault. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -5010,6 +5199,9 @@ class KubernetesClusterVaultTierRestoreCriteria( :ivar staging_storage_account_id: Gets or sets the staging Storage Account Id for creating backup extension object store data during restore from vault. :vartype staging_storage_account_id: str + :ivar resource_modifier_reference: Gets or sets the resource modifier reference. This property + sets the reference for resource modifier during restore. + :vartype resource_modifier_reference: ~azure.mgmt.dataprotection.models.NamespacedNameResource """ _validation = { @@ -5031,6 +5223,7 @@ class KubernetesClusterVaultTierRestoreCriteria( "restore_hook_references": {"key": "restoreHookReferences", "type": "[NamespacedNameResource]"}, "staging_resource_group_id": {"key": "stagingResourceGroupId", "type": "str"}, "staging_storage_account_id": {"key": "stagingStorageAccountId", "type": "str"}, + "resource_modifier_reference": {"key": "resourceModifierReference", "type": "NamespacedNameResource"}, } def __init__( @@ -5048,6 +5241,7 @@ def __init__( restore_hook_references: Optional[List["_models.NamespacedNameResource"]] = None, staging_resource_group_id: Optional[str] = None, staging_storage_account_id: Optional[str] = None, + resource_modifier_reference: Optional["_models.NamespacedNameResource"] = None, **kwargs: Any ) -> None: """ @@ -5091,6 +5285,10 @@ def __init__( :keyword staging_storage_account_id: Gets or sets the staging Storage Account Id for creating backup extension object store data during restore from vault. :paramtype staging_storage_account_id: str + :keyword resource_modifier_reference: Gets or sets the resource modifier reference. This + property sets the reference for resource modifier during restore. + :paramtype resource_modifier_reference: + ~azure.mgmt.dataprotection.models.NamespacedNameResource """ super().__init__(**kwargs) self.object_type: str = "KubernetesClusterVaultTierRestoreCriteria" @@ -5106,12 +5304,13 @@ def __init__( self.restore_hook_references = restore_hook_references self.staging_resource_group_id = staging_resource_group_id self.staging_storage_account_id = staging_storage_account_id + self.resource_modifier_reference = resource_modifier_reference class KubernetesPVRestoreCriteria(ItemLevelRestoreCriteria): """Item Level kubernetes persistent volume target info for restore operation. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -5147,7 +5346,7 @@ def __init__(self, *, name: Optional[str] = None, storage_class_name: Optional[s class KubernetesStorageClassRestoreCriteria(ItemLevelRestoreCriteria): """Item Level kubernetes storage class target info for restore operation. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -5238,7 +5437,7 @@ class OperationExtendedInfo(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: OperationJobExtendedInfo - 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 object_type: This property will be used as the discriminator for deciding the specific types in the polymorphic chain of types. Required. @@ -5264,7 +5463,7 @@ def __init__(self, **kwargs: Any) -> None: class OperationJobExtendedInfo(OperationExtendedInfo): """Operation Job Extended Info. - 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 object_type: This property will be used as the discriminator for deciding the specific types in the polymorphic chain of types. Required. @@ -5376,12 +5575,16 @@ class PatchBackupVaultInput(_serialization.Model): :vartype security_settings: ~azure.mgmt.dataprotection.models.SecuritySettings :ivar feature_settings: Feature Settings. :vartype feature_settings: ~azure.mgmt.dataprotection.models.FeatureSettings + :ivar resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check will + be performed. + :vartype resource_guard_operation_requests: list[str] """ _attribute_map = { "monitoring_settings": {"key": "monitoringSettings", "type": "MonitoringSettings"}, "security_settings": {"key": "securitySettings", "type": "SecuritySettings"}, "feature_settings": {"key": "featureSettings", "type": "FeatureSettings"}, + "resource_guard_operation_requests": {"key": "resourceGuardOperationRequests", "type": "[str]"}, } def __init__( @@ -5390,6 +5593,7 @@ def __init__( monitoring_settings: Optional["_models.MonitoringSettings"] = None, security_settings: Optional["_models.SecuritySettings"] = None, feature_settings: Optional["_models.FeatureSettings"] = None, + resource_guard_operation_requests: Optional[List[str]] = None, **kwargs: Any ) -> None: """ @@ -5399,11 +5603,15 @@ def __init__( :paramtype security_settings: ~azure.mgmt.dataprotection.models.SecuritySettings :keyword feature_settings: Feature Settings. :paramtype feature_settings: ~azure.mgmt.dataprotection.models.FeatureSettings + :keyword resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check + will be performed. + :paramtype resource_guard_operation_requests: list[str] """ super().__init__(**kwargs) self.monitoring_settings = monitoring_settings self.security_settings = security_settings self.feature_settings = feature_settings + self.resource_guard_operation_requests = resource_guard_operation_requests class PatchResourceGuardInput(_serialization.Model): @@ -5470,7 +5678,7 @@ class PolicyInfo(_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 policy_id: Required. :vartype policy_id: str @@ -5584,7 +5792,7 @@ def __init__( class RangeBasedItemLevelRestoreCriteria(ItemLevelRestoreCriteria): """Item Level target info for restore operation. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -6159,7 +6367,7 @@ def __init__( class RestorableTimeRange(_serialization.Model): """RestorableTimeRange. - 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 start_time: Start time for the available restore range. Required. :vartype start_time: str @@ -6198,7 +6406,7 @@ def __init__(self, *, start_time: str, end_time: str, object_type: Optional[str] class RestoreFilesTargetInfo(RestoreTargetInfoBase): """Class encapsulating restore as files target parameters. - 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 object_type: Type of Datasource object, used to initialize the right inherited type. Required. @@ -6282,7 +6490,7 @@ def __init__( class RestoreTargetInfo(RestoreTargetInfoBase): """Class encapsulating restore target parameters. - 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 object_type: Type of Datasource object, used to initialize the right inherited type. Required. @@ -6350,7 +6558,7 @@ class RetentionTag(_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 e_tag: Retention Tag version. :vartype e_tag: str @@ -6386,7 +6594,7 @@ def __init__(self, *, tag_name: str, **kwargs: Any) -> None: class ScheduleBasedBackupCriteria(BackupCriteria): """Schedule based backup criteria. - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -6460,7 +6668,7 @@ def __init__( class ScheduleBasedTriggerContext(TriggerContext): """Schedule based trigger context. - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -6500,7 +6708,7 @@ def __init__( class SecretStoreBasedAuthCredentials(AuthCredentials): """Secret store based authentication credentials. - 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 object_type: Type of the specific object - used for deserializing. Required. :vartype object_type: str @@ -6530,7 +6738,7 @@ def __init__(self, *, secret_store_resource: Optional["_models.SecretStoreResour class SecretStoreResource(_serialization.Model): """Class representing a secret store resource. - 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 uri: Uri to get to the resource. :vartype uri: str @@ -6581,11 +6789,14 @@ class SecuritySettings(_serialization.Model): :vartype soft_delete_settings: ~azure.mgmt.dataprotection.models.SoftDeleteSettings :ivar immutability_settings: Immutability Settings at vault level. :vartype immutability_settings: ~azure.mgmt.dataprotection.models.ImmutabilitySettings + :ivar encryption_settings: Customer Managed Key details of the resource. + :vartype encryption_settings: ~azure.mgmt.dataprotection.models.EncryptionSettings """ _attribute_map = { "soft_delete_settings": {"key": "softDeleteSettings", "type": "SoftDeleteSettings"}, "immutability_settings": {"key": "immutabilitySettings", "type": "ImmutabilitySettings"}, + "encryption_settings": {"key": "encryptionSettings", "type": "EncryptionSettings"}, } def __init__( @@ -6593,6 +6804,7 @@ def __init__( *, soft_delete_settings: Optional["_models.SoftDeleteSettings"] = None, immutability_settings: Optional["_models.ImmutabilitySettings"] = None, + encryption_settings: Optional["_models.EncryptionSettings"] = None, **kwargs: Any ) -> None: """ @@ -6600,10 +6812,13 @@ def __init__( :paramtype soft_delete_settings: ~azure.mgmt.dataprotection.models.SoftDeleteSettings :keyword immutability_settings: Immutability Settings at vault level. :paramtype immutability_settings: ~azure.mgmt.dataprotection.models.ImmutabilitySettings + :keyword encryption_settings: Customer Managed Key details of the resource. + :paramtype encryption_settings: ~azure.mgmt.dataprotection.models.EncryptionSettings """ super().__init__(**kwargs) self.soft_delete_settings = soft_delete_settings self.immutability_settings = immutability_settings + self.encryption_settings = encryption_settings class SoftDeleteSettings(_serialization.Model): @@ -6641,7 +6856,7 @@ def __init__( class SourceLifeCycle(_serialization.Model): """Source LifeCycle. - 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 delete_after: Delete Option. Required. :vartype delete_after: ~azure.mgmt.dataprotection.models.DeleteOption @@ -6686,6 +6901,28 @@ def __init__( self.target_data_store_copy_settings = target_data_store_copy_settings +class StopProtectionRequest(_serialization.Model): + """Request body of Stop protection when MUA is Enabled. + + :ivar resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check will + be performed. + :vartype resource_guard_operation_requests: list[str] + """ + + _attribute_map = { + "resource_guard_operation_requests": {"key": "resourceGuardOperationRequests", "type": "[str]"}, + } + + def __init__(self, *, resource_guard_operation_requests: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check + will be performed. + :paramtype resource_guard_operation_requests: list[str] + """ + super().__init__(**kwargs) + self.resource_guard_operation_requests = resource_guard_operation_requests + + class StorageSetting(_serialization.Model): """Storage setting. @@ -6763,6 +7000,28 @@ def __init__( self.exposure_controlled_features = exposure_controlled_features +class SuspendBackupRequest(_serialization.Model): + """Request body of Suspend backup when MUA is Enabled. + + :ivar resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check will + be performed. + :vartype resource_guard_operation_requests: list[str] + """ + + _attribute_map = { + "resource_guard_operation_requests": {"key": "resourceGuardOperationRequests", "type": "[str]"}, + } + + def __init__(self, *, resource_guard_operation_requests: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check + will be performed. + :paramtype resource_guard_operation_requests: list[str] + """ + super().__init__(**kwargs) + self.resource_guard_operation_requests = resource_guard_operation_requests + + class SyncBackupInstanceRequest(_serialization.Model): """Sync BackupInstance Request. @@ -6852,7 +7111,7 @@ def __init__( class TaggingCriteria(_serialization.Model): """Tagging criteria. - 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 criteria: Criteria which decides whether the tag can be applied to a triggered backup. :vartype criteria: list[~azure.mgmt.dataprotection.models.BackupCriteria] @@ -6906,7 +7165,7 @@ def __init__( class TargetCopySetting(_serialization.Model): """Target copy settings. - 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 copy_after: It can be CustomCopyOption or ImmediateCopyOption. Required. :vartype copy_after: ~azure.mgmt.dataprotection.models.CopyOption @@ -6941,7 +7200,7 @@ def __init__( class TargetDetails(_serialization.Model): """Class encapsulating target details, used where the destination is not a datasource. - 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 file_prefix: Restore operation may create multiple files inside location pointed by Url Below will be the common prefix for all of them. Required. @@ -7018,7 +7277,7 @@ def __init__( class TriggerBackupRequest(_serialization.Model): """Trigger backup 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 backup_rule_options: Name for the Rule of the Policy which needs to be applied for this backup. Required. @@ -7046,7 +7305,8 @@ def __init__(self, *, backup_rule_options: "_models.AdHocBackupRuleOptions", **k class UnlockDeleteRequest(_serialization.Model): """Request body of unlock delete API. - :ivar resource_guard_operation_requests: + :ivar resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check will + be performed. :vartype resource_guard_operation_requests: list[str] :ivar resource_to_be_deleted: :vartype resource_to_be_deleted: str @@ -7065,7 +7325,8 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword resource_guard_operation_requests: + :keyword resource_guard_operation_requests: ResourceGuardOperationRequests on which LAC check + will be performed. :paramtype resource_guard_operation_requests: list[str] :keyword resource_to_be_deleted: :paramtype resource_to_be_deleted: str @@ -7210,7 +7471,7 @@ class UserFacingWarningDetail(_serialization.Model): """Warning object used by layers that have access to localized content, and propagate that to user. - 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 resource_name: Name of resource for which warning is raised. :vartype resource_name: str @@ -7244,7 +7505,7 @@ def __init__( class ValidateCrossRegionRestoreRequestObject(_serialization.Model): """Cross Region Restore Request Object. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar restore_request_object: Gets or sets the restore request object. Required. :vartype restore_request_object: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest @@ -7285,7 +7546,7 @@ def __init__( class ValidateForBackupRequest(_serialization.Model): """Validate for backup 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 backup_instance: Backup Instance. Required. :vartype backup_instance: ~azure.mgmt.dataprotection.models.BackupInstance @@ -7311,7 +7572,7 @@ def __init__(self, *, backup_instance: "_models.BackupInstance", **kwargs: Any) class ValidateRestoreRequestObject(_serialization.Model): """Validate restore request object. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar restore_request_object: Gets or sets the restore request object. Required. :vartype restore_request_object: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/__init__.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/__init__.py index 3080328f08e9..42904f5f3feb 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/__init__.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/__init__.py @@ -20,6 +20,7 @@ from ._fetch_secondary_recovery_points_operations import FetchSecondaryRecoveryPointsOperations from ._fetch_cross_region_restore_job_operations import FetchCrossRegionRestoreJobOperations from ._fetch_cross_region_restore_jobs_operations import FetchCrossRegionRestoreJobsOperations +from ._backup_instances_extension_routing_operations import BackupInstancesExtensionRoutingOperations from ._jobs_operations import JobsOperations from ._restorable_time_ranges_operations import RestorableTimeRangesOperations from ._export_jobs_operations import ExportJobsOperations @@ -47,6 +48,7 @@ "FetchSecondaryRecoveryPointsOperations", "FetchCrossRegionRestoreJobOperations", "FetchCrossRegionRestoreJobsOperations", + "BackupInstancesExtensionRoutingOperations", "JobsOperations", "RestorableTimeRangesOperations", "ExportJobsOperations", diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_instances_extension_routing_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_instances_extension_routing_operations.py new file mode 100644 index 000000000000..72539a393fa2 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_instances_extension_routing_operations.py @@ -0,0 +1,161 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.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 + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.DataProtection/backupInstances") + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BackupInstancesExtensionRoutingOperations: # pylint: disable=name-too-long + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.dataprotection.DataProtectionMgmtClient`'s + :attr:`backup_instances_extension_routing` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_id: str, **kwargs: Any) -> Iterable["_models.BackupInstanceResource"]: + """Gets a list of backup instances associated with a tracked resource. + + :param resource_id: ARM path of the resource to be protected using Microsoft.DataProtection. + Required. + :type resource_id: str + :return: An iterator like instance of either BackupInstanceResource or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.BackupInstanceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BackupInstanceResourceList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_id=resource_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BackupInstanceResourceList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_instances_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_instances_operations.py index 37ddc77a1914..3a52ed7bbbf2 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_instances_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_instances_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 ( @@ -20,9 +21,8 @@ ) 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 +30,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 +46,7 @@ def build_list_request(resource_group_name: str, vault_name: str, subscription_i _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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,7 +79,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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -105,12 +108,18 @@ def build_get_request( def build_create_or_update_request( - resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + subscription_id: str, + *, + x_ms_authorization_auxiliary: Optional[str] = None, + **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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -134,6 +143,10 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if x_ms_authorization_auxiliary is not None: + _headers["x-ms-authorization-auxiliary"] = _SERIALIZER.header( + "x_ms_authorization_auxiliary", x_ms_authorization_auxiliary, "str" + ) if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -142,12 +155,18 @@ def build_create_or_update_request( def build_delete_request( - resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + subscription_id: str, + *, + x_ms_authorization_auxiliary: Optional[str] = None, + **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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -170,6 +189,10 @@ def build_delete_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if x_ms_authorization_auxiliary is not None: + _headers["x-ms-authorization-auxiliary"] = _SERIALIZER.header( + "x_ms_authorization_auxiliary", x_ms_authorization_auxiliary, "str" + ) _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) @@ -181,7 +204,7 @@ def build_adhoc_backup_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -218,7 +241,7 @@ def build_validate_for_backup_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -248,7 +271,7 @@ def build_validate_for_backup_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_backup_instance_operation_result_request( +def build_get_backup_instance_operation_result_request( # pylint: disable=name-too-long resource_group_name: str, vault_name: str, backup_instance_name: str, @@ -259,7 +282,7 @@ def build_get_backup_instance_operation_result_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -288,13 +311,13 @@ def build_get_backup_instance_operation_result_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_trigger_cross_region_restore_request( +def build_trigger_cross_region_restore_request( # pylint: disable=name-too-long resource_group_name: str, location: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -324,13 +347,13 @@ def build_trigger_cross_region_restore_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_validate_cross_region_restore_request( +def build_validate_cross_region_restore_request( # pylint: disable=name-too-long resource_group_name: str, location: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -366,7 +389,7 @@ def build_trigger_rehydrate_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -398,12 +421,18 @@ def build_trigger_rehydrate_request( def build_trigger_restore_request( - resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + subscription_id: str, + *, + x_ms_authorization_auxiliary: Optional[str] = None, + **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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -427,6 +456,10 @@ def build_trigger_restore_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if x_ms_authorization_auxiliary is not None: + _headers["x-ms-authorization-auxiliary"] = _SERIALIZER.header( + "x_ms_authorization_auxiliary", x_ms_authorization_auxiliary, "str" + ) if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -440,7 +473,7 @@ def build_resume_backups_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -474,7 +507,7 @@ def build_resume_protection_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -503,12 +536,19 @@ def build_resume_protection_request( def build_stop_protection_request( - resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + subscription_id: str, + *, + x_ms_authorization_auxiliary: Optional[str] = None, + **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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -531,18 +571,31 @@ def build_stop_protection_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if x_ms_authorization_auxiliary is not None: + _headers["x-ms-authorization-auxiliary"] = _SERIALIZER.header( + "x_ms_authorization_auxiliary", x_ms_authorization_auxiliary, "str" + ) + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_suspend_backups_request( - resource_group_name: str, vault_name: str, backup_instance_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + subscription_id: str, + *, + x_ms_authorization_auxiliary: Optional[str] = None, + **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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -565,6 +618,12 @@ def build_suspend_backups_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if x_ms_authorization_auxiliary is not None: + _headers["x-ms-authorization-auxiliary"] = _SERIALIZER.header( + "x_ms_authorization_auxiliary", x_ms_authorization_auxiliary, "str" + ) + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) @@ -576,7 +635,7 @@ def build_sync_backup_instance_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -613,7 +672,7 @@ def build_validate_for_restore_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -674,7 +733,6 @@ def list( :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BackupInstanceResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.BackupInstanceResource] @@ -686,7 +744,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackupInstanceResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -697,17 +755,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, vault_name=vault_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 @@ -719,13 +775,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("BackupInstanceResourceList", pipeline_response) @@ -735,11 +790,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 @@ -751,10 +806,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances" - } - @distributed_trace def get( self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any @@ -768,12 +819,11 @@ def get( :type vault_name: str :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BackupInstanceResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BackupInstanceResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -787,22 +837,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackupInstanceResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_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 @@ -811,26 +859,23 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BackupInstanceResource", pipeline_response) + deserialized = self._deserialize("BackupInstanceResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.BackupInstanceResource, IO], + parameters: Union[_models.BackupInstanceResource, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.BackupInstanceResource]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -843,7 +888,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.BackupInstanceResource]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -853,40 +898,39 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "BackupInstanceResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, subscription_id=self._config.subscription_id, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize("BackupInstanceResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 201: - deserialized = self._deserialize("BackupInstanceResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -894,14 +938,12 @@ def _create_or_update_initial( "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -910,6 +952,7 @@ def begin_create_or_update( vault_name: str, backup_instance_name: str, parameters: _models.BackupInstanceResource, + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -925,17 +968,11 @@ def begin_create_or_update( :type backup_instance_name: str :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.BackupInstanceResource + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either BackupInstanceResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupInstanceResource] @@ -948,7 +985,8 @@ def begin_create_or_update( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: IO, + parameters: IO[bytes], + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -963,18 +1001,12 @@ def begin_create_or_update( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either BackupInstanceResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupInstanceResource] @@ -987,7 +1019,8 @@ def begin_create_or_update( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.BackupInstanceResource, IO], + parameters: Union[_models.BackupInstanceResource, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any ) -> LROPoller[_models.BackupInstanceResource]: """Create or update a backup instance in a backup vault. @@ -999,20 +1032,11 @@ def begin_create_or_update( :type vault_name: str :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str - :param parameters: Request body for operation. Is either a BackupInstanceResource type or a IO - type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.BackupInstanceResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Request body for operation. Is either a BackupInstanceResource type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.BackupInstanceResource or IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :return: An instance of LROPoller that returns either BackupInstanceResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupInstanceResource] @@ -1033,6 +1057,7 @@ def begin_create_or_update( vault_name=vault_name, backup_instance_name=backup_instance_name, parameters=parameters, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1040,12 +1065,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BackupInstanceResource", pipeline_response) + deserialized = self._deserialize("BackupInstanceResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1055,22 +1081,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BackupInstanceResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}" - } + return LROPoller[_models.BackupInstanceResource]( + 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, vault_name: str, backup_instance_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1082,33 +1111,36 @@ 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, vault_name=vault_name, backup_instance_name=backup_instance_name, subscription_id=self._config.subscription_id, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, 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 + _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]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( @@ -1116,16 +1148,24 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline) + + if response.status_code == 204: + deserialized = response.stream_download(self._client._pipeline) + 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.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( - self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + **kwargs: Any ) -> LROPoller[None]: """Delete a backup instance in a backup vault. @@ -1136,14 +1176,8 @@ def begin_delete( :type vault_name: str :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_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. + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :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: @@ -1157,21 +1191,23 @@ 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, vault_name=vault_name, backup_instance_name=backup_instance_name, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1180,27 +1216,23 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _adhoc_backup_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.TriggerBackupRequest, IO], + parameters: Union[_models.TriggerBackupRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OperationJobExtendedInfo]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1213,7 +1245,7 @@ def _adhoc_backup_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.OperationJobExtendedInfo]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1223,7 +1255,7 @@ def _adhoc_backup_initial( else: _json = self._serialize.body(parameters, "TriggerBackupRequest") - request = build_adhoc_backup_request( + _request = build_adhoc_backup_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -1232,28 +1264,26 @@ def _adhoc_backup_initial( content_type=content_type, json=_json, content=_content, - template_url=self._adhoc_backup_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -1262,14 +1292,12 @@ def _adhoc_backup_initial( ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _adhoc_backup_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/backup" - } + return deserialized # type: ignore @overload def begin_adhoc_backup( @@ -1296,14 +1324,6 @@ def begin_adhoc_backup( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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 OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1317,7 +1337,7 @@ def begin_adhoc_backup( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1332,18 +1352,10 @@ def begin_adhoc_backup( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1357,7 +1369,7 @@ def begin_adhoc_backup( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.TriggerBackupRequest, IO], + parameters: Union[_models.TriggerBackupRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.OperationJobExtendedInfo]: """Trigger adhoc backup. @@ -1369,20 +1381,9 @@ def begin_adhoc_backup( :type vault_name: str :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str - :param parameters: Request body for operation. Is either a TriggerBackupRequest type or a IO - type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.TriggerBackupRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Request body for operation. Is either a TriggerBackupRequest type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.TriggerBackupRequest or IO[bytes] :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1411,12 +1412,13 @@ def begin_adhoc_backup( 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("OperationJobExtendedInfo", pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1428,26 +1430,24 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.OperationJobExtendedInfo].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_adhoc_backup.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/backup" - } + return LROPoller[_models.OperationJobExtendedInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _validate_for_backup_initial( self, resource_group_name: str, vault_name: str, - parameters: Union[_models.ValidateForBackupRequest, IO], + parameters: Union[_models.ValidateForBackupRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OperationJobExtendedInfo]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1460,7 +1460,7 @@ def _validate_for_backup_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.OperationJobExtendedInfo]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1470,7 +1470,7 @@ def _validate_for_backup_initial( else: _json = self._serialize.body(parameters, "ValidateForBackupRequest") - request = build_validate_for_backup_request( + _request = build_validate_for_backup_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, @@ -1478,28 +1478,26 @@ def _validate_for_backup_initial( content_type=content_type, json=_json, content=_content, - template_url=self._validate_for_backup_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -1508,14 +1506,12 @@ def _validate_for_backup_initial( ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _validate_for_backup_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/validateForBackup" - } + return deserialized # type: ignore @overload def begin_validate_for_backup( @@ -1539,14 +1535,6 @@ def begin_validate_for_backup( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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 OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1559,7 +1547,7 @@ def begin_validate_for_backup( self, resource_group_name: str, vault_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1572,18 +1560,10 @@ def begin_validate_for_backup( :param vault_name: The name of the backup vault. Required. :type vault_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1596,7 +1576,7 @@ def begin_validate_for_backup( self, resource_group_name: str, vault_name: str, - parameters: Union[_models.ValidateForBackupRequest, IO], + parameters: Union[_models.ValidateForBackupRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.OperationJobExtendedInfo]: """Validate whether adhoc backup will be successful or not. @@ -1607,19 +1587,8 @@ def begin_validate_for_backup( :param vault_name: The name of the backup vault. Required. :type vault_name: str :param parameters: Request body for operation. Is either a ValidateForBackupRequest type or a - IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.ValidateForBackupRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ValidateForBackupRequest or IO[bytes] :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1647,12 +1616,13 @@ def begin_validate_for_backup( 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("OperationJobExtendedInfo", pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1664,17 +1634,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.OperationJobExtendedInfo].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_validate_for_backup.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/validateForBackup" - } + return LROPoller[_models.OperationJobExtendedInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def get_backup_instance_operation_result( @@ -1691,12 +1659,11 @@ def get_backup_instance_operation_result( :type backup_instance_name: str :param operation_id: Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BackupInstanceResource or None or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BackupInstanceResource or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1710,23 +1677,21 @@ def get_backup_instance_operation_result( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.BackupInstanceResource]] = kwargs.pop("cls", None) - request = build_get_backup_instance_operation_result_request( + _request = build_get_backup_instance_operation_result_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_backup_instance_operation_result.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1737,25 +1702,21 @@ def get_backup_instance_operation_result( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("BackupInstanceResource", pipeline_response) + deserialized = self._deserialize("BackupInstanceResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_backup_instance_operation_result.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/operationResults/{operationId}" - } + return deserialized # type: ignore def _trigger_cross_region_restore_initial( self, resource_group_name: str, location: str, - parameters: Union[_models.CrossRegionRestoreRequestObject, IO], + parameters: Union[_models.CrossRegionRestoreRequestObject, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OperationJobExtendedInfo]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1768,7 +1729,7 @@ def _trigger_cross_region_restore_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.OperationJobExtendedInfo]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1778,7 +1739,7 @@ def _trigger_cross_region_restore_initial( else: _json = self._serialize.body(parameters, "CrossRegionRestoreRequestObject") - request = build_trigger_cross_region_restore_request( + _request = build_trigger_cross_region_restore_request( resource_group_name=resource_group_name, location=location, subscription_id=self._config.subscription_id, @@ -1786,29 +1747,27 @@ def _trigger_cross_region_restore_initial( content_type=content_type, json=_json, content=_content, - template_url=self._trigger_cross_region_restore_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + response.read() # Load the body in memory and close the socket 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("OperationJobExtendedInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -1817,14 +1776,12 @@ def _trigger_cross_region_restore_initial( ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _trigger_cross_region_restore_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/crossRegionRestore" - } + return deserialized # type: ignore @overload def begin_trigger_cross_region_restore( @@ -1848,14 +1805,6 @@ def begin_trigger_cross_region_restore( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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 OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1868,7 +1817,7 @@ def begin_trigger_cross_region_restore( self, resource_group_name: str, location: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1881,18 +1830,10 @@ def begin_trigger_cross_region_restore( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for trigger CRR operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1905,7 +1846,7 @@ def begin_trigger_cross_region_restore( self, resource_group_name: str, location: str, - parameters: Union[_models.CrossRegionRestoreRequestObject, IO], + parameters: Union[_models.CrossRegionRestoreRequestObject, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.OperationJobExtendedInfo]: """Triggers Cross Region Restore for BackupInstance. @@ -1916,19 +1857,9 @@ def begin_trigger_cross_region_restore( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for trigger CRR operation. Is either a - CrossRegionRestoreRequestObject type or a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.CrossRegionRestoreRequestObject or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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. + CrossRegionRestoreRequestObject type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.CrossRegionRestoreRequestObject or + IO[bytes] :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -1956,12 +1887,13 @@ def begin_trigger_cross_region_restore( 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("OperationJobExtendedInfo", pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1973,26 +1905,24 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.OperationJobExtendedInfo].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_trigger_cross_region_restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/crossRegionRestore" - } + return LROPoller[_models.OperationJobExtendedInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _validate_cross_region_restore_initial( self, resource_group_name: str, location: str, - parameters: Union[_models.ValidateCrossRegionRestoreRequestObject, IO], + parameters: Union[_models.ValidateCrossRegionRestoreRequestObject, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OperationJobExtendedInfo]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2005,7 +1935,7 @@ def _validate_cross_region_restore_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.OperationJobExtendedInfo]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -2015,7 +1945,7 @@ def _validate_cross_region_restore_initial( else: _json = self._serialize.body(parameters, "ValidateCrossRegionRestoreRequestObject") - request = build_validate_cross_region_restore_request( + _request = build_validate_cross_region_restore_request( resource_group_name=resource_group_name, location=location, subscription_id=self._config.subscription_id, @@ -2023,29 +1953,27 @@ def _validate_cross_region_restore_initial( content_type=content_type, json=_json, content=_content, - template_url=self._validate_cross_region_restore_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + response.read() # Load the body in memory and close the socket 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("OperationJobExtendedInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -2054,14 +1982,12 @@ def _validate_cross_region_restore_initial( ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _validate_cross_region_restore_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/validateCrossRegionRestore" - } + return deserialized # type: ignore @overload def begin_validate_cross_region_restore( @@ -2085,14 +2011,6 @@ def begin_validate_cross_region_restore( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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 OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -2105,7 +2023,7 @@ def begin_validate_cross_region_restore( self, resource_group_name: str, location: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2118,18 +2036,10 @@ def begin_validate_cross_region_restore( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -2142,7 +2052,7 @@ def begin_validate_cross_region_restore( self, resource_group_name: str, location: str, - parameters: Union[_models.ValidateCrossRegionRestoreRequestObject, IO], + parameters: Union[_models.ValidateCrossRegionRestoreRequestObject, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.OperationJobExtendedInfo]: """Validates whether Cross Region Restore can be triggered for DataSource. @@ -2153,20 +2063,9 @@ def begin_validate_cross_region_restore( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for operation. Is either a - ValidateCrossRegionRestoreRequestObject type or a IO type. Required. + ValidateCrossRegionRestoreRequestObject type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.dataprotection.models.ValidateCrossRegionRestoreRequestObject or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -2194,12 +2093,13 @@ def begin_validate_cross_region_restore( 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("OperationJobExtendedInfo", pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2211,27 +2111,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.OperationJobExtendedInfo].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_validate_cross_region_restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/validateCrossRegionRestore" - } + return LROPoller[_models.OperationJobExtendedInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _trigger_rehydrate_initial( # pylint: disable=inconsistent-return-statements + def _trigger_rehydrate_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.AzureBackupRehydrationRequest, IO], + parameters: Union[_models.AzureBackupRehydrationRequest, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2244,7 +2142,7 @@ def _trigger_rehydrate_initial( # pylint: disable=inconsistent-return-statement 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[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -2254,7 +2152,7 @@ def _trigger_rehydrate_initial( # pylint: disable=inconsistent-return-statement else: _json = self._serialize.body(parameters, "AzureBackupRehydrationRequest") - request = build_trigger_rehydrate_request( + _request = build_trigger_rehydrate_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -2263,21 +2161,20 @@ def _trigger_rehydrate_initial( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, content=_content, - template_url=self._trigger_rehydrate_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -2289,12 +2186,15 @@ def _trigger_rehydrate_initial( # pylint: disable=inconsistent-return-statement ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline) + + if response.status_code == 204: + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _trigger_rehydrate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/rehydrate" - } + return deserialized # type: ignore @overload def begin_trigger_rehydrate( @@ -2321,14 +2221,6 @@ def begin_trigger_rehydrate( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -2340,7 +2232,7 @@ def begin_trigger_rehydrate( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2355,18 +2247,10 @@ def begin_trigger_rehydrate( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2378,7 +2262,7 @@ def begin_trigger_rehydrate( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.AzureBackupRehydrationRequest, IO], + parameters: Union[_models.AzureBackupRehydrationRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """rehydrate recovery point for restore for a BackupInstance. @@ -2391,19 +2275,8 @@ def begin_trigger_rehydrate( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Is either a AzureBackupRehydrationRequest type - or a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRehydrationRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRehydrationRequest or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2418,7 +2291,7 @@ def begin_trigger_rehydrate( 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._trigger_rehydrate_initial( # type: ignore + raw_result = self._trigger_rehydrate_initial( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -2430,11 +2303,12 @@ def begin_trigger_rehydrate( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -2443,27 +2317,24 @@ 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_trigger_rehydrate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/rehydrate" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _trigger_restore_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.AzureBackupRestoreRequest, IO], + parameters: Union[_models.AzureBackupRestoreRequest, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.OperationJobExtendedInfo]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2476,7 +2347,7 @@ def _trigger_restore_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.OperationJobExtendedInfo]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -2486,37 +2357,36 @@ def _trigger_restore_initial( else: _json = self._serialize.body(parameters, "AzureBackupRestoreRequest") - request = build_trigger_restore_request( + _request = build_trigger_restore_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, subscription_id=self._config.subscription_id, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._trigger_restore_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -2525,14 +2395,12 @@ def _trigger_restore_initial( ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _trigger_restore_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/restore" - } + return deserialized # type: ignore @overload def begin_trigger_restore( @@ -2541,6 +2409,7 @@ def begin_trigger_restore( vault_name: str, backup_instance_name: str, parameters: _models.AzureBackupRestoreRequest, + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2556,17 +2425,11 @@ def begin_trigger_restore( :type backup_instance_name: str :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -2580,7 +2443,8 @@ def begin_trigger_restore( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: IO, + parameters: IO[bytes], + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2595,18 +2459,12 @@ def begin_trigger_restore( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -2620,7 +2478,8 @@ def begin_trigger_restore( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.AzureBackupRestoreRequest, IO], + parameters: Union[_models.AzureBackupRestoreRequest, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any ) -> LROPoller[_models.OperationJobExtendedInfo]: """Triggers restore for a BackupInstance. @@ -2633,19 +2492,10 @@ def begin_trigger_restore( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Is either a AzureBackupRestoreRequest type or a - IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupRestoreRequest or IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -2667,6 +2517,7 @@ def begin_trigger_restore( vault_name=vault_name, backup_instance_name=backup_instance_name, parameters=parameters, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2674,12 +2525,13 @@ def begin_trigger_restore( 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("OperationJobExtendedInfo", pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2691,22 +2543,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.OperationJobExtendedInfo].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_trigger_restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/restore" - } + return LROPoller[_models.OperationJobExtendedInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _resume_backups_initial( # pylint: disable=inconsistent-return-statements + def _resume_backups_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2718,33 +2568,35 @@ def _resume_backups_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_resume_backups_request( + _request = build_resume_backups_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._resume_backups_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( @@ -2752,12 +2604,12 @@ def _resume_backups_initial( # pylint: disable=inconsistent-return-statements ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _resume_backups_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeBackups" - } + return deserialized # type: ignore @distributed_trace def begin_resume_backups( @@ -2772,14 +2624,6 @@ def begin_resume_backups( :type vault_name: str :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_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: @@ -2793,7 +2637,7 @@ def begin_resume_backups( 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._resume_backups_initial( # type: ignore + raw_result = self._resume_backups_initial( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -2803,11 +2647,12 @@ def begin_resume_backups( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -2816,22 +2661,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_resume_backups.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeBackups" - } - - def _resume_protection_initial( # pylint: disable=inconsistent-return-statements + def _resume_protection_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2843,33 +2684,35 @@ def _resume_protection_initial( # pylint: disable=inconsistent-return-statement _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_resume_protection_request( + _request = build_resume_protection_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._resume_protection_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( @@ -2877,12 +2720,12 @@ def _resume_protection_initial( # pylint: disable=inconsistent-return-statement ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _resume_protection_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeProtection" - } + return deserialized # type: ignore @distributed_trace def begin_resume_protection( @@ -2897,14 +2740,6 @@ def begin_resume_protection( :type vault_name: str :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_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: @@ -2918,7 +2753,7 @@ def begin_resume_protection( 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._resume_protection_initial( # type: ignore + raw_result = self._resume_protection_initial( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -2928,11 +2763,12 @@ def begin_resume_protection( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -2941,22 +2777,24 @@ 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_resume_protection.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeProtection" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _stop_protection_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any - ) -> None: - error_map = { + def _stop_protection_initial( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + parameters: Optional[Union[_models.StopProtectionRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2964,37 +2802,55 @@ def _stop_protection_initial( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "StopProtectionRequest") + else: + _json = None - request = build_stop_protection_request( + _request = build_stop_protection_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, subscription_id=self._config.subscription_id, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, - template_url=self._stop_protection_initial.metadata["url"], + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( @@ -3002,16 +2858,88 @@ def _stop_protection_initial( # pylint: disable=inconsistent-return-statements ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _stop_protection_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/stopProtection" - } + return deserialized # type: ignore + + @overload + def begin_stop_protection( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + parameters: Optional[_models.StopProtectionRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """This operation will stop protection of a backup instance and data will be held forever. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str + :param parameters: Request body for operation. Default value is None. + :type parameters: ~azure.mgmt.dataprotection.models.StopProtectionRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_stop_protection( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """This operation will stop protection of a backup instance and data will be held forever. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str + :param parameters: Request body for operation. Default value is None. + :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 + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_stop_protection( - self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + parameters: Optional[Union[_models.StopProtectionRequest, IO[bytes]]] = None, + **kwargs: Any ) -> LROPoller[None]: """This operation will stop protection of a backup instance and data will be held forever. @@ -3022,42 +2950,44 @@ def begin_stop_protection( :type vault_name: str :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_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. + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str + :param parameters: Request body for operation. Is either a StopProtectionRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.dataprotection.models.StopProtectionRequest or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._stop_protection_initial( # type: ignore + raw_result = self._stop_protection_initial( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, + parameters=parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -3066,22 +2996,24 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_stop_protection.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/stopProtection" - } - - def _suspend_backups_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any - ) -> None: - error_map = { + def _suspend_backups_initial( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + parameters: Optional[Union[_models.SuspendBackupRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3089,37 +3021,55 @@ def _suspend_backups_initial( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "SuspendBackupRequest") + else: + _json = None - request = build_suspend_backups_request( + _request = build_suspend_backups_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, subscription_id=self._config.subscription_id, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, - template_url=self._suspend_backups_initial.metadata["url"], + content_type=content_type, + json=_json, + content=_content, headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( @@ -3127,16 +3077,90 @@ def _suspend_backups_initial( # pylint: disable=inconsistent-return-statements ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _suspend_backups_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/suspendBackups" - } + return deserialized # type: ignore + + @overload + def begin_suspend_backups( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + parameters: Optional[_models.SuspendBackupRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """This operation will stop backup for a backup instance and retains the backup data as per the + policy (except latest Recovery point, which will be retained forever). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str + :param parameters: Request body for operation. Default value is None. + :type parameters: ~azure.mgmt.dataprotection.models.SuspendBackupRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_suspend_backups( + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """This operation will stop backup for a backup instance and retains the backup data as per the + policy (except latest Recovery point, which will be retained forever). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param vault_name: The name of the backup vault. Required. + :type vault_name: str + :param backup_instance_name: The name of the backup instance. Required. + :type backup_instance_name: str + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str + :param parameters: Request body for operation. Default value is None. + :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 + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_suspend_backups( - self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any + self, + resource_group_name: str, + vault_name: str, + backup_instance_name: str, + x_ms_authorization_auxiliary: Optional[str] = None, + parameters: Optional[Union[_models.SuspendBackupRequest, IO[bytes]]] = None, + **kwargs: Any ) -> LROPoller[None]: """This operation will stop backup for a backup instance and retains the backup data as per the policy (except latest Recovery point, which will be retained forever). @@ -3148,42 +3172,44 @@ def begin_suspend_backups( :type vault_name: str :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_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. + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str + :param parameters: Request body for operation. Is either a SuspendBackupRequest type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.dataprotection.models.SuspendBackupRequest or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._suspend_backups_initial( # type: ignore + raw_result = self._suspend_backups_initial( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, + parameters=parameters, api_version=api_version, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -3192,27 +3218,23 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_suspend_backups.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/suspendBackups" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _sync_backup_instance_initial( # pylint: disable=inconsistent-return-statements + def _sync_backup_instance_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.SyncBackupInstanceRequest, IO], + parameters: Union[_models.SyncBackupInstanceRequest, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3225,7 +3247,7 @@ def _sync_backup_instance_initial( # pylint: disable=inconsistent-return-statem 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[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -3235,7 +3257,7 @@ def _sync_backup_instance_initial( # pylint: disable=inconsistent-return-statem else: _json = self._serialize.body(parameters, "SyncBackupInstanceRequest") - request = build_sync_backup_instance_request( + _request = build_sync_backup_instance_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -3244,25 +3266,27 @@ def _sync_backup_instance_initial( # pylint: disable=inconsistent-return-statem content_type=content_type, json=_json, content=_content, - template_url=self._sync_backup_instance_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( @@ -3270,12 +3294,12 @@ def _sync_backup_instance_initial( # pylint: disable=inconsistent-return-statem ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _sync_backup_instance_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/sync" - } + return deserialized # type: ignore @overload def begin_sync_backup_instance( @@ -3303,14 +3327,6 @@ def begin_sync_backup_instance( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -3322,7 +3338,7 @@ def begin_sync_backup_instance( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -3338,18 +3354,10 @@ def begin_sync_backup_instance( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -3361,7 +3369,7 @@ def begin_sync_backup_instance( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.SyncBackupInstanceRequest, IO], + parameters: Union[_models.SyncBackupInstanceRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Sync backup instance again in case of failure @@ -3375,19 +3383,8 @@ def begin_sync_backup_instance( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Is either a SyncBackupInstanceRequest type or a - IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.SyncBackupInstanceRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.SyncBackupInstanceRequest or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -3402,7 +3399,7 @@ def begin_sync_backup_instance( 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._sync_backup_instance_initial( # type: ignore + raw_result = self._sync_backup_instance_initial( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -3414,11 +3411,12 @@ def begin_sync_backup_instance( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -3427,27 +3425,23 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_sync_backup_instance.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/sync" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _validate_for_restore_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.ValidateRestoreRequestObject, IO], + parameters: Union[_models.ValidateRestoreRequestObject, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OperationJobExtendedInfo]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3460,7 +3454,7 @@ def _validate_for_restore_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.OperationJobExtendedInfo]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -3470,7 +3464,7 @@ def _validate_for_restore_initial( else: _json = self._serialize.body(parameters, "ValidateRestoreRequestObject") - request = build_validate_for_restore_request( + _request = build_validate_for_restore_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -3479,28 +3473,26 @@ def _validate_for_restore_initial( content_type=content_type, json=_json, content=_content, - template_url=self._validate_for_restore_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -3509,14 +3501,12 @@ def _validate_for_restore_initial( ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _validate_for_restore_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/validateRestore" - } + return deserialized # type: ignore @overload def begin_validate_for_restore( @@ -3543,14 +3533,6 @@ def begin_validate_for_restore( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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 OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -3564,7 +3546,7 @@ def begin_validate_for_restore( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -3579,18 +3561,10 @@ def begin_validate_for_restore( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -3604,7 +3578,7 @@ def begin_validate_for_restore( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.ValidateRestoreRequestObject, IO], + parameters: Union[_models.ValidateRestoreRequestObject, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.OperationJobExtendedInfo]: """Validates if Restore can be triggered for a DataSource. @@ -3617,19 +3591,8 @@ def begin_validate_for_restore( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Is either a ValidateRestoreRequestObject type or - a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.ValidateRestoreRequestObject or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ValidateRestoreRequestObject or IO[bytes] :return: An instance of LROPoller that returns either OperationJobExtendedInfo or the result of cls(response) :rtype: @@ -3658,12 +3621,13 @@ def begin_validate_for_restore( 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("OperationJobExtendedInfo", pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -3675,14 +3639,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.OperationJobExtendedInfo].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_validate_for_restore.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/validateRestore" - } + return LROPoller[_models.OperationJobExtendedInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_policies_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_policies_operations.py index c72eb5e6d556..0ca4a6c08235 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_policies_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_policies_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, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,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]] @@ -41,7 +44,7 @@ def build_list_request(resource_group_name: str, vault_name: str, subscription_i _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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,7 +77,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -108,7 +111,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -145,7 +148,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -203,7 +206,6 @@ def list( :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BaseBackupPolicyResource or the result of cls(response) :rtype: @@ -216,7 +218,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BaseBackupPolicyResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -227,17 +229,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, vault_name=vault_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 @@ -249,13 +249,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("BaseBackupPolicyResourceList", pipeline_response) @@ -265,11 +264,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 @@ -281,10 +280,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies" - } - @distributed_trace def get( self, resource_group_name: str, vault_name: str, backup_policy_name: str, **kwargs: Any @@ -300,12 +295,11 @@ def get( :type vault_name: str :param backup_policy_name: Required. :type backup_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BaseBackupPolicyResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -319,22 +313,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BaseBackupPolicyResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_policy_name=backup_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -343,16 +335,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BaseBackupPolicyResource", pipeline_response) + deserialized = self._deserialize("BaseBackupPolicyResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -381,7 +369,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BaseBackupPolicyResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource :raises ~azure.core.exceptions.HttpResponseError: @@ -393,7 +380,7 @@ def create_or_update( resource_group_name: str, vault_name: str, backup_policy_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -410,11 +397,10 @@ def create_or_update( :param backup_policy_name: Name of the policy. Required. :type backup_policy_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BaseBackupPolicyResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource :raises ~azure.core.exceptions.HttpResponseError: @@ -426,7 +412,7 @@ def create_or_update( resource_group_name: str, vault_name: str, backup_policy_name: str, - parameters: Union[_models.BaseBackupPolicyResource, IO], + parameters: Union[_models.BaseBackupPolicyResource, IO[bytes]], **kwargs: Any ) -> _models.BaseBackupPolicyResource: """Creates or Updates a backup policy belonging to a backup vault. @@ -441,17 +427,13 @@ def create_or_update( :param backup_policy_name: Name of the policy. Required. :type backup_policy_name: str :param parameters: Request body for operation. Is either a BaseBackupPolicyResource type or a - IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource or IO[bytes] :return: BaseBackupPolicyResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BaseBackupPolicyResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -474,7 +456,7 @@ def create_or_update( else: _json = self._serialize.body(parameters, "BaseBackupPolicyResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_policy_name=backup_policy_name, @@ -483,16 +465,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -501,16 +481,12 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BaseBackupPolicyResource", pipeline_response) + deserialized = self._deserialize("BaseBackupPolicyResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -527,12 +503,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type vault_name: str :param backup_policy_name: Required. :type backup_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -546,22 +521,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_policy_name=backup_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -571,8 +544,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_vault_operation_results_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_vault_operation_results_operations.py index dea996b991df..c4cb79a4d144 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_vault_operation_results_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_vault_operation_results_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_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -100,12 +103,11 @@ def get( :type vault_name: str :param operation_id: Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BackupVaultResource or None or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BackupVaultResource or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -119,22 +121,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.BackupVaultResource]] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -146,7 +146,7 @@ def get( deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize("BackupVaultResource", pipeline_response) + deserialized = self._deserialize("BackupVaultResource", pipeline_response.http_response) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -156,10 +156,6 @@ def get( response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/operationResults/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_vaults_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_vaults_operations.py index c252b6781171..1c6ca6764ba9 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_vaults_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_backup_vaults_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 ( @@ -20,9 +21,8 @@ ) 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 +30,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 +46,7 @@ def build_get_in_subscription_request(subscription_id: str, **kwargs: Any) -> Ht _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +70,7 @@ def build_get_in_resource_group_request(resource_group_name: str, subscription_i _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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +100,7 @@ def build_get_request(resource_group_name: str, vault_name: str, subscription_id _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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -125,12 +128,17 @@ def build_get_request(resource_group_name: str, vault_name: str, subscription_id def build_create_or_update_request( - resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + vault_name: str, + subscription_id: str, + *, + x_ms_authorization_auxiliary: Optional[str] = None, + **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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -153,6 +161,10 @@ def build_create_or_update_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if x_ms_authorization_auxiliary is not None: + _headers["x-ms-authorization-auxiliary"] = _SERIALIZER.header( + "x_ms_authorization_auxiliary", x_ms_authorization_auxiliary, "str" + ) if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -164,7 +176,7 @@ def build_delete_request(resource_group_name: str, vault_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -191,11 +203,18 @@ def build_delete_request(resource_group_name: str, vault_name: str, subscription return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request(resource_group_name: str, vault_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_update_request( + resource_group_name: str, + vault_name: str, + subscription_id: str, + *, + x_ms_authorization_auxiliary: Optional[str] = None, + **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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -218,6 +237,10 @@ def build_update_request(resource_group_name: str, vault_name: str, subscription _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if x_ms_authorization_auxiliary is not None: + _headers["x-ms-authorization-auxiliary"] = _SERIALIZER.header( + "x_ms_authorization_auxiliary", x_ms_authorization_auxiliary, "str" + ) if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -231,7 +254,7 @@ def build_check_name_availability_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -284,7 +307,6 @@ def __init__(self, *args, **kwargs): def get_in_subscription(self, **kwargs: Any) -> Iterable["_models.BackupVaultResource"]: """Returns resource collection belonging to a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BackupVaultResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.BackupVaultResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -295,7 +317,7 @@ def get_in_subscription(self, **kwargs: Any) -> Iterable["_models.BackupVaultRes api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackupVaultResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -306,15 +328,13 @@ def get_in_subscription(self, **kwargs: Any) -> Iterable["_models.BackupVaultRes def prepare_request(next_link=None): if not next_link: - request = build_get_in_subscription_request( + _request = build_get_in_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_in_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 @@ -326,13 +346,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("BackupVaultResourceList", pipeline_response) @@ -342,11 +361,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 @@ -358,10 +377,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - get_in_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/backupVaults" - } - @distributed_trace def get_in_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.BackupVaultResource"]: """Returns resource collection belonging to a resource group. @@ -369,7 +384,6 @@ def get_in_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iter :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 BackupVaultResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.BackupVaultResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -380,7 +394,7 @@ def get_in_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iter api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackupVaultResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -391,16 +405,14 @@ def get_in_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iter def prepare_request(next_link=None): if not next_link: - request = build_get_in_resource_group_request( + _request = build_get_in_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_in_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 @@ -412,13 +424,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("BackupVaultResourceList", pipeline_response) @@ -428,11 +439,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,10 +455,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - get_in_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults" - } - @distributed_trace def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _models.BackupVaultResource: """Returns a resource belonging to a resource group. @@ -457,12 +464,11 @@ def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _mode :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BackupVaultResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.BackupVaultResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -476,21 +482,19 @@ def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackupVaultResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_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 @@ -499,25 +503,22 @@ def get(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> _mode map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BackupVaultResource", pipeline_response) + deserialized = self._deserialize("BackupVaultResource", 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.DataProtection/backupVaults/{vaultName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, vault_name: str, - parameters: Union[_models.BackupVaultResource, IO], + parameters: Union[_models.BackupVaultResource, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any - ) -> _models.BackupVaultResource: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -530,7 +531,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.BackupVaultResource] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -540,53 +541,50 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "BackupVaultResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("BackupVaultResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if response.status_code == 201: - deserialized = self._deserialize("BackupVaultResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}" - } - @overload def begin_create_or_update( self, resource_group_name: str, vault_name: str, parameters: _models.BackupVaultResource, + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -600,17 +598,11 @@ def begin_create_or_update( :type vault_name: str :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.BackupVaultResource + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either BackupVaultResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] @@ -622,7 +614,8 @@ def begin_create_or_update( self, resource_group_name: str, vault_name: str, - parameters: IO, + parameters: IO[bytes], + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -635,18 +628,12 @@ def begin_create_or_update( :param vault_name: The name of the backup vault. Required. :type vault_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either BackupVaultResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] @@ -658,7 +645,8 @@ def begin_create_or_update( self, resource_group_name: str, vault_name: str, - parameters: Union[_models.BackupVaultResource, IO], + parameters: Union[_models.BackupVaultResource, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any ) -> LROPoller[_models.BackupVaultResource]: """Creates or updates a BackupVault resource belonging to a resource group. @@ -668,20 +656,11 @@ def begin_create_or_update( :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_name: str - :param parameters: Request body for operation. Is either a BackupVaultResource type or a IO - type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.BackupVaultResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/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: Request body for operation. Is either a BackupVaultResource type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.BackupVaultResource or IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :return: An instance of LROPoller that returns either BackupVaultResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] @@ -701,6 +680,7 @@ def begin_create_or_update( resource_group_name=resource_group_name, vault_name=vault_name, parameters=parameters, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -708,12 +688,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BackupVaultResource", pipeline_response) + deserialized = self._deserialize("BackupVaultResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -723,22 +704,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BackupVaultResource].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}" - } + return LROPoller[_models.BackupVaultResource]( + 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, vault_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -750,37 +727,43 @@ 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, vault_name=vault_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 + _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]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + + if response.status_code == 202: + deserialized = response.stream_download(self._client._pipeline) + + if response.status_code == 204: + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> LROPoller[None]: @@ -791,14 +774,6 @@ def begin_delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_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: @@ -812,7 +787,7 @@ def begin_delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, vault_name=vault_name, api_version=api_version, @@ -821,11 +796,12 @@ def begin_delete(self, resource_group_name: str, vault_name: str, **kwargs: Any) params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -834,26 +810,23 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _update_initial( self, resource_group_name: str, vault_name: str, - parameters: Union[_models.PatchResourceRequestInput, IO], + parameters: Union[_models.PatchResourceRequestInput, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.BackupVaultResource]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -866,7 +839,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.BackupVaultResource]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -876,44 +849,42 @@ def _update_initial( else: _json = self._serialize.body(parameters, "PatchResourceRequestInput") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize("BackupVaultResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline) - if cls: - return cls(pipeline_response, deserialized, {}) + if response.status_code == 202: + deserialized = response.stream_download(self._client._pipeline) - return deserialized + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -921,6 +892,7 @@ def begin_update( resource_group_name: str, vault_name: str, parameters: _models.PatchResourceRequestInput, + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -935,17 +907,11 @@ def begin_update( :type vault_name: str :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceRequestInput + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either BackupVaultResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] @@ -957,7 +923,8 @@ def begin_update( self, resource_group_name: str, vault_name: str, - parameters: IO, + parameters: IO[bytes], + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -971,18 +938,12 @@ def begin_update( :param vault_name: The name of the backup vault. Required. :type vault_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either BackupVaultResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] @@ -994,7 +955,8 @@ def begin_update( self, resource_group_name: str, vault_name: str, - parameters: Union[_models.PatchResourceRequestInput, IO], + parameters: Union[_models.PatchResourceRequestInput, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any ) -> LROPoller[_models.BackupVaultResource]: """Updates a BackupVault resource belonging to a resource group. For example, updating tags for a @@ -1006,19 +968,10 @@ def begin_update( :param vault_name: The name of the backup vault. Required. :type vault_name: str :param parameters: Request body for operation. Is either a PatchResourceRequestInput type or a - IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceRequestInput or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceRequestInput or IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :return: An instance of LROPoller that returns either BackupVaultResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.dataprotection.models.BackupVaultResource] @@ -1038,6 +991,7 @@ def begin_update( resource_group_name=resource_group_name, vault_name=vault_name, parameters=parameters, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -1045,12 +999,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("BackupVaultResource", pipeline_response) + deserialized = self._deserialize("BackupVaultResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1060,17 +1015,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BackupVaultResource].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.DataProtection/backupVaults/{vaultName}" - } + return LROPoller[_models.BackupVaultResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @overload def check_name_availability( @@ -1096,7 +1049,6 @@ def check_name_availability( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1107,7 +1059,7 @@ def check_name_availability( self, resource_group_name: str, location: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1122,11 +1074,10 @@ def check_name_availability( :param location: The location in which uniqueness will be verified. Required. :type location: str :param parameters: Check name availability request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1137,7 +1088,7 @@ def check_name_availability( self, resource_group_name: str, location: str, - parameters: Union[_models.CheckNameAvailabilityRequest, IO], + parameters: Union[_models.CheckNameAvailabilityRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """API to check for resource name availability. @@ -1150,17 +1101,13 @@ def check_name_availability( :param location: The location in which uniqueness will be verified. Required. :type location: str :param parameters: Check name availability request. Is either a CheckNameAvailabilityRequest - type or a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityRequest or IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1183,7 +1130,7 @@ def check_name_availability( else: _json = self._serialize.body(parameters, "CheckNameAvailabilityRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, location=location, subscription_id=self._config.subscription_id, @@ -1191,16 +1138,14 @@ def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1209,13 +1154,9 @@ def check_name_availability( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_data_protection_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_data_protection_operations.py index 669a513b2fd5..a26a37206b07 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_data_protection_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_data_protection_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, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,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]] @@ -39,7 +42,7 @@ def build_check_feature_support_request(location: str, subscription_id: str, **k _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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -105,7 +108,6 @@ def check_feature_support( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FeatureValidationResponseBase or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.FeatureValidationResponseBase :raises ~azure.core.exceptions.HttpResponseError: @@ -113,7 +115,7 @@ def check_feature_support( @overload def check_feature_support( - self, location: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.FeatureValidationResponseBase: """Validates if a feature is supported. @@ -122,11 +124,10 @@ def check_feature_support( :param location: Required. :type location: str :param parameters: Feature support request 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 :return: FeatureValidationResponseBase or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.FeatureValidationResponseBase :raises ~azure.core.exceptions.HttpResponseError: @@ -134,7 +135,7 @@ def check_feature_support( @distributed_trace def check_feature_support( - self, location: str, parameters: Union[_models.FeatureValidationRequestBase, IO], **kwargs: Any + self, location: str, parameters: Union[_models.FeatureValidationRequestBase, IO[bytes]], **kwargs: Any ) -> _models.FeatureValidationResponseBase: """Validates if a feature is supported. @@ -143,17 +144,13 @@ def check_feature_support( :param location: Required. :type location: str :param parameters: Feature support request object. Is either a FeatureValidationRequestBase - type or a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.FeatureValidationRequestBase or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.FeatureValidationRequestBase or IO[bytes] :return: FeatureValidationResponseBase or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.FeatureValidationResponseBase :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -176,23 +173,21 @@ def check_feature_support( else: _json = self._serialize.body(parameters, "FeatureValidationRequestBase") - request = build_check_feature_support_request( + _request = build_check_feature_support_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_feature_support.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -201,13 +196,9 @@ def check_feature_support( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("FeatureValidationResponseBase", pipeline_response) + deserialized = self._deserialize("FeatureValidationResponseBase", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_feature_support.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/checkFeatureSupport" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_data_protection_operations_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_data_protection_operations_operations.py index fdc7ab65a90f..1dffce31540b 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_data_protection_operations_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_data_protection_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-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.ClientDiscoveryValueForSingleApi"]: """Returns the list of available operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ClientDiscoveryValueForSingleApi or the result of cls(response) :rtype: @@ -91,7 +93,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.ClientDiscoveryValueForSingle api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ClientDiscoveryResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -102,14 +104,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.ClientDiscoveryValueForSingle 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 @@ -121,13 +121,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("ClientDiscoveryResponse", pipeline_response) @@ -137,11 +136,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 @@ -152,5 +151,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.DataProtection/operations"} diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_deleted_backup_instances_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_deleted_backup_instances_operations.py index 7410ceec8140..5e081dfb08fc 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_deleted_backup_instances_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_deleted_backup_instances_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, Union, cast +import sys +from typing import Any, Callable, Dict, Iterable, Iterator, Optional, Type, TypeVar, Union, cast import urllib.parse from azure.core.exceptions import ( @@ -19,9 +20,8 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -29,8 +29,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]] @@ -42,7 +45,7 @@ def build_list_request(resource_group_name: str, vault_name: str, subscription_i _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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -75,7 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,7 +112,7 @@ def build_undelete_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -167,7 +170,6 @@ def list( :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DeletedBackupInstanceResource or the result of cls(response) :rtype: @@ -180,7 +182,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DeletedBackupInstanceResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -191,17 +193,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, vault_name=vault_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 @@ -213,13 +213,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("DeletedBackupInstanceResourceList", pipeline_response) @@ -229,11 +228,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 @@ -245,10 +244,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances" - } - @distributed_trace def get( self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any @@ -262,12 +257,11 @@ def get( :type vault_name: str :param backup_instance_name: The name of the deleted backup instance. Required. :type backup_instance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DeletedBackupInstanceResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DeletedBackupInstanceResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -281,22 +275,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DeletedBackupInstanceResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_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 @@ -305,21 +297,17 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DeletedBackupInstanceResource", pipeline_response) + deserialized = self._deserialize("DeletedBackupInstanceResource", 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.DataProtection/backupVaults/{vaultName}/deletedBackupInstances/{backupInstanceName}" - } + return deserialized # type: ignore - def _undelete_initial( # pylint: disable=inconsistent-return-statements + def _undelete_initial( self, resource_group_name: str, vault_name: str, backup_instance_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -331,38 +319,41 @@ def _undelete_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_undelete_request( + _request = build_undelete_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._undelete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _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]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if response.status_code == 200: + deserialized = response.stream_download(self._client._pipeline) + + if response.status_code == 202: + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _undelete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances/{backupInstanceName}/undelete" - } + return deserialized # type: ignore @distributed_trace def begin_undelete( @@ -377,14 +368,6 @@ def begin_undelete( :type vault_name: str :param backup_instance_name: The name of the deleted backup instance. Required. :type backup_instance_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: @@ -398,7 +381,7 @@ def begin_undelete( 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._undelete_initial( # type: ignore + raw_result = self._undelete_initial( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -408,11 +391,12 @@ def begin_undelete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -421,14 +405,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_undelete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances/{backupInstanceName}/undelete" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_dpp_resource_guard_proxy_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_dpp_resource_guard_proxy_operations.py index 592c0f21bf62..e86757f12a85 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_dpp_resource_guard_proxy_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_dpp_resource_guard_proxy_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, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,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]] @@ -41,7 +44,7 @@ def build_list_request(resource_group_name: str, vault_name: str, subscription_i _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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,7 +77,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -110,7 +113,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -149,7 +152,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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -180,12 +183,18 @@ def build_delete_request( def build_unlock_delete_request( - resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, subscription_id: str, **kwargs: Any + resource_group_name: str, + vault_name: str, + resource_guard_proxy_name: str, + subscription_id: str, + *, + x_ms_authorization_auxiliary: Optional[str] = None, + **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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -211,6 +220,10 @@ def build_unlock_delete_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if x_ms_authorization_auxiliary is not None: + _headers["x-ms-authorization-auxiliary"] = _SERIALIZER.header( + "x_ms_authorization_auxiliary", x_ms_authorization_auxiliary, "str" + ) if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -250,7 +263,6 @@ def list( :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceGuardProxyBaseResource or the result of cls(response) :rtype: @@ -263,7 +275,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceGuardProxyBaseResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -274,17 +286,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, vault_name=vault_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 @@ -296,13 +306,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("ResourceGuardProxyBaseResourceList", pipeline_response) @@ -312,11 +321,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 @@ -328,10 +337,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies" - } - @distributed_trace def get( self, resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, **kwargs: Any @@ -349,12 +354,11 @@ def get( :type vault_name: str :param resource_guard_proxy_name: name of the resource guard proxy. Required. :type resource_guard_proxy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceGuardProxyBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -368,22 +372,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceGuardProxyBaseResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, resource_guard_proxy_name=resource_guard_proxy_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 @@ -392,16 +394,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ResourceGuardProxyBaseResource", pipeline_response) + deserialized = self._deserialize("ResourceGuardProxyBaseResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -430,7 +428,6 @@ def create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceGuardProxyBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource :raises ~azure.core.exceptions.HttpResponseError: @@ -442,7 +439,7 @@ def create_or_update( resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -459,11 +456,10 @@ def create_or_update( :param resource_guard_proxy_name: name of the resource guard proxy. Required. :type resource_guard_proxy_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceGuardProxyBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource :raises ~azure.core.exceptions.HttpResponseError: @@ -475,7 +471,7 @@ def create_or_update( resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, - parameters: Union[_models.ResourceGuardProxyBaseResource, IO], + parameters: Union[_models.ResourceGuardProxyBaseResource, IO[bytes]], **kwargs: Any ) -> _models.ResourceGuardProxyBaseResource: """Creates or Updates a ResourceGuardProxy. @@ -490,17 +486,13 @@ def create_or_update( :param resource_guard_proxy_name: name of the resource guard proxy. Required. :type resource_guard_proxy_name: str :param parameters: Request body for operation. Is either a ResourceGuardProxyBaseResource type - or a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource or IO[bytes] :return: ResourceGuardProxyBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardProxyBaseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -523,7 +515,7 @@ def create_or_update( else: _json = self._serialize.body(parameters, "ResourceGuardProxyBaseResource") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, vault_name=vault_name, resource_guard_proxy_name=resource_guard_proxy_name, @@ -532,16 +524,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -550,16 +540,12 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ResourceGuardProxyBaseResource", pipeline_response) + deserialized = self._deserialize("ResourceGuardProxyBaseResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -576,12 +562,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type vault_name: str :param resource_guard_proxy_name: name of the resource guard proxy. Required. :type resource_guard_proxy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -595,22 +580,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, vault_name=vault_name, resource_guard_proxy_name=resource_guard_proxy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -620,11 +603,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def unlock_delete( @@ -633,6 +612,7 @@ def unlock_delete( vault_name: str, resource_guard_proxy_name: str, parameters: _models.UnlockDeleteRequest, + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -650,10 +630,11 @@ def unlock_delete( :type resource_guard_proxy_name: str :param parameters: Request body for operation. Required. :type parameters: ~azure.mgmt.dataprotection.models.UnlockDeleteRequest + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: UnlockDeleteResponse or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -665,7 +646,8 @@ def unlock_delete( resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, - parameters: IO, + parameters: IO[bytes], + x_ms_authorization_auxiliary: Optional[str] = None, *, content_type: str = "application/json", **kwargs: Any @@ -682,11 +664,12 @@ def unlock_delete( :param resource_guard_proxy_name: name of the resource guard proxy. Required. :type resource_guard_proxy_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: UnlockDeleteResponse or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -698,7 +681,8 @@ def unlock_delete( resource_group_name: str, vault_name: str, resource_guard_proxy_name: str, - parameters: Union[_models.UnlockDeleteRequest, IO], + parameters: Union[_models.UnlockDeleteRequest, IO[bytes]], + x_ms_authorization_auxiliary: Optional[str] = None, **kwargs: Any ) -> _models.UnlockDeleteResponse: """UnlockDelete call for ResourceGuardProxy, executed before one can delete it. @@ -712,18 +696,16 @@ def unlock_delete( :type vault_name: str :param resource_guard_proxy_name: name of the resource guard proxy. Required. :type resource_guard_proxy_name: str - :param parameters: Request body for operation. Is either a UnlockDeleteRequest type or a IO - type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.UnlockDeleteRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: Request body for operation. Is either a UnlockDeleteRequest type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.UnlockDeleteRequest or IO[bytes] + :param x_ms_authorization_auxiliary: Default value is None. + :type x_ms_authorization_auxiliary: str :return: UnlockDeleteResponse or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.UnlockDeleteResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -746,25 +728,24 @@ def unlock_delete( else: _json = self._serialize.body(parameters, "UnlockDeleteRequest") - request = build_unlock_delete_request( + _request = build_unlock_delete_request( resource_group_name=resource_group_name, vault_name=vault_name, resource_guard_proxy_name=resource_guard_proxy_name, subscription_id=self._config.subscription_id, + x_ms_authorization_auxiliary=x_ms_authorization_auxiliary, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.unlock_delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -773,13 +754,9 @@ def unlock_delete( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("UnlockDeleteResponse", pipeline_response) + deserialized = self._deserialize("UnlockDeleteResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - unlock_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}/unlockDelete" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_export_jobs_operation_result_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_export_jobs_operation_result_operations.py index 31a33fc29f0f..3934057f86e8 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_export_jobs_operation_result_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_export_jobs_operation_result_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_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -102,12 +105,11 @@ def get( :type vault_name: str :param operation_id: OperationID which represents the export job. Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ExportJobsResult or None or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ExportJobsResult or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,22 +123,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.ExportJobsResult]] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -147,13 +147,9 @@ def get( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("ExportJobsResult", pipeline_response) + deserialized = self._deserialize("ExportJobsResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs/operations/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_export_jobs_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_export_jobs_operations.py index 94ee335c42f2..7a04f31370bc 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_export_jobs_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_export_jobs_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, Union, cast +import sys +from typing import Any, Callable, Dict, Iterator, Optional, Type, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,9 +18,8 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -27,8 +27,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]] @@ -42,7 +45,7 @@ def build_trigger_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -88,10 +91,8 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _trigger_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, vault_name: str, **kwargs: Any - ) -> None: - error_map = { + def _trigger_initial(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -103,28 +104,27 @@ def _trigger_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_trigger_request( + _request = build_trigger_request( resource_group_name=resource_group_name, vault_name=vault_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._trigger_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -133,12 +133,15 @@ def _trigger_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline) + + if response.status_code == 204: + deserialized = response.stream_download(self._client._pipeline) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _trigger_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/exportBackupJobs" - } + return deserialized # type: ignore @distributed_trace def begin_trigger(self, resource_group_name: str, vault_name: str, **kwargs: Any) -> LROPoller[None]: @@ -149,14 +152,6 @@ def begin_trigger(self, resource_group_name: str, vault_name: str, **kwargs: Any :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_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: @@ -170,7 +165,7 @@ def begin_trigger(self, resource_group_name: str, vault_name: str, **kwargs: Any lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._trigger_initial( # type: ignore + raw_result = self._trigger_initial( resource_group_name=resource_group_name, vault_name=vault_name, api_version=api_version, @@ -179,11 +174,12 @@ def begin_trigger(self, resource_group_name: str, vault_name: str, **kwargs: Any 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( @@ -194,14 +190,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_trigger.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/exportBackupJobs" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_fetch_cross_region_restore_job_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_fetch_cross_region_restore_job_operations.py index 00a263f5fb90..1f6bb24cb7e8 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_fetch_cross_region_restore_job_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_fetch_cross_region_restore_job_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, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,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]] @@ -39,7 +42,7 @@ def build_get_request(resource_group_name: str, location: str, subscription_id: _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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -110,7 +113,6 @@ def get( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AzureBackupJobResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupJobResource :raises ~azure.core.exceptions.HttpResponseError: @@ -121,7 +123,7 @@ def get( self, resource_group_name: str, location: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -134,11 +136,10 @@ def get( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AzureBackupJobResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupJobResource :raises ~azure.core.exceptions.HttpResponseError: @@ -149,7 +150,7 @@ def get( self, resource_group_name: str, location: str, - parameters: Union[_models.CrossRegionRestoreJobRequest, IO], + parameters: Union[_models.CrossRegionRestoreJobRequest, IO[bytes]], **kwargs: Any ) -> _models.AzureBackupJobResource: """Fetches the Cross Region Restore Job. @@ -160,17 +161,13 @@ def get( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for operation. Is either a CrossRegionRestoreJobRequest type or - a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.CrossRegionRestoreJobRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.CrossRegionRestoreJobRequest or IO[bytes] :return: AzureBackupJobResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupJobResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,7 +190,7 @@ def get( else: _json = self._serialize.body(parameters, "CrossRegionRestoreJobRequest") - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, location=location, subscription_id=self._config.subscription_id, @@ -201,16 +198,14 @@ def get( content_type=content_type, json=_json, content=_content, - 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 @@ -219,13 +214,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AzureBackupJobResource", pipeline_response) + deserialized = self._deserialize("AzureBackupJobResource", 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.DataProtection/locations/{location}/fetchCrossRegionRestoreJob" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_fetch_cross_region_restore_jobs_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_fetch_cross_region_restore_jobs_operations.py index 506ff9ca3fcb..90b9d3692412 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_fetch_cross_region_restore_jobs_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_fetch_cross_region_restore_jobs_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, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,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]] @@ -43,7 +46,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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -119,7 +122,6 @@ def list( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureBackupJobResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.AzureBackupJobResource] @@ -131,7 +133,7 @@ def list( self, resource_group_name: str, location: str, - parameters: IO, + parameters: IO[bytes], filter: Optional[str] = None, *, content_type: str = "application/json", @@ -145,13 +147,12 @@ def list( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param filter: OData filter options. Default value is None. :type filter: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureBackupJobResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.AzureBackupJobResource] @@ -163,7 +164,7 @@ def list( self, resource_group_name: str, location: str, - parameters: Union[_models.CrossRegionRestoreJobsRequest, IO], + parameters: Union[_models.CrossRegionRestoreJobsRequest, IO[bytes]], filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.AzureBackupJobResource"]: @@ -175,14 +176,10 @@ def list( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for operation. Is either a CrossRegionRestoreJobsRequest type - or a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.CrossRegionRestoreJobsRequest or IO + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.CrossRegionRestoreJobsRequest or IO[bytes] :param filter: OData filter options. Default value is None. :type filter: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureBackupJobResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.AzureBackupJobResource] @@ -195,7 +192,7 @@ def list( content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AzureBackupJobResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -213,7 +210,7 @@ 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, location=location, subscription_id=self._config.subscription_id, @@ -222,12 +219,10 @@ def prepare_request(next_link=None): content_type=content_type, json=_json, content=_content, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -239,13 +234,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("AzureBackupJobResourceList", pipeline_response) @@ -255,11 +249,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 @@ -270,7 +264,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.DataProtection/locations/{location}/fetchCrossRegionRestoreJobs" - } diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_fetch_secondary_recovery_points_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_fetch_secondary_recovery_points_operations.py index dad6d1eed3fa..e9324789b426 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_fetch_secondary_recovery_points_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_fetch_secondary_recovery_points_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, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,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]] @@ -49,7 +52,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -131,7 +134,6 @@ def list( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureBackupRecoveryPointResource or the result of cls(response) :rtype: @@ -144,7 +146,7 @@ def list( self, resource_group_name: str, location: str, - parameters: IO, + parameters: IO[bytes], filter: Optional[str] = None, skip_token: Optional[str] = None, *, @@ -160,7 +162,7 @@ def list( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param filter: OData filter options. Default value is None. :type filter: str :param skip_token: skipToken Filter. Default value is None. @@ -168,7 +170,6 @@ def list( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureBackupRecoveryPointResource or the result of cls(response) :rtype: @@ -181,7 +182,7 @@ def list( self, resource_group_name: str, location: str, - parameters: Union[_models.FetchSecondaryRPsRequestParameters, IO], + parameters: Union[_models.FetchSecondaryRPsRequestParameters, IO[bytes]], filter: Optional[str] = None, skip_token: Optional[str] = None, **kwargs: Any @@ -195,16 +196,13 @@ def list( :param location: The name of the Azure region. Required. :type location: str :param parameters: Request body for operation. Is either a FetchSecondaryRPsRequestParameters - type or a IO type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.FetchSecondaryRPsRequestParameters or IO + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.FetchSecondaryRPsRequestParameters or + IO[bytes] :param filter: OData filter options. Default value is None. :type filter: str :param skip_token: skipToken Filter. Default value is None. :type skip_token: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureBackupRecoveryPointResource or the result of cls(response) :rtype: @@ -218,7 +216,7 @@ def list( content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AzureBackupRecoveryPointResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,7 +234,7 @@ 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, location=location, subscription_id=self._config.subscription_id, @@ -246,12 +244,10 @@ def prepare_request(next_link=None): content_type=content_type, json=_json, content=_content, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -263,13 +259,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("AzureBackupRecoveryPointResourceList", pipeline_response) @@ -279,11 +274,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 @@ -294,7 +289,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.DataProtection/locations/{location}/fetchSecondaryRecoveryPoints" - } diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_jobs_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_jobs_operations.py index ba5bb7986921..04844590fe8f 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_jobs_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_jobs_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(resource_group_name: str, vault_name: str, subscription_i _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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -73,7 +76,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -131,7 +134,6 @@ def list( :type resource_group_name: str :param vault_name: The name of the backup vault. Required. :type vault_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureBackupJobResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.AzureBackupJobResource] @@ -143,7 +145,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AzureBackupJobResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -154,17 +156,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, vault_name=vault_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 @@ -176,13 +176,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("AzureBackupJobResourceList", pipeline_response) @@ -192,11 +191,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -208,10 +207,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs" - } - @distributed_trace def get( self, resource_group_name: str, vault_name: str, job_id: str, **kwargs: Any @@ -226,12 +221,11 @@ def get( :param job_id: The Job ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). Required. :type job_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AzureBackupJobResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupJobResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,22 +239,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AzureBackupJobResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, job_id=job_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -269,13 +261,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AzureBackupJobResource", pipeline_response) + deserialized = self._deserialize("AzureBackupJobResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs/{jobId}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_result_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_result_operations.py index 327555ab7943..5087daa6fd3d 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_result_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_result_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]] @@ -38,7 +41,7 @@ def build_get_request(operation_id: str, location: str, subscription_id: str, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,12 +95,11 @@ def get(self, operation_id: str, location: str, **kwargs: Any) -> Optional[_mode :type operation_id: str :param location: Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationJobExtendedInfo or None or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.OperationJobExtendedInfo or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -111,21 +113,19 @@ def get(self, operation_id: str, location: str, **kwargs: Any) -> Optional[_mode api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.OperationJobExtendedInfo]] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( operation_id=operation_id, location=location, 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 @@ -137,7 +137,7 @@ def get(self, operation_id: str, location: str, **kwargs: Any) -> Optional[_mode deserialized = None response_headers = {} if response.status_code == 200: - deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response) + deserialized = self._deserialize("OperationJobExtendedInfo", pipeline_response.http_response) if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -147,10 +147,6 @@ def get(self, operation_id: str, location: str, **kwargs: Any) -> Optional[_mode response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/operationResults/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_backup_vault_context_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_backup_vault_context_operations.py index 222d6d97ba04..8f17982b3129 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_backup_vault_context_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_backup_vault_context_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_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +71,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class OperationStatusBackupVaultContextOperations: +class OperationStatusBackupVaultContextOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -102,12 +105,11 @@ def get( :type vault_name: str :param operation_id: Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.OperationResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,22 +123,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -145,13 +145,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationResource", pipeline_response) + deserialized = self._deserialize("OperationResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/operationStatus/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_operations.py index 2fd5065ec243..0ad59974be65 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_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]] @@ -38,7 +41,7 @@ def build_get_request(location: str, operation_id: str, subscription_id: str, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,12 +95,11 @@ def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.Operat :type location: str :param operation_id: Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.OperationResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -111,21 +113,19 @@ def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.Operat api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( location=location, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -134,13 +134,9 @@ def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.Operat map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationResource", pipeline_response) + deserialized = self._deserialize("OperationResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/operationStatus/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_resource_group_context_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_resource_group_context_operations.py index 4cfbdcc862d5..2daae0f5e738 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_resource_group_context_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_operation_status_resource_group_context_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]] @@ -38,7 +41,7 @@ def build_get_request(resource_group_name: str, operation_id: 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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,7 +68,7 @@ def build_get_request(resource_group_name: str, operation_id: str, subscription_ return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class OperationStatusResourceGroupContextOperations: +class OperationStatusResourceGroupContextOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -95,12 +98,11 @@ def get(self, resource_group_name: str, operation_id: str, **kwargs: Any) -> _mo :type resource_group_name: str :param operation_id: Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.OperationResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -114,21 +116,19 @@ def get(self, resource_group_name: str, operation_id: str, **kwargs: Any) -> _mo api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -137,13 +137,9 @@ def get(self, resource_group_name: str, operation_id: str, **kwargs: Any) -> _mo map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationResource", pipeline_response) + deserialized = self._deserialize("OperationResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/operationStatus/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_recovery_points_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_recovery_points_operations.py index e709ad28902e..bdf5ba2f5e1c 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_recovery_points_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_recovery_points_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]] @@ -49,7 +52,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,7 +95,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -163,7 +166,6 @@ def list( :type filter: str :param skip_token: skipToken Filter. Default value is None. :type skip_token: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureBackupRecoveryPointResource or the result of cls(response) :rtype: @@ -176,7 +178,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AzureBackupRecoveryPointResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,7 +189,7 @@ 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, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -195,12 +197,10 @@ def prepare_request(next_link=None): filter=filter, skip_token=skip_token, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -212,13 +212,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("AzureBackupRecoveryPointResourceList", pipeline_response) @@ -228,11 +227,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 @@ -244,10 +243,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/recoveryPoints" - } - @distributed_trace def get( self, @@ -268,12 +263,11 @@ def get( :type backup_instance_name: str :param recovery_point_id: Required. :type recovery_point_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AzureBackupRecoveryPointResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupRecoveryPointResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -287,23 +281,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AzureBackupRecoveryPointResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, recovery_point_id=recovery_point_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -312,13 +304,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AzureBackupRecoveryPointResource", pipeline_response) + deserialized = self._deserialize("AzureBackupRecoveryPointResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/recoveryPoints/{recoveryPointId}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_resource_guards_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_resource_guards_operations.py index 7b27c4060c84..54b5ac58fd4f 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_resource_guards_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_resource_guards_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, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,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]] @@ -37,11 +40,13 @@ _SERIALIZER.client_side_validation = False -def build_get_resources_in_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_get_resources_in_subscription_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,13 +68,13 @@ def build_get_resources_in_subscription_request(subscription_id: str, **kwargs: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_resources_in_resource_group_request( +def build_get_resources_in_resource_group_request( # pylint: disable=name-too-long resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -101,7 +106,7 @@ def build_put_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -137,7 +142,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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -203,7 +208,7 @@ def build_patch_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -233,13 +238,13 @@ def build_patch_request( return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_disable_soft_delete_requests_objects_request( +def build_get_disable_soft_delete_requests_objects_request( # pylint: disable=name-too-long resource_group_name: str, resource_guards_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -266,13 +271,13 @@ def build_get_disable_soft_delete_requests_objects_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_delete_resource_guard_proxy_requests_objects_request( +def build_get_delete_resource_guard_proxy_requests_objects_request( # pylint: disable=name-too-long resource_group_name: str, resource_guards_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -299,13 +304,13 @@ def build_get_delete_resource_guard_proxy_requests_objects_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_backup_security_pin_requests_objects_request( +def build_get_backup_security_pin_requests_objects_request( # pylint: disable=name-too-long resource_group_name: str, resource_guards_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -332,13 +337,13 @@ def build_get_backup_security_pin_requests_objects_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_delete_protected_item_requests_objects_request( +def build_get_delete_protected_item_requests_objects_request( # pylint: disable=name-too-long resource_group_name: str, resource_guards_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -365,13 +370,13 @@ def build_get_delete_protected_item_requests_objects_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_update_protection_policy_requests_objects_request( +def build_get_update_protection_policy_requests_objects_request( # pylint: disable=name-too-long resource_group_name: str, resource_guards_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -398,13 +403,13 @@ def build_get_update_protection_policy_requests_objects_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_update_protected_item_requests_objects_request( +def build_get_update_protected_item_requests_objects_request( # pylint: disable=name-too-long resource_group_name: str, resource_guards_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -431,13 +436,13 @@ def build_get_update_protected_item_requests_objects_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_default_disable_soft_delete_requests_object_request( +def build_get_default_disable_soft_delete_requests_object_request( # pylint: disable=name-too-long resource_group_name: str, resource_guards_name: str, request_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -465,13 +470,13 @@ def build_get_default_disable_soft_delete_requests_object_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_default_delete_resource_guard_proxy_requests_object_request( +def build_get_default_delete_resource_guard_proxy_requests_object_request( # pylint: disable=name-too-long resource_group_name: str, resource_guards_name: str, request_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -499,13 +504,13 @@ def build_get_default_delete_resource_guard_proxy_requests_object_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_default_backup_security_pin_requests_object_request( +def build_get_default_backup_security_pin_requests_object_request( # pylint: disable=name-too-long resource_group_name: str, resource_guards_name: str, request_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -533,13 +538,13 @@ def build_get_default_backup_security_pin_requests_object_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_default_delete_protected_item_requests_object_request( +def build_get_default_delete_protected_item_requests_object_request( # pylint: disable=name-too-long resource_group_name: str, resource_guards_name: str, request_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -567,13 +572,13 @@ def build_get_default_delete_protected_item_requests_object_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_default_update_protection_policy_requests_object_request( +def build_get_default_update_protection_policy_requests_object_request( # pylint: disable=name-too-long resource_group_name: str, resource_guards_name: str, request_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -601,13 +606,13 @@ def build_get_default_update_protection_policy_requests_object_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_default_update_protected_item_requests_object_request( +def build_get_default_update_protected_item_requests_object_request( # pylint: disable=name-too-long resource_group_name: str, resource_guards_name: str, request_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -660,7 +665,6 @@ def get_resources_in_subscription(self, **kwargs: Any) -> Iterable["_models.Reso Returns ResourceGuards collection belonging to a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceGuardResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.ResourceGuardResource] @@ -672,7 +676,7 @@ def get_resources_in_subscription(self, **kwargs: Any) -> Iterable["_models.Reso api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceGuardResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -683,15 +687,13 @@ def get_resources_in_subscription(self, **kwargs: Any) -> Iterable["_models.Reso def prepare_request(next_link=None): if not next_link: - request = build_get_resources_in_subscription_request( + _request = build_get_resources_in_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resources_in_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 @@ -703,13 +705,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("ResourceGuardResourceList", pipeline_response) @@ -719,11 +720,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 @@ -735,10 +736,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - get_resources_in_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/resourceGuards" - } - @distributed_trace def get_resources_in_resource_group( self, resource_group_name: str, **kwargs: Any @@ -750,7 +747,6 @@ def get_resources_in_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceGuardResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.ResourceGuardResource] @@ -762,7 +758,7 @@ def get_resources_in_resource_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceGuardResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -773,16 +769,14 @@ def get_resources_in_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_get_resources_in_resource_group_request( + _request = build_get_resources_in_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_resources_in_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 @@ -794,13 +788,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("ResourceGuardResourceList", pipeline_response) @@ -810,11 +803,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 @@ -826,10 +819,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - get_resources_in_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards" - } - @overload def put( self, @@ -854,7 +843,6 @@ def put( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource :raises ~azure.core.exceptions.HttpResponseError: @@ -865,7 +853,7 @@ def put( self, resource_group_name: str, resource_guards_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -880,11 +868,10 @@ def put( :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource :raises ~azure.core.exceptions.HttpResponseError: @@ -895,7 +882,7 @@ def put( self, resource_group_name: str, resource_guards_name: str, - parameters: Union[_models.ResourceGuardResource, IO], + parameters: Union[_models.ResourceGuardResource, IO[bytes]], **kwargs: Any ) -> _models.ResourceGuardResource: """Creates or updates a ResourceGuard resource belonging to a resource group. @@ -907,18 +894,14 @@ def put( :type resource_group_name: str :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str - :param parameters: Request body for operation. Is either a ResourceGuardResource type or a IO - type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardResource or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: Request body for operation. Is either a ResourceGuardResource type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.ResourceGuardResource or IO[bytes] :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -941,7 +924,7 @@ def put( else: _json = self._serialize.body(parameters, "ResourceGuardResource") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, @@ -949,16 +932,14 @@ def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -968,20 +949,16 @@ def put( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize("ResourceGuardResource", pipeline_response) + deserialized = self._deserialize("ResourceGuardResource", pipeline_response.http_response) if response.status_code == 201: - deserialized = self._deserialize("ResourceGuardResource", pipeline_response) + deserialized = self._deserialize("ResourceGuardResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}" - } - @distributed_trace def get(self, resource_group_name: str, resource_guards_name: str, **kwargs: Any) -> _models.ResourceGuardResource: """Returns a ResourceGuard belonging to a resource group. @@ -993,12 +970,11 @@ def get(self, resource_group_name: str, resource_guards_name: str, **kwargs: Any :type resource_group_name: str :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1012,21 +988,19 @@ def get(self, resource_group_name: str, resource_guards_name: str, **kwargs: Any api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourceGuardResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_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 @@ -1035,16 +1009,12 @@ def get(self, resource_group_name: str, resource_guards_name: str, **kwargs: Any map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ResourceGuardResource", pipeline_response) + deserialized = self._deserialize("ResourceGuardResource", 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.DataProtection/resourceGuards/{resourceGuardsName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1059,12 +1029,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1078,21 +1047,19 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1102,11 +1069,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def patch( @@ -1134,7 +1097,6 @@ def patch( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource :raises ~azure.core.exceptions.HttpResponseError: @@ -1145,7 +1107,7 @@ def patch( self, resource_group_name: str, resource_guards_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1162,11 +1124,10 @@ def patch( :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource :raises ~azure.core.exceptions.HttpResponseError: @@ -1177,7 +1138,7 @@ def patch( self, resource_group_name: str, resource_guards_name: str, - parameters: Union[_models.PatchResourceGuardInput, IO], + parameters: Union[_models.PatchResourceGuardInput, IO[bytes]], **kwargs: Any ) -> _models.ResourceGuardResource: """Updates a ResourceGuard resource belonging to a resource group. For example, updating tags for @@ -1191,18 +1152,14 @@ def patch( :type resource_group_name: str :param resource_guards_name: The name of ResourceGuard. Required. :type resource_guards_name: str - :param parameters: Request body for operation. Is either a PatchResourceGuardInput type or a IO - type. Required. - :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceGuardInput or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: Request body for operation. Is either a PatchResourceGuardInput type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.dataprotection.models.PatchResourceGuardInput or IO[bytes] :return: ResourceGuardResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.ResourceGuardResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1225,7 +1182,7 @@ def patch( else: _json = self._serialize.body(parameters, "PatchResourceGuardInput") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, @@ -1233,16 +1190,14 @@ def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -1251,16 +1206,12 @@ def patch( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ResourceGuardResource", pipeline_response) + deserialized = self._deserialize("ResourceGuardResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}" - } + return deserialized # type: ignore @distributed_trace def get_disable_soft_delete_requests_objects( @@ -1277,7 +1228,6 @@ def get_disable_soft_delete_requests_objects( :type resource_group_name: str :param resource_guards_name: Required. :type resource_guards_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DppBaseResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -1288,7 +1238,7 @@ def get_disable_soft_delete_requests_objects( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1299,17 +1249,15 @@ def get_disable_soft_delete_requests_objects( def prepare_request(next_link=None): if not next_link: - request = build_get_disable_soft_delete_requests_objects_request( + _request = build_get_disable_soft_delete_requests_objects_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_disable_soft_delete_requests_objects.metadata["url"], 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 @@ -1321,13 +1269,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("DppBaseResourceList", pipeline_response) @@ -1337,11 +1284,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 @@ -1353,12 +1300,8 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - get_disable_soft_delete_requests_objects.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/disableSoftDeleteRequests" - } - @distributed_trace - def get_delete_resource_guard_proxy_requests_objects( + def get_delete_resource_guard_proxy_requests_objects( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, **kwargs: Any ) -> Iterable["_models.DppBaseResource"]: """Returns collection of operation request objects for a critical operation protected by the given @@ -1372,7 +1315,6 @@ def get_delete_resource_guard_proxy_requests_objects( :type resource_group_name: str :param resource_guards_name: Required. :type resource_guards_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DppBaseResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -1383,7 +1325,7 @@ def get_delete_resource_guard_proxy_requests_objects( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1394,17 +1336,15 @@ def get_delete_resource_guard_proxy_requests_objects( def prepare_request(next_link=None): if not next_link: - request = build_get_delete_resource_guard_proxy_requests_objects_request( + _request = build_get_delete_resource_guard_proxy_requests_objects_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_delete_resource_guard_proxy_requests_objects.metadata["url"], 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 @@ -1416,13 +1356,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("DppBaseResourceList", pipeline_response) @@ -1432,11 +1371,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 @@ -1448,10 +1387,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - get_delete_resource_guard_proxy_requests_objects.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteResourceGuardProxyRequests" - } - @distributed_trace def get_backup_security_pin_requests_objects( self, resource_group_name: str, resource_guards_name: str, **kwargs: Any @@ -1467,7 +1402,6 @@ def get_backup_security_pin_requests_objects( :type resource_group_name: str :param resource_guards_name: Required. :type resource_guards_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DppBaseResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -1478,7 +1412,7 @@ def get_backup_security_pin_requests_objects( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1489,17 +1423,15 @@ def get_backup_security_pin_requests_objects( def prepare_request(next_link=None): if not next_link: - request = build_get_backup_security_pin_requests_objects_request( + _request = build_get_backup_security_pin_requests_objects_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_backup_security_pin_requests_objects.metadata["url"], 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 @@ -1511,13 +1443,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("DppBaseResourceList", pipeline_response) @@ -1527,11 +1458,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 @@ -1543,12 +1474,8 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - get_backup_security_pin_requests_objects.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/getBackupSecurityPINRequests" - } - @distributed_trace - def get_delete_protected_item_requests_objects( + def get_delete_protected_item_requests_objects( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, **kwargs: Any ) -> Iterable["_models.DppBaseResource"]: """Returns collection of operation request objects for a critical operation protected by the given @@ -1562,7 +1489,6 @@ def get_delete_protected_item_requests_objects( :type resource_group_name: str :param resource_guards_name: Required. :type resource_guards_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DppBaseResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -1573,7 +1499,7 @@ def get_delete_protected_item_requests_objects( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1584,17 +1510,15 @@ def get_delete_protected_item_requests_objects( def prepare_request(next_link=None): if not next_link: - request = build_get_delete_protected_item_requests_objects_request( + _request = build_get_delete_protected_item_requests_objects_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_delete_protected_item_requests_objects.metadata["url"], 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 @@ -1606,13 +1530,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("DppBaseResourceList", pipeline_response) @@ -1622,11 +1545,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 @@ -1638,12 +1561,8 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - get_delete_protected_item_requests_objects.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteProtectedItemRequests" - } - @distributed_trace - def get_update_protection_policy_requests_objects( + def get_update_protection_policy_requests_objects( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, **kwargs: Any ) -> Iterable["_models.DppBaseResource"]: """Returns collection of operation request objects for a critical operation protected by the given @@ -1657,7 +1576,6 @@ def get_update_protection_policy_requests_objects( :type resource_group_name: str :param resource_guards_name: Required. :type resource_guards_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DppBaseResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -1668,7 +1586,7 @@ def get_update_protection_policy_requests_objects( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1679,17 +1597,15 @@ def get_update_protection_policy_requests_objects( def prepare_request(next_link=None): if not next_link: - request = build_get_update_protection_policy_requests_objects_request( + _request = build_get_update_protection_policy_requests_objects_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_update_protection_policy_requests_objects.metadata["url"], 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 @@ -1701,13 +1617,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("DppBaseResourceList", pipeline_response) @@ -1717,11 +1632,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 @@ -1733,12 +1648,8 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - get_update_protection_policy_requests_objects.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectionPolicyRequests" - } - @distributed_trace - def get_update_protected_item_requests_objects( + def get_update_protected_item_requests_objects( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, **kwargs: Any ) -> Iterable["_models.DppBaseResource"]: """Returns collection of operation request objects for a critical operation protected by the given @@ -1752,7 +1663,6 @@ def get_update_protected_item_requests_objects( :type resource_group_name: str :param resource_guards_name: Required. :type resource_guards_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DppBaseResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.dataprotection.models.DppBaseResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -1763,7 +1673,7 @@ def get_update_protected_item_requests_objects( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResourceList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1774,17 +1684,15 @@ def get_update_protected_item_requests_objects( def prepare_request(next_link=None): if not next_link: - request = build_get_update_protected_item_requests_objects_request( + _request = build_get_update_protected_item_requests_objects_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_update_protected_item_requests_objects.metadata["url"], 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 @@ -1796,13 +1704,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("DppBaseResourceList", pipeline_response) @@ -1812,11 +1719,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 @@ -1828,12 +1735,8 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - get_update_protected_item_requests_objects.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectedItemRequests" - } - @distributed_trace - def get_default_disable_soft_delete_requests_object( + def get_default_disable_soft_delete_requests_object( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any ) -> _models.DppBaseResource: """Returns collection of operation request objects for a critical operation protected by the given @@ -1849,12 +1752,11 @@ def get_default_disable_soft_delete_requests_object( :type resource_guards_name: str :param request_name: Required. :type request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1868,22 +1770,20 @@ def get_default_disable_soft_delete_requests_object( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResource] = kwargs.pop("cls", None) - request = build_get_default_disable_soft_delete_requests_object_request( + _request = build_get_default_disable_soft_delete_requests_object_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, request_name=request_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_default_disable_soft_delete_requests_object.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -1892,19 +1792,15 @@ def get_default_disable_soft_delete_requests_object( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DppBaseResource", pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_default_disable_soft_delete_requests_object.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/disableSoftDeleteRequests/{requestName}" - } + return deserialized # type: ignore @distributed_trace - def get_default_delete_resource_guard_proxy_requests_object( + def get_default_delete_resource_guard_proxy_requests_object( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any ) -> _models.DppBaseResource: """Returns collection of operation request objects for a critical operation protected by the given @@ -1920,12 +1816,11 @@ def get_default_delete_resource_guard_proxy_requests_object( :type resource_guards_name: str :param request_name: Required. :type request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1939,22 +1834,20 @@ def get_default_delete_resource_guard_proxy_requests_object( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResource] = kwargs.pop("cls", None) - request = build_get_default_delete_resource_guard_proxy_requests_object_request( + _request = build_get_default_delete_resource_guard_proxy_requests_object_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, request_name=request_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_default_delete_resource_guard_proxy_requests_object.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -1963,19 +1856,15 @@ def get_default_delete_resource_guard_proxy_requests_object( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DppBaseResource", pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_default_delete_resource_guard_proxy_requests_object.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteResourceGuardProxyRequests/{requestName}" - } + return deserialized # type: ignore @distributed_trace - def get_default_backup_security_pin_requests_object( + def get_default_backup_security_pin_requests_object( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any ) -> _models.DppBaseResource: """Returns collection of operation request objects for a critical operation protected by the given @@ -1991,12 +1880,11 @@ def get_default_backup_security_pin_requests_object( :type resource_guards_name: str :param request_name: Required. :type request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2010,22 +1898,20 @@ def get_default_backup_security_pin_requests_object( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResource] = kwargs.pop("cls", None) - request = build_get_default_backup_security_pin_requests_object_request( + _request = build_get_default_backup_security_pin_requests_object_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, request_name=request_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_default_backup_security_pin_requests_object.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -2034,19 +1920,15 @@ def get_default_backup_security_pin_requests_object( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DppBaseResource", pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_default_backup_security_pin_requests_object.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/getBackupSecurityPINRequests/{requestName}" - } + return deserialized # type: ignore @distributed_trace - def get_default_delete_protected_item_requests_object( + def get_default_delete_protected_item_requests_object( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any ) -> _models.DppBaseResource: """Returns collection of operation request objects for a critical operation protected by the given @@ -2062,12 +1944,11 @@ def get_default_delete_protected_item_requests_object( :type resource_guards_name: str :param request_name: Required. :type request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2081,22 +1962,20 @@ def get_default_delete_protected_item_requests_object( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResource] = kwargs.pop("cls", None) - request = build_get_default_delete_protected_item_requests_object_request( + _request = build_get_default_delete_protected_item_requests_object_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, request_name=request_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_default_delete_protected_item_requests_object.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -2105,19 +1984,15 @@ def get_default_delete_protected_item_requests_object( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DppBaseResource", pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_default_delete_protected_item_requests_object.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/deleteProtectedItemRequests/{requestName}" - } + return deserialized # type: ignore @distributed_trace - def get_default_update_protection_policy_requests_object( + def get_default_update_protection_policy_requests_object( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any ) -> _models.DppBaseResource: """Returns collection of operation request objects for a critical operation protected by the given @@ -2133,12 +2008,11 @@ def get_default_update_protection_policy_requests_object( :type resource_guards_name: str :param request_name: Required. :type request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2152,22 +2026,20 @@ def get_default_update_protection_policy_requests_object( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResource] = kwargs.pop("cls", None) - request = build_get_default_update_protection_policy_requests_object_request( + _request = build_get_default_update_protection_policy_requests_object_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, request_name=request_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_default_update_protection_policy_requests_object.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -2176,19 +2048,15 @@ def get_default_update_protection_policy_requests_object( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DppBaseResource", pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_default_update_protection_policy_requests_object.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectionPolicyRequests/{requestName}" - } + return deserialized # type: ignore @distributed_trace - def get_default_update_protected_item_requests_object( + def get_default_update_protected_item_requests_object( # pylint: disable=name-too-long self, resource_group_name: str, resource_guards_name: str, request_name: str, **kwargs: Any ) -> _models.DppBaseResource: """Returns collection of operation request objects for a critical operation protected by the given @@ -2204,12 +2072,11 @@ def get_default_update_protected_item_requests_object( :type resource_guards_name: str :param request_name: Required. :type request_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DppBaseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.DppBaseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2223,22 +2090,20 @@ def get_default_update_protected_item_requests_object( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DppBaseResource] = kwargs.pop("cls", None) - request = build_get_default_update_protected_item_requests_object_request( + _request = build_get_default_update_protected_item_requests_object_request( resource_group_name=resource_group_name, resource_guards_name=resource_guards_name, request_name=request_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_default_update_protected_item_requests_object.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -2247,13 +2112,9 @@ def get_default_update_protected_item_requests_object( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DppBaseResource", pipeline_response) + deserialized = self._deserialize("DppBaseResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_default_update_protected_item_requests_object.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards/{resourceGuardsName}/updateProtectedItemRequests/{requestName}" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_restorable_time_ranges_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_restorable_time_ranges_operations.py index 0a4433299100..09ef916a8f84 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_restorable_time_ranges_operations.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/azure/mgmt/dataprotection/operations/_restorable_time_ranges_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, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,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]] @@ -41,7 +44,7 @@ def build_find_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-11-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -116,7 +119,6 @@ def find( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AzureBackupFindRestorableTimeRangesResponseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesResponseResource :raises ~azure.core.exceptions.HttpResponseError: @@ -128,7 +130,7 @@ def find( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -143,11 +145,10 @@ def find( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AzureBackupFindRestorableTimeRangesResponseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesResponseResource :raises ~azure.core.exceptions.HttpResponseError: @@ -159,7 +160,7 @@ def find( resource_group_name: str, vault_name: str, backup_instance_name: str, - parameters: Union[_models.AzureBackupFindRestorableTimeRangesRequest, IO], + parameters: Union[_models.AzureBackupFindRestorableTimeRangesRequest, IO[bytes]], **kwargs: Any ) -> _models.AzureBackupFindRestorableTimeRangesResponseResource: """find. @@ -172,18 +173,14 @@ def find( :param backup_instance_name: The name of the backup instance. Required. :type backup_instance_name: str :param parameters: Request body for operation. Is either a - AzureBackupFindRestorableTimeRangesRequest type or a IO type. Required. + AzureBackupFindRestorableTimeRangesRequest type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesRequest - or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + or IO[bytes] :return: AzureBackupFindRestorableTimeRangesResponseResource or the result of cls(response) :rtype: ~azure.mgmt.dataprotection.models.AzureBackupFindRestorableTimeRangesResponseResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,7 +203,7 @@ def find( else: _json = self._serialize.body(parameters, "AzureBackupFindRestorableTimeRangesRequest") - request = build_find_request( + _request = build_find_request( resource_group_name=resource_group_name, vault_name=vault_name, backup_instance_name=backup_instance_name, @@ -215,16 +212,14 @@ def find( content_type=content_type, json=_json, content=_content, - template_url=self.find.metadata["url"], headers=_headers, params=_params, ) - request = _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 @@ -233,13 +228,11 @@ def find( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("AzureBackupFindRestorableTimeRangesResponseResource", pipeline_response) + deserialized = self._deserialize( + "AzureBackupFindRestorableTimeRangesResponseResource", pipeline_response.http_response + ) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - find.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/findRestorableTimeRanges" - } + return deserialized # type: ignore diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/delete_backup_instance.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/delete_backup_instance.py index ae16e7f94adb..13556bd61c23 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/delete_backup_instance.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/delete_backup_instance.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/DeleteBackupInstance.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/DeleteBackupInstance.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/find_restorable_time_ranges.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/find_restorable_time_ranges.py index 6495a128d4e9..bc38d16427e1 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/find_restorable_time_ranges.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/find_restorable_time_ranges.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.dataprotection import DataProtectionMgmtClient """ @@ -42,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/FindRestorableTimeRanges.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/FindRestorableTimeRanges.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/get_backup_instance.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/get_backup_instance.py index 22d10ffd16b2..d17eaf2f2e03 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/get_backup_instance.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/get_backup_instance.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/GetBackupInstance.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/GetBackupInstance.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/get_backup_instance_operation_result.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/get_backup_instance_operation_result.py index 82f2493b3ac8..8cbfa29bfad2 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/get_backup_instance_operation_result.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/get_backup_instance_operation_result.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/GetBackupInstanceOperationResult.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/GetBackupInstanceOperationResult.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/get_recovery_point.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/get_recovery_point.py index d5093ba7caaa..93e87ee1df16 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/get_recovery_point.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/get_recovery_point.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/GetRecoveryPoint.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/GetRecoveryPoint.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/list_backup_instances.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/list_backup_instances.py index aa7d82f87ab4..0b57b80490a9 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/list_backup_instances.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/list_backup_instances.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/ListBackupInstances.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/ListBackupInstances.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/list_backup_instances_extension_routing.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/list_backup_instances_extension_routing.py new file mode 100644 index 000000000000..68687fad5281 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/list_backup_instances_extension_routing.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dataprotection +# USAGE + python list_backup_instances_extension_routing.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DataProtectionMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.backup_instances_extension_routing.list( + resource_id="subscriptions/36d32b25-3dc7-41b0-bde1-397500644591/resourceGroups/testRG/providers/Microsoft.Compute/disks/testDisk", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/ListBackupInstancesExtensionRouting.json +if __name__ == "__main__": + main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/list_recovery_points.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/list_recovery_points.py index 431cbefeca11..828d96717086 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/list_recovery_points.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/list_recovery_points.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/ListRecoveryPoints.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/ListRecoveryPoints.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/put_backup_instance.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/put_backup_instance.py index e83b2c34db99..be62f8614e0e 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/put_backup_instance.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/put_backup_instance.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.dataprotection import DataProtectionMgmtClient """ @@ -82,6 +85,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/PutBackupInstance.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/PutBackupInstance.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/put_backup_instance_resource_guard_enabled.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/put_backup_instance_resource_guard_enabled.py new file mode 100644 index 000000000000..bc9c7cdc6d90 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/put_backup_instance_resource_guard_enabled.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. +# -------------------------------------------------------------------------- + +from typing import Any, IO, Union + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dataprotection +# USAGE + python put_backup_instance_resource_guard_enabled.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DataProtectionMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="04cf684a-d41f-4550-9f70-7708a3a2283b", + ) + + response = client.backup_instances.begin_create_or_update( + resource_group_name="000pikumar", + vault_name="PratikPrivatePreviewVault1", + backup_instance_name="testInstance1", + parameters={ + "properties": { + "dataSourceInfo": { + "datasourceType": "Microsoft.DBforPostgreSQL/servers/databases", + "objectType": "Datasource", + "resourceID": "/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/testdb", + "resourceLocation": "", + "resourceName": "testdb", + "resourceType": "Microsoft.DBforPostgreSQL/servers/databases", + "resourceUri": "", + }, + "dataSourceSetInfo": { + "datasourceType": "Microsoft.DBforPostgreSQL/servers/databases", + "objectType": "DatasourceSet", + "resourceID": "/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest", + "resourceLocation": "", + "resourceName": "viveksipgtest", + "resourceType": "Microsoft.DBforPostgreSQL/servers", + "resourceUri": "", + }, + "datasourceAuthCredentials": { + "objectType": "SecretStoreBasedAuthCredentials", + "secretStoreResource": { + "secretStoreType": "AzureKeyVault", + "uri": "https://samplevault.vault.azure.net/secrets/credentials", + }, + }, + "friendlyName": "harshitbi2", + "objectType": "BackupInstance", + "policyInfo": { + "policyId": "/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/Backupvaults/PratikPrivatePreviewVault1/backupPolicies/PratikPolicy1", + "policyParameters": { + "dataStoreParametersList": [ + { + "dataStoreType": "OperationalStore", + "objectType": "AzureOperationalStoreParameters", + "resourceGroupId": "/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest", + } + ] + }, + }, + "resourceGuardOperationRequests": [ + "/subscriptions/38304e13-357e-405e-9e9a-220351dcce8c/resourcegroups/ankurResourceGuard1/providers/Microsoft.DataProtection/resourceGuards/ResourceGuard38-1/dppModifyPolicy/default" + ], + "validationType": "ShallowValidation", + }, + "tags": {"key1": "val1"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/PutBackupInstance_ResourceGuardEnabled.json +if __name__ == "__main__": + main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/resume_backups.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/resume_backups.py index 7371391b9faf..3a9cace6e7ab 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/resume_backups.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/resume_backups.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/ResumeBackups.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/ResumeBackups.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/resume_protection.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/resume_protection.py index 367852a66962..28ade62fc02a 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/resume_protection.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/resume_protection.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/ResumeProtection.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/ResumeProtection.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/stop_protection.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/stop_protection.py index 82d2e3169378..34f8b05c9acb 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/stop_protection.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/stop_protection.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/StopProtection.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/StopProtection.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/stop_protection_resource_guard_enabled.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/stop_protection_resource_guard_enabled.py new file mode 100644 index 000000000000..4879ca5ec5c2 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/stop_protection_resource_guard_enabled.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dataprotection +# USAGE + python stop_protection_resource_guard_enabled.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DataProtectionMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="04cf684a-d41f-4550-9f70-7708a3a2283b", + ) + + client.backup_instances.begin_stop_protection( + resource_group_name="testrg", + vault_name="testvault", + backup_instance_name="testbi", + ).result() + + +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/StopProtection_ResourceGuardEnabled.json +if __name__ == "__main__": + main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/suspend_backup_resource_guard_enabled.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/suspend_backup_resource_guard_enabled.py new file mode 100644 index 000000000000..deb8fdb3c4c0 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/suspend_backup_resource_guard_enabled.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dataprotection +# USAGE + python suspend_backup_resource_guard_enabled.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DataProtectionMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="04cf684a-d41f-4550-9f70-7708a3a2283b", + ) + + client.backup_instances.begin_suspend_backups( + resource_group_name="testrg", + vault_name="testvault", + backup_instance_name="testbi", + ).result() + + +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/SuspendBackup_ResourceGuardEnabled.json +if __name__ == "__main__": + main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/suspend_backups.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/suspend_backups.py index 0f0e5ad00f77..278000fba52c 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/suspend_backups.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/suspend_backups.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/SuspendBackups.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/SuspendBackups.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/sync_backup_instance.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/sync_backup_instance.py index 8973e51290bd..ab15f550a395 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/sync_backup_instance.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/sync_backup_instance.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.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +40,6 @@ def main(): ).result() -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/SyncBackupInstance.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/SyncBackupInstance.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_backup.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_backup.py index be6920b3914d..309ab24a0fcd 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_backup.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_backup.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.dataprotection import DataProtectionMgmtClient """ @@ -40,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/TriggerBackup.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/TriggerBackup.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_rehydrate.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_rehydrate.py index 5ed2e73611fe..990052a83f2c 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_rehydrate.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_rehydrate.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.dataprotection import DataProtectionMgmtClient """ @@ -41,6 +44,6 @@ def main(): ).result() -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/TriggerRehydrate.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/TriggerRehydrate.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_restore.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_restore.py index 312495c53a34..df77ad132850 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_restore.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_restore.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.dataprotection import DataProtectionMgmtClient """ @@ -73,6 +76,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/TriggerRestore.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/TriggerRestore.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_restore_as_files.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_restore_as_files.py index 8571743a44d7..25c3767eaba8 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_restore_as_files.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_restore_as_files.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.dataprotection import DataProtectionMgmtClient """ @@ -53,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/TriggerRestoreAsFiles.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/TriggerRestoreAsFiles.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_restore_with_rehydration.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_restore_with_rehydration.py index e30fedda43ce..55af77488e62 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_restore_with_rehydration.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/trigger_restore_with_rehydration.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.dataprotection import DataProtectionMgmtClient """ @@ -68,6 +71,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/TriggerRestoreWithRehydration.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/TriggerRestoreWithRehydration.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/validate_for_backup.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/validate_for_backup.py index 5762d88ddafe..2affb2d94c69 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/validate_for_backup.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/validate_for_backup.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.dataprotection import DataProtectionMgmtClient """ @@ -70,6 +73,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/ValidateForBackup.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/ValidateForBackup.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/validate_restore.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/validate_restore.py index 67166f7772c0..593b9961325f 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/validate_restore.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/backup_instance_operations/validate_restore.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.dataprotection import DataProtectionMgmtClient """ @@ -75,6 +78,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/BackupInstanceOperations/ValidateRestore.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/BackupInstanceOperations/ValidateRestore.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/checkfeature_support.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/checkfeature_support.py index 4c8400fe30be..2a15d8bff824 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/checkfeature_support.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/checkfeature_support.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.dataprotection import DataProtectionMgmtClient """ @@ -36,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/CheckfeatureSupport.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/CheckfeatureSupport.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/fetch_cross_region_restore_job.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/fetch_cross_region_restore_job.py index 10709d2cfd5f..9bc5bc4aef40 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/fetch_cross_region_restore_job.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/fetch_cross_region_restore_job.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.dataprotection import DataProtectionMgmtClient """ @@ -41,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/CrossRegionRestore/FetchCrossRegionRestoreJob.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/CrossRegionRestore/FetchCrossRegionRestoreJob.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/fetch_cross_region_restore_jobs.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/fetch_cross_region_restore_jobs.py index 74f192d8f0d9..562ff663bb97 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/fetch_cross_region_restore_jobs.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/fetch_cross_region_restore_jobs.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.dataprotection import DataProtectionMgmtClient """ @@ -41,6 +44,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/CrossRegionRestore/FetchCrossRegionRestoreJobs.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/CrossRegionRestore/FetchCrossRegionRestoreJobs.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/fetch_secondary_rps.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/fetch_secondary_rps.py index c740f3415357..3d83cafb2842 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/fetch_secondary_rps.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/fetch_secondary_rps.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.dataprotection import DataProtectionMgmtClient """ @@ -41,6 +44,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/CrossRegionRestore/FetchSecondaryRPs.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/CrossRegionRestore/FetchSecondaryRPs.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/trigger_cross_region_restore.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/trigger_cross_region_restore.py index c24c644e7c5a..0a3a4e27eced 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/trigger_cross_region_restore.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/trigger_cross_region_restore.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.dataprotection import DataProtectionMgmtClient """ @@ -78,6 +81,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/CrossRegionRestore/TriggerCrossRegionRestore.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/CrossRegionRestore/TriggerCrossRegionRestore.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/validate_cross_region_restore.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/validate_cross_region_restore.py index cd322a3e8bf8..bbe19e16c014 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/validate_cross_region_restore.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/cross_region_restore/validate_cross_region_restore.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.dataprotection import DataProtectionMgmtClient """ @@ -78,6 +81,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/CrossRegionRestore/ValidateCrossRegionRestore.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/CrossRegionRestore/ValidateCrossRegionRestore.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/deleted_backup_instance_operations/get_deleted_backup_instance.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/deleted_backup_instance_operations/get_deleted_backup_instance.py index f19656aa01b9..7be303f55289 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/deleted_backup_instance_operations/get_deleted_backup_instance.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/deleted_backup_instance_operations/get_deleted_backup_instance.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/DeletedBackupInstanceOperations/GetDeletedBackupInstance.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/DeletedBackupInstanceOperations/GetDeletedBackupInstance.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/deleted_backup_instance_operations/list_deleted_backup_instances.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/deleted_backup_instance_operations/list_deleted_backup_instances.py index 8722484603bc..32710025c57a 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/deleted_backup_instance_operations/list_deleted_backup_instances.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/deleted_backup_instance_operations/list_deleted_backup_instances.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/DeletedBackupInstanceOperations/ListDeletedBackupInstances.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/DeletedBackupInstanceOperations/ListDeletedBackupInstances.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/deleted_backup_instance_operations/undelete_deleted_backup_instance.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/deleted_backup_instance_operations/undelete_deleted_backup_instance.py index 1c00a6aa82fb..9fdc8c8785ed 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/deleted_backup_instance_operations/undelete_deleted_backup_instance.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/deleted_backup_instance_operations/undelete_deleted_backup_instance.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/DeletedBackupInstanceOperations/UndeleteDeletedBackupInstance.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/DeletedBackupInstanceOperations/UndeleteDeletedBackupInstance.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_operation_result.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_operation_result.py index ad494e25e9ca..84c238dbc9c8 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_operation_result.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_operation_result.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/GetOperationResult.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/GetOperationResult.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_operation_status.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_operation_status.py index c9e36e722257..16dcda099e7f 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_operation_status.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_operation_status.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/GetOperationStatus.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/GetOperationStatus.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_operation_status_rg_context.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_operation_status_rg_context.py index d8fd317ce421..446cfdfec1a8 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_operation_status_rg_context.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_operation_status_rg_context.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/GetOperationStatusRGContext.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/GetOperationStatusRGContext.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_operation_status_vault_context.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_operation_status_vault_context.py index 230df83189c2..788c063ede45 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_operation_status_vault_context.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/get_operation_status_vault_context.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/GetOperationStatusVaultContext.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/GetOperationStatusVaultContext.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/job_crud/get_export_jobs_operation_result.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/job_crud/get_export_jobs_operation_result.py index 8b19d6a3ce09..2ced5becbee8 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/job_crud/get_export_jobs_operation_result.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/job_crud/get_export_jobs_operation_result.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/JobCRUD/GetExportJobsOperationResult.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/JobCRUD/GetExportJobsOperationResult.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/job_crud/get_job.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/job_crud/get_job.py index 6cfc0271da93..cb84bfe490e4 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/job_crud/get_job.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/job_crud/get_job.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/JobCRUD/GetJob.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/JobCRUD/GetJob.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/job_crud/list_jobs.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/job_crud/list_jobs.py index 6f017a808c70..4500a3bc66d4 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/job_crud/list_jobs.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/job_crud/list_jobs.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/JobCRUD/ListJobs.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/JobCRUD/ListJobs.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/job_crud/trigger_export_jobs.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/job_crud/trigger_export_jobs.py index 45a1852b9786..f5bcc623859f 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/job_crud/trigger_export_jobs.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/job_crud/trigger_export_jobs.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/JobCRUD/TriggerExportJobs.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/JobCRUD/TriggerExportJobs.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/operations/list.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/operations/list.py index 2cdd1cb41419..7a88a8308805 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/operations/list.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/operations/list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/Operations/List.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/Operations/List.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/policy_crud/create_or_update_backup_policy.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/policy_crud/create_or_update_backup_policy.py index 6e5ef4e0cc5a..e2273ebe4cdc 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/policy_crud/create_or_update_backup_policy.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/policy_crud/create_or_update_backup_policy.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.dataprotection import DataProtectionMgmtClient """ @@ -92,6 +95,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/PolicyCRUD/CreateOrUpdateBackupPolicy.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/PolicyCRUD/CreateOrUpdateBackupPolicy.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/policy_crud/delete_backup_policy.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/policy_crud/delete_backup_policy.py index 0169a70a079f..6e7fee02b392 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/policy_crud/delete_backup_policy.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/policy_crud/delete_backup_policy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -36,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/PolicyCRUD/DeleteBackupPolicy.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/PolicyCRUD/DeleteBackupPolicy.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/policy_crud/get_backup_policy.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/policy_crud/get_backup_policy.py index 7393b3eb0bf4..e881df3cda4d 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/policy_crud/get_backup_policy.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/policy_crud/get_backup_policy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/PolicyCRUD/GetBackupPolicy.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/PolicyCRUD/GetBackupPolicy.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/policy_crud/list_backup_policy.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/policy_crud/list_backup_policy.py index de0c9e09e06a..64c15ce0e631 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/policy_crud/list_backup_policy.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/policy_crud/list_backup_policy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/PolicyCRUD/ListBackupPolicy.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/PolicyCRUD/ListBackupPolicy.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/delete_resource_guard.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/delete_resource_guard.py index ce249ff22107..a81ad9812740 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/delete_resource_guard.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/delete_resource_guard.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -35,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/DeleteResourceGuard.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/DeleteResourceGuard.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_backup_security_pin_requests.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_backup_security_pin_requests.py index 2e7fb2313e9e..3603dd8d05c6 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_backup_security_pin_requests.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_backup_security_pin_requests.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/GetDefaultBackupSecurityPINRequests.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/GetDefaultBackupSecurityPINRequests.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_delete_protected_item_requests.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_delete_protected_item_requests.py index 3105673495ab..31ed30f8bdae 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_delete_protected_item_requests.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_delete_protected_item_requests.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/GetDefaultDeleteProtectedItemRequests.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/GetDefaultDeleteProtectedItemRequests.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_delete_resource_guard_proxy_requests.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_delete_resource_guard_proxy_requests.py index a4339ddb6c5d..10b88c7a46f7 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_delete_resource_guard_proxy_requests.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_delete_resource_guard_proxy_requests.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/GetDefaultDeleteResourceGuardProxyRequests.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/GetDefaultDeleteResourceGuardProxyRequests.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_disable_soft_delete_requests.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_disable_soft_delete_requests.py index 196e86740c26..d3f1f336538a 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_disable_soft_delete_requests.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_disable_soft_delete_requests.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/GetDefaultDisableSoftDeleteRequests.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/GetDefaultDisableSoftDeleteRequests.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_update_protected_item_requests.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_update_protected_item_requests.py index 6f05dededd15..a0050f3a114f 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_update_protected_item_requests.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_update_protected_item_requests.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/GetDefaultUpdateProtectedItemRequests.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/GetDefaultUpdateProtectedItemRequests.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_update_protection_policy_requests.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_update_protection_policy_requests.py index 8b39d509f08d..bca4f4bf8f59 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_update_protection_policy_requests.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_default_update_protection_policy_requests.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/GetDefaultUpdateProtectionPolicyRequests.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/GetDefaultUpdateProtectionPolicyRequests.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_resource_guard.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_resource_guard.py index 0759b19df8a3..c3666b6407fb 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_resource_guard.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_resource_guard.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/GetResourceGuard.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/GetResourceGuard.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_resource_guards_in_resource_group.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_resource_guards_in_resource_group.py index c9aa0f4bebae..f26da44fe848 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_resource_guards_in_resource_group.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_resource_guards_in_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/GetResourceGuardsInResourceGroup.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/GetResourceGuardsInResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_resource_guards_in_subscription.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_resource_guards_in_subscription.py index e983646692f6..85df4b590d21 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_resource_guards_in_subscription.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/get_resource_guards_in_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/GetResourceGuardsInSubscription.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/GetResourceGuardsInSubscription.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_backup_security_pin_requests.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_backup_security_pin_requests.py index ad3bf172acd3..430645782f4c 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_backup_security_pin_requests.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_backup_security_pin_requests.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/ListBackupSecurityPINRequests.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/ListBackupSecurityPINRequests.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_delete_protected_item_requests.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_delete_protected_item_requests.py index e0e5bfd887fd..51275bcf898a 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_delete_protected_item_requests.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_delete_protected_item_requests.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/ListDeleteProtectedItemRequests.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/ListDeleteProtectedItemRequests.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_delete_resource_guard_proxy_requests.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_delete_resource_guard_proxy_requests.py index fe065b4d2615..f108c0045db5 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_delete_resource_guard_proxy_requests.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_delete_resource_guard_proxy_requests.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/ListDeleteResourceGuardProxyRequests.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/ListDeleteResourceGuardProxyRequests.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_disable_soft_delete_requests.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_disable_soft_delete_requests.py index 36c8696ffbc6..f5e5512e41b3 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_disable_soft_delete_requests.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_disable_soft_delete_requests.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/ListDisableSoftDeleteRequests.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/ListDisableSoftDeleteRequests.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_update_protected_item_requests.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_update_protected_item_requests.py index 4d6e83e003ce..b54da0480395 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_update_protected_item_requests.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_update_protected_item_requests.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/ListUpdateProtectedItemRequests.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/ListUpdateProtectedItemRequests.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_update_protection_policy_requests.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_update_protection_policy_requests.py index 91848a1743fe..c7b0faf2878d 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_update_protection_policy_requests.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/list_update_protection_policy_requests.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/ListUpdateProtectionPolicyRequests.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/ListUpdateProtectionPolicyRequests.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/patch_resource_guard.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/patch_resource_guard.py index c4a569bfcb6a..b40c5096e602 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/patch_resource_guard.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/patch_resource_guard.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.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/PatchResourceGuard.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/PatchResourceGuard.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/put_resource_guard.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/put_resource_guard.py index 47b28571c077..a1cc47107e27 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/put_resource_guard.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_crud/put_resource_guard.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.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardCRUD/PutResourceGuard.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardCRUD/PutResourceGuard.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/delete_resource_guard_proxy.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/delete_resource_guard_proxy.py index abef6a83f3fb..e950921b3b50 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/delete_resource_guard_proxy.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/delete_resource_guard_proxy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -36,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardProxyCRUD/DeleteResourceGuardProxy.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardProxyCRUD/DeleteResourceGuardProxy.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/get_resource_guard_proxy.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/get_resource_guard_proxy.py index c961249b2dc6..7b3a32e7dacd 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/get_resource_guard_proxy.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/get_resource_guard_proxy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardProxyCRUD/GetResourceGuardProxy.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardProxyCRUD/GetResourceGuardProxy.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/list_resource_guard_proxy.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/list_resource_guard_proxy.py index 257aaa3e701a..ad626b87240a 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/list_resource_guard_proxy.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/list_resource_guard_proxy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardProxyCRUD/ListResourceGuardProxy.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardProxyCRUD/ListResourceGuardProxy.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/put_resource_guard_proxy.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/put_resource_guard_proxy.py index 9d756b791784..b1ea1686991b 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/put_resource_guard_proxy.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/put_resource_guard_proxy.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.dataprotection import DataProtectionMgmtClient """ @@ -42,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardProxyCRUD/PutResourceGuardProxy.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardProxyCRUD/PutResourceGuardProxy.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/unlock_delete_resource_guard_proxy.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/unlock_delete_resource_guard_proxy.py index c9889f17c5b8..219a7e5983e2 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/unlock_delete_resource_guard_proxy.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/resource_guard_proxy_crud/unlock_delete_resource_guard_proxy.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.dataprotection import DataProtectionMgmtClient """ @@ -43,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/ResourceGuardProxyCRUD/UnlockDeleteResourceGuardProxy.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/ResourceGuardProxyCRUD/UnlockDeleteResourceGuardProxy.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/check_backup_vaults_name_availability.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/check_backup_vaults_name_availability.py index 887613321d9a..9c2526c117e5 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/check_backup_vaults_name_availability.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/check_backup_vaults_name_availability.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.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/VaultCRUD/CheckBackupVaultsNameAvailability.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/VaultCRUD/CheckBackupVaultsNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/delete_backup_vault.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/delete_backup_vault.py index b639a35749a0..d5fdd0ac38bc 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/delete_backup_vault.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/delete_backup_vault.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/VaultCRUD/DeleteBackupVault.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/VaultCRUD/DeleteBackupVault.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vault.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vault.py index 160204ca9606..527cdbb9d2c4 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vault.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vault.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/VaultCRUD/GetBackupVault.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/VaultCRUD/GetBackupVault.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vault_with_cmk.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vault_with_cmk.py new file mode 100644 index 000000000000..4507887c3fec --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vault_with_cmk.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dataprotection +# USAGE + python get_backup_vault_with_cmk.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DataProtectionMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="0b352192-dcac-4cc7-992e-a96190ccc68c", + ) + + response = client.backup_vaults.get( + resource_group_name="SampleResourceGroup", + vault_name="swaggerExample", + ) + print(response) + + +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/VaultCRUD/GetBackupVaultWithCMK.json +if __name__ == "__main__": + main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vault_with_msi.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vault_with_msi.py index 623af5999b1b..d42aff54d2d2 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vault_with_msi.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vault_with_msi.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/VaultCRUD/GetBackupVaultWithMSI.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/VaultCRUD/GetBackupVaultWithMSI.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vaults_in_resource_group.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vaults_in_resource_group.py index 33e9398d33e2..2ff6a8ebad33 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vaults_in_resource_group.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vaults_in_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/VaultCRUD/GetBackupVaultsInResourceGroup.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/VaultCRUD/GetBackupVaultsInResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vaults_in_subscription.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vaults_in_subscription.py index 974163f59f13..3cf0732e5e7f 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vaults_in_subscription.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_backup_vaults_in_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/VaultCRUD/GetBackupVaultsInSubscription.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/VaultCRUD/GetBackupVaultsInSubscription.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_operation_result_patch.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_operation_result_patch.py index aec158802fef..f0d326d644ec 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_operation_result_patch.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/get_operation_result_patch.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.dataprotection import DataProtectionMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/VaultCRUD/GetOperationResultPatch.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/VaultCRUD/GetOperationResultPatch.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/patch_backup_vault.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/patch_backup_vault.py index 96873e68a22a..7dac9a7be9d0 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/patch_backup_vault.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/patch_backup_vault.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.dataprotection import DataProtectionMgmtClient """ @@ -40,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/VaultCRUD/PatchBackupVault.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/VaultCRUD/PatchBackupVault.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/patch_backup_vault_with_cmk.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/patch_backup_vault_with_cmk.py new file mode 100644 index 000000000000..e303ee0c0805 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/patch_backup_vault_with_cmk.py @@ -0,0 +1,62 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, IO, Union + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dataprotection +# USAGE + python patch_backup_vault_with_cmk.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DataProtectionMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="0b352192-dcac-4cc7-992e-a96190ccc68c", + ) + + response = client.backup_vaults.begin_update( + resource_group_name="SampleResourceGroup", + vault_name="swaggerExample", + parameters={ + "properties": { + "monitoringSettings": {"azureMonitorAlertSettings": {"alertsForAllJobFailures": "Enabled"}}, + "securitySettings": { + "encryptionSettings": { + "infrastructureEncryption": "Enabled", + "kekIdentity": {"identityType": "SystemAssigned"}, + "keyVaultProperties": { + "keyUri": "https://cmk2xkv.vault.azure.net/keys/Key1/0767b348bb1a4c07baa6c4ec0055d2b3" + }, + "state": "Enabled", + }, + "immutabilitySettings": {"state": "Disabled"}, + "softDeleteSettings": {"retentionDurationInDays": 90, "state": "On"}, + }, + }, + "tags": {"newKey": "newVal"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/VaultCRUD/PatchBackupVaultWithCMK.json +if __name__ == "__main__": + main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/put_backup_vault.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/put_backup_vault.py index f6f5b7783a88..3211aaf4e361 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/put_backup_vault.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/put_backup_vault.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.dataprotection import DataProtectionMgmtClient """ @@ -47,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/VaultCRUD/PutBackupVault.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/VaultCRUD/PutBackupVault.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/put_backup_vault_with_cmk.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/put_backup_vault_with_cmk.py new file mode 100644 index 000000000000..78e9a47082a7 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/put_backup_vault_with_cmk.py @@ -0,0 +1,68 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, IO, Union + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-dataprotection +# USAGE + python put_backup_vault_with_cmk.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = DataProtectionMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="0b352192-dcac-4cc7-992e-a96190ccc68c", + ) + + response = client.backup_vaults.begin_create_or_update( + resource_group_name="SampleResourceGroup", + vault_name="swaggerExample", + parameters={ + "identity": {"type": "None"}, + "location": "WestUS", + "properties": { + "monitoringSettings": {"azureMonitorAlertSettings": {"alertsForAllJobFailures": "Enabled"}}, + "securitySettings": { + "encryptionSettings": { + "infrastructureEncryption": "Enabled", + "kekIdentity": { + "identityId": "/subscriptions/85bf5e8c-3084-4f42-add2-746ebb7e97b2/resourcegroups/defaultrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplemsi", + "identityType": "UserAssigned", + }, + "keyVaultProperties": { + "keyUri": "https://cmk2xkv.vault.azure.net/keys/Key1/0767b348bb1a4c07baa6c4ec0055d2b3" + }, + "state": "Enabled", + }, + "immutabilitySettings": {"state": "Disabled"}, + "softDeleteSettings": {"retentionDurationInDays": 0, "state": "Off"}, + }, + "storageSettings": [{"datastoreType": "VaultStore", "type": "LocallyRedundant"}], + }, + "tags": {"key1": "val1"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/VaultCRUD/PutBackupVaultWithCMK.json +if __name__ == "__main__": + main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/put_backup_vault_with_msi.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/put_backup_vault_with_msi.py index 0f7436337c0a..64e832da3a2a 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/put_backup_vault_with_msi.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_samples/vault_crud/put_backup_vault_with_msi.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.dataprotection import DataProtectionMgmtClient """ @@ -47,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/examples/VaultCRUD/PutBackupVaultWithMSI.json +# x-ms-original-file: specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2024-04-01/examples/VaultCRUD/PutBackupVaultWithMSI.json if __name__ == "__main__": main() diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/conftest.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/conftest.py new file mode 100644 index 000000000000..611c373bd8c4 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/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): + dataprotectionmgmt_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + dataprotectionmgmt_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + dataprotectionmgmt_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + dataprotectionmgmt_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=dataprotectionmgmt_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=dataprotectionmgmt_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=dataprotectionmgmt_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=dataprotectionmgmt_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/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_instances_extension_routing_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_instances_extension_routing_operations.py new file mode 100644 index 000000000000..1557c9f36650 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_instances_extension_routing_operations.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtBackupInstancesExtensionRoutingOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.backup_instances_extension_routing.list( + resource_id="str", + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_instances_extension_routing_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_instances_extension_routing_operations_async.py new file mode 100644 index 000000000000..051e0bd38426 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_instances_extension_routing_operations_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtBackupInstancesExtensionRoutingOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.backup_instances_extension_routing.list( + resource_id="str", + api_version="2024-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_instances_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_instances_operations.py new file mode 100644 index 000000000000..c7fc90e8ae49 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_instances_operations.py @@ -0,0 +1,402 @@ +# 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.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtBackupInstancesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.backup_instances.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.backup_instances.get( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.backup_instances.begin_create_or_update( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": { + "dataSourceInfo": { + "resourceID": "str", + "datasourceType": "str", + "objectType": "str", + "resourceLocation": "str", + "resourceName": "str", + "resourceProperties": "base_resource_properties", + "resourceType": "str", + "resourceUri": "str", + }, + "objectType": "str", + "policyInfo": { + "policyId": "str", + "policyParameters": { + "backupDatasourceParametersList": ["backup_datasource_parameters"], + "dataStoreParametersList": ["data_store_parameters"], + }, + "policyVersion": "str", + }, + "currentProtectionState": "str", + "dataSourceSetInfo": { + "resourceID": "str", + "datasourceType": "str", + "objectType": "str", + "resourceLocation": "str", + "resourceName": "str", + "resourceProperties": "base_resource_properties", + "resourceType": "str", + "resourceUri": "str", + }, + "datasourceAuthCredentials": "auth_credentials", + "friendlyName": "str", + "identityDetails": {"useSystemAssignedIdentity": bool, "userAssignedIdentityArmUrl": "str"}, + "protectionErrorDetails": { + "code": "str", + "details": [...], + "innerError": {"additionalInfo": {"str": "str"}, "code": "str", "embeddedInnerError": ...}, + "isRetryable": bool, + "isUserError": bool, + "message": "str", + "properties": {"str": "str"}, + "recommendedAction": ["str"], + "target": "str", + }, + "protectionStatus": { + "errorDetails": { + "code": "str", + "details": [...], + "innerError": {"additionalInfo": {"str": "str"}, "code": "str", "embeddedInnerError": ...}, + "isRetryable": bool, + "isUserError": bool, + "message": "str", + "properties": {"str": "str"}, + "recommendedAction": ["str"], + "target": "str", + }, + "status": "str", + }, + "provisioningState": "str", + "resourceGuardOperationRequests": ["str"], + "validationType": "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-04-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.backup_instances.begin_delete( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-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_adhoc_backup(self, resource_group): + response = self.client.backup_instances.begin_adhoc_backup( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + parameters={"backupRuleOptions": {"ruleName": "str", "triggerOption": {"retentionTagOverride": "str"}}}, + api_version="2024-04-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_validate_for_backup(self, resource_group): + response = self.client.backup_instances.begin_validate_for_backup( + resource_group_name=resource_group.name, + vault_name="str", + parameters={ + "backupInstance": { + "dataSourceInfo": { + "resourceID": "str", + "datasourceType": "str", + "objectType": "str", + "resourceLocation": "str", + "resourceName": "str", + "resourceProperties": "base_resource_properties", + "resourceType": "str", + "resourceUri": "str", + }, + "objectType": "str", + "policyInfo": { + "policyId": "str", + "policyParameters": { + "backupDatasourceParametersList": ["backup_datasource_parameters"], + "dataStoreParametersList": ["data_store_parameters"], + }, + "policyVersion": "str", + }, + "currentProtectionState": "str", + "dataSourceSetInfo": { + "resourceID": "str", + "datasourceType": "str", + "objectType": "str", + "resourceLocation": "str", + "resourceName": "str", + "resourceProperties": "base_resource_properties", + "resourceType": "str", + "resourceUri": "str", + }, + "datasourceAuthCredentials": "auth_credentials", + "friendlyName": "str", + "identityDetails": {"useSystemAssignedIdentity": bool, "userAssignedIdentityArmUrl": "str"}, + "protectionErrorDetails": { + "code": "str", + "details": [...], + "innerError": {"additionalInfo": {"str": "str"}, "code": "str", "embeddedInnerError": ...}, + "isRetryable": bool, + "isUserError": bool, + "message": "str", + "properties": {"str": "str"}, + "recommendedAction": ["str"], + "target": "str", + }, + "protectionStatus": { + "errorDetails": { + "code": "str", + "details": [...], + "innerError": {"additionalInfo": {"str": "str"}, "code": "str", "embeddedInnerError": ...}, + "isRetryable": bool, + "isUserError": bool, + "message": "str", + "properties": {"str": "str"}, + "recommendedAction": ["str"], + "target": "str", + }, + "status": "str", + }, + "provisioningState": "str", + "resourceGuardOperationRequests": ["str"], + "validationType": "str", + } + }, + api_version="2024-04-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_backup_instance_operation_result(self, resource_group): + response = self.client.backup_instances.get_backup_instance_operation_result( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + operation_id="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_trigger_cross_region_restore(self, resource_group): + response = self.client.backup_instances.begin_trigger_cross_region_restore( + resource_group_name=resource_group.name, + location="str", + parameters={ + "crossRegionRestoreDetails": {"sourceBackupInstanceId": "str", "sourceRegion": "str"}, + "restoreRequestObject": "azure_backup_restore_request", + }, + api_version="2024-04-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_validate_cross_region_restore(self, resource_group): + response = self.client.backup_instances.begin_validate_cross_region_restore( + resource_group_name=resource_group.name, + location="str", + parameters={ + "crossRegionRestoreDetails": {"sourceBackupInstanceId": "str", "sourceRegion": "str"}, + "restoreRequestObject": "azure_backup_restore_request", + }, + api_version="2024-04-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_trigger_rehydrate(self, resource_group): + response = self.client.backup_instances.begin_trigger_rehydrate( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + parameters={"recoveryPointId": "str", "rehydrationRetentionDuration": "str", "rehydrationPriority": "str"}, + api_version="2024-04-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_trigger_restore(self, resource_group): + response = self.client.backup_instances.begin_trigger_restore( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + parameters={ + "objectType": "AzureBackupRestoreWithRehydrationRequest", + "recoveryPointId": "str", + "rehydrationPriority": "str", + "rehydrationRetentionDuration": "str", + "restoreTargetInfo": "restore_target_info_base", + "sourceDataStoreType": "str", + "identityDetails": {"useSystemAssignedIdentity": bool, "userAssignedIdentityArmUrl": "str"}, + "resourceGuardOperationRequests": ["str"], + "sourceResourceId": "str", + }, + api_version="2024-04-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_resume_backups(self, resource_group): + response = self.client.backup_instances.begin_resume_backups( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-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_resume_protection(self, resource_group): + response = self.client.backup_instances.begin_resume_protection( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-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_stop_protection(self, resource_group): + response = self.client.backup_instances.begin_stop_protection( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-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_suspend_backups(self, resource_group): + response = self.client.backup_instances.begin_suspend_backups( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-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_sync_backup_instance(self, resource_group): + response = self.client.backup_instances.begin_sync_backup_instance( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + parameters={"syncType": "str"}, + api_version="2024-04-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_validate_for_restore(self, resource_group): + response = self.client.backup_instances.begin_validate_for_restore( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + parameters={"restoreRequestObject": "azure_backup_restore_request"}, + api_version="2024-04-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_instances_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_instances_operations_async.py new file mode 100644 index 000000000000..3c8d86348de3 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_instances_operations_async.py @@ -0,0 +1,443 @@ +# 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.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtBackupInstancesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.backup_instances.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-04-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_get(self, resource_group): + response = await self.client.backup_instances.get( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.backup_instances.begin_create_or_update( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": { + "dataSourceInfo": { + "resourceID": "str", + "datasourceType": "str", + "objectType": "str", + "resourceLocation": "str", + "resourceName": "str", + "resourceProperties": "base_resource_properties", + "resourceType": "str", + "resourceUri": "str", + }, + "objectType": "str", + "policyInfo": { + "policyId": "str", + "policyParameters": { + "backupDatasourceParametersList": ["backup_datasource_parameters"], + "dataStoreParametersList": ["data_store_parameters"], + }, + "policyVersion": "str", + }, + "currentProtectionState": "str", + "dataSourceSetInfo": { + "resourceID": "str", + "datasourceType": "str", + "objectType": "str", + "resourceLocation": "str", + "resourceName": "str", + "resourceProperties": "base_resource_properties", + "resourceType": "str", + "resourceUri": "str", + }, + "datasourceAuthCredentials": "auth_credentials", + "friendlyName": "str", + "identityDetails": {"useSystemAssignedIdentity": bool, "userAssignedIdentityArmUrl": "str"}, + "protectionErrorDetails": { + "code": "str", + "details": [...], + "innerError": {"additionalInfo": {"str": "str"}, "code": "str", "embeddedInnerError": ...}, + "isRetryable": bool, + "isUserError": bool, + "message": "str", + "properties": {"str": "str"}, + "recommendedAction": ["str"], + "target": "str", + }, + "protectionStatus": { + "errorDetails": { + "code": "str", + "details": [...], + "innerError": { + "additionalInfo": {"str": "str"}, + "code": "str", + "embeddedInnerError": ..., + }, + "isRetryable": bool, + "isUserError": bool, + "message": "str", + "properties": {"str": "str"}, + "recommendedAction": ["str"], + "target": "str", + }, + "status": "str", + }, + "provisioningState": "str", + "resourceGuardOperationRequests": ["str"], + "validationType": "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-04-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.backup_instances.begin_delete( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-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_adhoc_backup(self, resource_group): + response = await ( + await self.client.backup_instances.begin_adhoc_backup( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + parameters={"backupRuleOptions": {"ruleName": "str", "triggerOption": {"retentionTagOverride": "str"}}}, + api_version="2024-04-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_validate_for_backup(self, resource_group): + response = await ( + await self.client.backup_instances.begin_validate_for_backup( + resource_group_name=resource_group.name, + vault_name="str", + parameters={ + "backupInstance": { + "dataSourceInfo": { + "resourceID": "str", + "datasourceType": "str", + "objectType": "str", + "resourceLocation": "str", + "resourceName": "str", + "resourceProperties": "base_resource_properties", + "resourceType": "str", + "resourceUri": "str", + }, + "objectType": "str", + "policyInfo": { + "policyId": "str", + "policyParameters": { + "backupDatasourceParametersList": ["backup_datasource_parameters"], + "dataStoreParametersList": ["data_store_parameters"], + }, + "policyVersion": "str", + }, + "currentProtectionState": "str", + "dataSourceSetInfo": { + "resourceID": "str", + "datasourceType": "str", + "objectType": "str", + "resourceLocation": "str", + "resourceName": "str", + "resourceProperties": "base_resource_properties", + "resourceType": "str", + "resourceUri": "str", + }, + "datasourceAuthCredentials": "auth_credentials", + "friendlyName": "str", + "identityDetails": {"useSystemAssignedIdentity": bool, "userAssignedIdentityArmUrl": "str"}, + "protectionErrorDetails": { + "code": "str", + "details": [...], + "innerError": {"additionalInfo": {"str": "str"}, "code": "str", "embeddedInnerError": ...}, + "isRetryable": bool, + "isUserError": bool, + "message": "str", + "properties": {"str": "str"}, + "recommendedAction": ["str"], + "target": "str", + }, + "protectionStatus": { + "errorDetails": { + "code": "str", + "details": [...], + "innerError": { + "additionalInfo": {"str": "str"}, + "code": "str", + "embeddedInnerError": ..., + }, + "isRetryable": bool, + "isUserError": bool, + "message": "str", + "properties": {"str": "str"}, + "recommendedAction": ["str"], + "target": "str", + }, + "status": "str", + }, + "provisioningState": "str", + "resourceGuardOperationRequests": ["str"], + "validationType": "str", + } + }, + api_version="2024-04-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_backup_instance_operation_result(self, resource_group): + response = await self.client.backup_instances.get_backup_instance_operation_result( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + operation_id="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_trigger_cross_region_restore(self, resource_group): + response = await ( + await self.client.backup_instances.begin_trigger_cross_region_restore( + resource_group_name=resource_group.name, + location="str", + parameters={ + "crossRegionRestoreDetails": {"sourceBackupInstanceId": "str", "sourceRegion": "str"}, + "restoreRequestObject": "azure_backup_restore_request", + }, + api_version="2024-04-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_validate_cross_region_restore(self, resource_group): + response = await ( + await self.client.backup_instances.begin_validate_cross_region_restore( + resource_group_name=resource_group.name, + location="str", + parameters={ + "crossRegionRestoreDetails": {"sourceBackupInstanceId": "str", "sourceRegion": "str"}, + "restoreRequestObject": "azure_backup_restore_request", + }, + api_version="2024-04-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_trigger_rehydrate(self, resource_group): + response = await ( + await self.client.backup_instances.begin_trigger_rehydrate( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + parameters={ + "recoveryPointId": "str", + "rehydrationRetentionDuration": "str", + "rehydrationPriority": "str", + }, + api_version="2024-04-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_trigger_restore(self, resource_group): + response = await ( + await self.client.backup_instances.begin_trigger_restore( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + parameters={ + "objectType": "AzureBackupRestoreWithRehydrationRequest", + "recoveryPointId": "str", + "rehydrationPriority": "str", + "rehydrationRetentionDuration": "str", + "restoreTargetInfo": "restore_target_info_base", + "sourceDataStoreType": "str", + "identityDetails": {"useSystemAssignedIdentity": bool, "userAssignedIdentityArmUrl": "str"}, + "resourceGuardOperationRequests": ["str"], + "sourceResourceId": "str", + }, + api_version="2024-04-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_resume_backups(self, resource_group): + response = await ( + await self.client.backup_instances.begin_resume_backups( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-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_resume_protection(self, resource_group): + response = await ( + await self.client.backup_instances.begin_resume_protection( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-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_stop_protection(self, resource_group): + response = await ( + await self.client.backup_instances.begin_stop_protection( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-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_suspend_backups(self, resource_group): + response = await ( + await self.client.backup_instances.begin_suspend_backups( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-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_sync_backup_instance(self, resource_group): + response = await ( + await self.client.backup_instances.begin_sync_backup_instance( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + parameters={"syncType": "str"}, + api_version="2024-04-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_validate_for_restore(self, resource_group): + response = await ( + await self.client.backup_instances.begin_validate_for_restore( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + parameters={"restoreRequestObject": "azure_backup_restore_request"}, + api_version="2024-04-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_policies_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_policies_operations.py new file mode 100644 index 000000000000..66e8e998bd1a --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_policies_operations.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtBackupPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.backup_policies.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.backup_policies.get( + resource_group_name=resource_group.name, + vault_name="str", + backup_policy_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.backup_policies.create_or_update( + resource_group_name=resource_group.name, + vault_name="str", + backup_policy_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": "base_backup_policy", + "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-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.backup_policies.delete( + resource_group_name=resource_group.name, + vault_name="str", + backup_policy_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_policies_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_policies_operations_async.py new file mode 100644 index 000000000000..fd7d8d4734a8 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_policies_operations_async.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtBackupPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.backup_policies.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-04-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_get(self, resource_group): + response = await self.client.backup_policies.get( + resource_group_name=resource_group.name, + vault_name="str", + backup_policy_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.backup_policies.create_or_update( + resource_group_name=resource_group.name, + vault_name="str", + backup_policy_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": "base_backup_policy", + "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-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.backup_policies.delete( + resource_group_name=resource_group.name, + vault_name="str", + backup_policy_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_vault_operation_results_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_vault_operation_results_operations.py new file mode 100644 index 000000000000..9dfd7d93ba8c --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_vault_operation_results_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtBackupVaultOperationResultsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.backup_vault_operation_results.get( + resource_group_name=resource_group.name, + vault_name="str", + operation_id="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_vault_operation_results_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_vault_operation_results_operations_async.py new file mode 100644 index 000000000000..1f3254616370 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_vault_operation_results_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtBackupVaultOperationResultsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.backup_vault_operation_results.get( + resource_group_name=resource_group.name, + vault_name="str", + operation_id="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_vaults_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_vaults_operations.py new file mode 100644 index 000000000000..f31c5d2f25c5 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_vaults_operations.py @@ -0,0 +1,182 @@ +# 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.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtBackupVaultsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_in_subscription(self, resource_group): + response = self.client.backup_vaults.get_in_subscription( + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_in_resource_group(self, resource_group): + response = self.client.backup_vaults.get_in_resource_group( + resource_group_name=resource_group.name, + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.backup_vaults.get( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.backup_vaults.begin_create_or_update( + resource_group_name=resource_group.name, + vault_name="str", + parameters={ + "properties": { + "storageSettings": [{"datastoreType": "str", "type": "str"}], + "bcdrSecurityLevel": "str", + "featureSettings": { + "crossRegionRestoreSettings": {"state": "str"}, + "crossSubscriptionRestoreSettings": {"state": "str"}, + }, + "isVaultProtectedByResourceGuard": bool, + "monitoringSettings": {"azureMonitorAlertSettings": {"alertsForAllJobFailures": "str"}}, + "provisioningState": "str", + "replicatedRegions": ["str"], + "resourceGuardOperationRequests": ["str"], + "resourceMoveDetails": { + "completionTimeUtc": "str", + "operationId": "str", + "sourceResourcePath": "str", + "startTimeUtc": "str", + "targetResourcePath": "str", + }, + "resourceMoveState": "str", + "secureScore": "str", + "securitySettings": { + "encryptionSettings": { + "infrastructureEncryption": "str", + "kekIdentity": {"identityId": "str", "identityType": "str"}, + "keyVaultProperties": {"keyUri": "str"}, + "state": "str", + }, + "immutabilitySettings": {"state": "str"}, + "softDeleteSettings": {"retentionDurationInDays": 0.0, "state": "str"}, + }, + }, + "eTag": "str", + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "location": "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-04-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.backup_vaults.begin_delete( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-04-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.backup_vaults.begin_update( + resource_group_name=resource_group.name, + vault_name="str", + parameters={ + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "properties": { + "featureSettings": { + "crossRegionRestoreSettings": {"state": "str"}, + "crossSubscriptionRestoreSettings": {"state": "str"}, + }, + "monitoringSettings": {"azureMonitorAlertSettings": {"alertsForAllJobFailures": "str"}}, + "resourceGuardOperationRequests": ["str"], + "securitySettings": { + "encryptionSettings": { + "infrastructureEncryption": "str", + "kekIdentity": {"identityId": "str", "identityType": "str"}, + "keyVaultProperties": {"keyUri": "str"}, + "state": "str", + }, + "immutabilitySettings": {"state": "str"}, + "softDeleteSettings": {"retentionDurationInDays": 0.0, "state": "str"}, + }, + }, + "tags": {"str": "str"}, + }, + api_version="2024-04-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_check_name_availability(self, resource_group): + response = self.client.backup_vaults.check_name_availability( + resource_group_name=resource_group.name, + location="str", + parameters={"name": "str", "type": "str"}, + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_vaults_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_vaults_operations_async.py new file mode 100644 index 000000000000..193b5d530e9a --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_backup_vaults_operations_async.py @@ -0,0 +1,189 @@ +# 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.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtBackupVaultsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_in_subscription(self, resource_group): + response = self.client.backup_vaults.get_in_subscription( + api_version="2024-04-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_get_in_resource_group(self, resource_group): + response = self.client.backup_vaults.get_in_resource_group( + resource_group_name=resource_group.name, + api_version="2024-04-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_get(self, resource_group): + response = await self.client.backup_vaults.get( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.backup_vaults.begin_create_or_update( + resource_group_name=resource_group.name, + vault_name="str", + parameters={ + "properties": { + "storageSettings": [{"datastoreType": "str", "type": "str"}], + "bcdrSecurityLevel": "str", + "featureSettings": { + "crossRegionRestoreSettings": {"state": "str"}, + "crossSubscriptionRestoreSettings": {"state": "str"}, + }, + "isVaultProtectedByResourceGuard": bool, + "monitoringSettings": {"azureMonitorAlertSettings": {"alertsForAllJobFailures": "str"}}, + "provisioningState": "str", + "replicatedRegions": ["str"], + "resourceGuardOperationRequests": ["str"], + "resourceMoveDetails": { + "completionTimeUtc": "str", + "operationId": "str", + "sourceResourcePath": "str", + "startTimeUtc": "str", + "targetResourcePath": "str", + }, + "resourceMoveState": "str", + "secureScore": "str", + "securitySettings": { + "encryptionSettings": { + "infrastructureEncryption": "str", + "kekIdentity": {"identityId": "str", "identityType": "str"}, + "keyVaultProperties": {"keyUri": "str"}, + "state": "str", + }, + "immutabilitySettings": {"state": "str"}, + "softDeleteSettings": {"retentionDurationInDays": 0.0, "state": "str"}, + }, + }, + "eTag": "str", + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "location": "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-04-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.backup_vaults.begin_delete( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-04-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.backup_vaults.begin_update( + resource_group_name=resource_group.name, + vault_name="str", + parameters={ + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "properties": { + "featureSettings": { + "crossRegionRestoreSettings": {"state": "str"}, + "crossSubscriptionRestoreSettings": {"state": "str"}, + }, + "monitoringSettings": {"azureMonitorAlertSettings": {"alertsForAllJobFailures": "str"}}, + "resourceGuardOperationRequests": ["str"], + "securitySettings": { + "encryptionSettings": { + "infrastructureEncryption": "str", + "kekIdentity": {"identityId": "str", "identityType": "str"}, + "keyVaultProperties": {"keyUri": "str"}, + "state": "str", + }, + "immutabilitySettings": {"state": "str"}, + "softDeleteSettings": {"retentionDurationInDays": 0.0, "state": "str"}, + }, + }, + "tags": {"str": "str"}, + }, + api_version="2024-04-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_check_name_availability(self, resource_group): + response = await self.client.backup_vaults.check_name_availability( + resource_group_name=resource_group.name, + location="str", + parameters={"name": "str", "type": "str"}, + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_data_protection_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_data_protection_operations.py new file mode 100644 index 000000000000..2abd99194da0 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_data_protection_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.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtDataProtectionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_feature_support(self, resource_group): + response = self.client.data_protection.check_feature_support( + location="str", + parameters={"objectType": "FeatureValidationRequest", "featureName": "str", "featureType": "str"}, + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_data_protection_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_data_protection_operations_async.py new file mode 100644 index 000000000000..51578c539823 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_data_protection_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.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtDataProtectionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_feature_support(self, resource_group): + response = await self.client.data_protection.check_feature_support( + location="str", + parameters={"objectType": "FeatureValidationRequest", "featureName": "str", "featureType": "str"}, + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_data_protection_operations_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_data_protection_operations_operations.py new file mode 100644 index 000000000000..41ade571d9b6 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_data_protection_operations_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtDataProtectionOperationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.data_protection_operations.list( + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_data_protection_operations_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_data_protection_operations_operations_async.py new file mode 100644 index 000000000000..822049595e7c --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_data_protection_operations_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtDataProtectionOperationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.data_protection_operations.list( + api_version="2024-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_deleted_backup_instances_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_deleted_backup_instances_operations.py new file mode 100644 index 000000000000..e7bcab7e4127 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_deleted_backup_instances_operations.py @@ -0,0 +1,57 @@ +# 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.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtDeletedBackupInstancesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.deleted_backup_instances.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.deleted_backup_instances.get( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_undelete(self, resource_group): + response = self.client.deleted_backup_instances.begin_undelete( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_deleted_backup_instances_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_deleted_backup_instances_operations_async.py new file mode 100644 index 000000000000..1d57b7050e43 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_deleted_backup_instances_operations_async.py @@ -0,0 +1,60 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtDeletedBackupInstancesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.deleted_backup_instances.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-04-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_get(self, resource_group): + response = await self.client.deleted_backup_instances.get( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_undelete(self, resource_group): + response = await ( + await self.client.deleted_backup_instances.begin_undelete( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_dpp_resource_guard_proxy_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_dpp_resource_guard_proxy_operations.py new file mode 100644 index 000000000000..7e196900edde --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_dpp_resource_guard_proxy_operations.py @@ -0,0 +1,105 @@ +# 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.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtDppResourceGuardProxyOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.dpp_resource_guard_proxy.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.dpp_resource_guard_proxy.get( + resource_group_name=resource_group.name, + vault_name="str", + resource_guard_proxy_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.dpp_resource_guard_proxy.create_or_update( + resource_group_name=resource_group.name, + vault_name="str", + resource_guard_proxy_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": { + "description": "str", + "lastUpdatedTime": "str", + "resourceGuardOperationDetails": [ + {"defaultResourceRequest": "str", "vaultCriticalOperation": "str"} + ], + "resourceGuardResourceId": "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-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.dpp_resource_guard_proxy.delete( + resource_group_name=resource_group.name, + vault_name="str", + resource_guard_proxy_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_unlock_delete(self, resource_group): + response = self.client.dpp_resource_guard_proxy.unlock_delete( + resource_group_name=resource_group.name, + vault_name="str", + resource_guard_proxy_name="str", + parameters={"resourceGuardOperationRequests": ["str"], "resourceToBeDeleted": "str"}, + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_dpp_resource_guard_proxy_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_dpp_resource_guard_proxy_operations_async.py new file mode 100644 index 000000000000..8240aef1d353 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_dpp_resource_guard_proxy_operations_async.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtDppResourceGuardProxyOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.dpp_resource_guard_proxy.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-04-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_get(self, resource_group): + response = await self.client.dpp_resource_guard_proxy.get( + resource_group_name=resource_group.name, + vault_name="str", + resource_guard_proxy_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.dpp_resource_guard_proxy.create_or_update( + resource_group_name=resource_group.name, + vault_name="str", + resource_guard_proxy_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": { + "description": "str", + "lastUpdatedTime": "str", + "resourceGuardOperationDetails": [ + {"defaultResourceRequest": "str", "vaultCriticalOperation": "str"} + ], + "resourceGuardResourceId": "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-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.dpp_resource_guard_proxy.delete( + resource_group_name=resource_group.name, + vault_name="str", + resource_guard_proxy_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_unlock_delete(self, resource_group): + response = await self.client.dpp_resource_guard_proxy.unlock_delete( + resource_group_name=resource_group.name, + vault_name="str", + resource_guard_proxy_name="str", + parameters={"resourceGuardOperationRequests": ["str"], "resourceToBeDeleted": "str"}, + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_export_jobs_operation_result_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_export_jobs_operation_result_operations.py new file mode 100644 index 000000000000..514b9f55bbcf --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_export_jobs_operation_result_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtExportJobsOperationResultOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.export_jobs_operation_result.get( + resource_group_name=resource_group.name, + vault_name="str", + operation_id="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_export_jobs_operation_result_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_export_jobs_operation_result_operations_async.py new file mode 100644 index 000000000000..598666f73963 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_export_jobs_operation_result_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtExportJobsOperationResultOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.export_jobs_operation_result.get( + resource_group_name=resource_group.name, + vault_name="str", + operation_id="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_export_jobs_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_export_jobs_operations.py new file mode 100644 index 000000000000..bd7f72db261b --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_export_jobs_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.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtExportJobsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_trigger(self, resource_group): + response = self.client.export_jobs.begin_trigger( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-04-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_export_jobs_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_export_jobs_operations_async.py new file mode 100644 index 000000000000..1862945c291a --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_export_jobs_operations_async.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtExportJobsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_trigger(self, resource_group): + response = await ( + await self.client.export_jobs.begin_trigger( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-04-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_cross_region_restore_job_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_cross_region_restore_job_operations.py new file mode 100644 index 000000000000..af79320f9c99 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_cross_region_restore_job_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtFetchCrossRegionRestoreJobOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.fetch_cross_region_restore_job.get( + resource_group_name=resource_group.name, + location="str", + parameters={"jobId": "str", "sourceBackupVaultId": "str", "sourceRegion": "str"}, + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_cross_region_restore_job_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_cross_region_restore_job_operations_async.py new file mode 100644 index 000000000000..7c85abda00a7 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_cross_region_restore_job_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtFetchCrossRegionRestoreJobOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.fetch_cross_region_restore_job.get( + resource_group_name=resource_group.name, + location="str", + parameters={"jobId": "str", "sourceBackupVaultId": "str", "sourceRegion": "str"}, + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_cross_region_restore_jobs_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_cross_region_restore_jobs_operations.py new file mode 100644 index 000000000000..bf9b1fbd022e --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_cross_region_restore_jobs_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtFetchCrossRegionRestoreJobsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.fetch_cross_region_restore_jobs.list( + resource_group_name=resource_group.name, + location="str", + parameters={"sourceBackupVaultId": "str", "sourceRegion": "str"}, + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_cross_region_restore_jobs_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_cross_region_restore_jobs_operations_async.py new file mode 100644 index 000000000000..275159ed2423 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_cross_region_restore_jobs_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtFetchCrossRegionRestoreJobsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.fetch_cross_region_restore_jobs.list( + resource_group_name=resource_group.name, + location="str", + parameters={"sourceBackupVaultId": "str", "sourceRegion": "str"}, + api_version="2024-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_secondary_recovery_points_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_secondary_recovery_points_operations.py new file mode 100644 index 000000000000..a72241d024be --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_secondary_recovery_points_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtFetchSecondaryRecoveryPointsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.fetch_secondary_recovery_points.list( + resource_group_name=resource_group.name, + location="str", + parameters={"sourceBackupInstanceId": "str", "sourceRegion": "str"}, + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_secondary_recovery_points_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_secondary_recovery_points_operations_async.py new file mode 100644 index 000000000000..c1eca7617373 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_fetch_secondary_recovery_points_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtFetchSecondaryRecoveryPointsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.fetch_secondary_recovery_points.list( + resource_group_name=resource_group.name, + location="str", + parameters={"sourceBackupInstanceId": "str", "sourceRegion": "str"}, + api_version="2024-04-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_jobs_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_jobs_operations.py new file mode 100644 index 000000000000..bc9d1529aa8f --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_jobs_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtJobsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.jobs.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.jobs.get( + resource_group_name=resource_group.name, + vault_name="str", + job_id="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_jobs_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_jobs_operations_async.py new file mode 100644 index 000000000000..fad62b9e260b --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_jobs_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtJobsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.jobs.list( + resource_group_name=resource_group.name, + vault_name="str", + api_version="2024-04-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_get(self, resource_group): + response = await self.client.jobs.get( + resource_group_name=resource_group.name, + vault_name="str", + job_id="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_result_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_result_operations.py new file mode 100644 index 000000000000..b361860883fc --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_result_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.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtOperationResultOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.operation_result.get( + operation_id="str", + location="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_result_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_result_operations_async.py new file mode 100644 index 000000000000..db9b756758f0 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_result_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.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtOperationResultOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.operation_result.get( + operation_id="str", + location="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_backup_vault_context_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_backup_vault_context_operations.py new file mode 100644 index 000000000000..0781ac4c348d --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_backup_vault_context_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtOperationStatusBackupVaultContextOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.operation_status_backup_vault_context.get( + resource_group_name=resource_group.name, + vault_name="str", + operation_id="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_backup_vault_context_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_backup_vault_context_operations_async.py new file mode 100644 index 000000000000..19453274e079 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_backup_vault_context_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtOperationStatusBackupVaultContextOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.operation_status_backup_vault_context.get( + resource_group_name=resource_group.name, + vault_name="str", + operation_id="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_operations.py new file mode 100644 index 000000000000..9ca006ee0804 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_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.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtOperationStatusOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.operation_status.get( + location="str", + operation_id="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_operations_async.py new file mode 100644 index 000000000000..f96e76ace122 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_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.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtOperationStatusOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.operation_status.get( + location="str", + operation_id="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_resource_group_context_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_resource_group_context_operations.py new file mode 100644 index 000000000000..58600cdef866 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_resource_group_context_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.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtOperationStatusResourceGroupContextOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.operation_status_resource_group_context.get( + resource_group_name=resource_group.name, + operation_id="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_resource_group_context_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_resource_group_context_operations_async.py new file mode 100644 index 000000000000..8d9d043f366e --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_operation_status_resource_group_context_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.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtOperationStatusResourceGroupContextOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.operation_status_resource_group_context.get( + resource_group_name=resource_group.name, + operation_id="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_recovery_points_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_recovery_points_operations.py new file mode 100644 index 000000000000..111648bbeba2 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_recovery_points_operations.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtRecoveryPointsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.recovery_points.list( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.recovery_points.get( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + recovery_point_id="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_recovery_points_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_recovery_points_operations_async.py new file mode 100644 index 000000000000..30a1e08e7cbd --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_recovery_points_operations_async.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtRecoveryPointsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.recovery_points.list( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + api_version="2024-04-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_get(self, resource_group): + response = await self.client.recovery_points.get( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + recovery_point_id="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_resource_guards_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_resource_guards_operations.py new file mode 100644 index 000000000000..2d068fce7519 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_resource_guards_operations.py @@ -0,0 +1,262 @@ +# 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.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtResourceGuardsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_resources_in_subscription(self, resource_group): + response = self.client.resource_guards.get_resources_in_subscription( + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_resources_in_resource_group(self, resource_group): + response = self.client.resource_guards.get_resources_in_resource_group( + resource_group_name=resource_group.name, + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_put(self, resource_group): + response = self.client.resource_guards.put( + resource_group_name=resource_group.name, + resource_guards_name="str", + parameters={ + "eTag": "str", + "id": "str", + "location": "str", + "name": "str", + "properties": { + "allowAutoApprovals": bool, + "description": "str", + "provisioningState": "str", + "resourceGuardOperations": [{"requestResourceType": "str", "vaultCriticalOperation": "str"}], + "vaultCriticalOperationExclusionList": ["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-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.resource_guards.get( + resource_group_name=resource_group.name, + resource_guards_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.resource_guards.delete( + resource_group_name=resource_group.name, + resource_guards_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_patch(self, resource_group): + response = self.client.resource_guards.patch( + resource_group_name=resource_group.name, + resource_guards_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_disable_soft_delete_requests_objects(self, resource_group): + response = self.client.resource_guards.get_disable_soft_delete_requests_objects( + resource_group_name=resource_group.name, + resource_guards_name="str", + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_delete_resource_guard_proxy_requests_objects(self, resource_group): + response = self.client.resource_guards.get_delete_resource_guard_proxy_requests_objects( + resource_group_name=resource_group.name, + resource_guards_name="str", + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_backup_security_pin_requests_objects(self, resource_group): + response = self.client.resource_guards.get_backup_security_pin_requests_objects( + resource_group_name=resource_group.name, + resource_guards_name="str", + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_delete_protected_item_requests_objects(self, resource_group): + response = self.client.resource_guards.get_delete_protected_item_requests_objects( + resource_group_name=resource_group.name, + resource_guards_name="str", + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_update_protection_policy_requests_objects(self, resource_group): + response = self.client.resource_guards.get_update_protection_policy_requests_objects( + resource_group_name=resource_group.name, + resource_guards_name="str", + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_update_protected_item_requests_objects(self, resource_group): + response = self.client.resource_guards.get_update_protected_item_requests_objects( + resource_group_name=resource_group.name, + resource_guards_name="str", + api_version="2024-04-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_default_disable_soft_delete_requests_object(self, resource_group): + response = self.client.resource_guards.get_default_disable_soft_delete_requests_object( + resource_group_name=resource_group.name, + resource_guards_name="str", + request_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_default_delete_resource_guard_proxy_requests_object(self, resource_group): + response = self.client.resource_guards.get_default_delete_resource_guard_proxy_requests_object( + resource_group_name=resource_group.name, + resource_guards_name="str", + request_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_default_backup_security_pin_requests_object(self, resource_group): + response = self.client.resource_guards.get_default_backup_security_pin_requests_object( + resource_group_name=resource_group.name, + resource_guards_name="str", + request_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_default_delete_protected_item_requests_object(self, resource_group): + response = self.client.resource_guards.get_default_delete_protected_item_requests_object( + resource_group_name=resource_group.name, + resource_guards_name="str", + request_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_default_update_protection_policy_requests_object(self, resource_group): + response = self.client.resource_guards.get_default_update_protection_policy_requests_object( + resource_group_name=resource_group.name, + resource_guards_name="str", + request_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_default_update_protected_item_requests_object(self, resource_group): + response = self.client.resource_guards.get_default_update_protected_item_requests_object( + resource_group_name=resource_group.name, + resource_guards_name="str", + request_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_resource_guards_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_resource_guards_operations_async.py new file mode 100644 index 000000000000..a0d19fa5bd96 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_resource_guards_operations_async.py @@ -0,0 +1,263 @@ +# 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.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtResourceGuardsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_resources_in_subscription(self, resource_group): + response = self.client.resource_guards.get_resources_in_subscription( + api_version="2024-04-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_get_resources_in_resource_group(self, resource_group): + response = self.client.resource_guards.get_resources_in_resource_group( + resource_group_name=resource_group.name, + api_version="2024-04-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_put(self, resource_group): + response = await self.client.resource_guards.put( + resource_group_name=resource_group.name, + resource_guards_name="str", + parameters={ + "eTag": "str", + "id": "str", + "location": "str", + "name": "str", + "properties": { + "allowAutoApprovals": bool, + "description": "str", + "provisioningState": "str", + "resourceGuardOperations": [{"requestResourceType": "str", "vaultCriticalOperation": "str"}], + "vaultCriticalOperationExclusionList": ["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-04-01", + ) + + # 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.resource_guards.get( + resource_group_name=resource_group.name, + resource_guards_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.resource_guards.delete( + resource_group_name=resource_group.name, + resource_guards_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_patch(self, resource_group): + response = await self.client.resource_guards.patch( + resource_group_name=resource_group.name, + resource_guards_name="str", + parameters={"tags": {"str": "str"}}, + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_disable_soft_delete_requests_objects(self, resource_group): + response = self.client.resource_guards.get_disable_soft_delete_requests_objects( + resource_group_name=resource_group.name, + resource_guards_name="str", + api_version="2024-04-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_get_delete_resource_guard_proxy_requests_objects(self, resource_group): + response = self.client.resource_guards.get_delete_resource_guard_proxy_requests_objects( + resource_group_name=resource_group.name, + resource_guards_name="str", + api_version="2024-04-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_get_backup_security_pin_requests_objects(self, resource_group): + response = self.client.resource_guards.get_backup_security_pin_requests_objects( + resource_group_name=resource_group.name, + resource_guards_name="str", + api_version="2024-04-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_get_delete_protected_item_requests_objects(self, resource_group): + response = self.client.resource_guards.get_delete_protected_item_requests_objects( + resource_group_name=resource_group.name, + resource_guards_name="str", + api_version="2024-04-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_get_update_protection_policy_requests_objects(self, resource_group): + response = self.client.resource_guards.get_update_protection_policy_requests_objects( + resource_group_name=resource_group.name, + resource_guards_name="str", + api_version="2024-04-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_get_update_protected_item_requests_objects(self, resource_group): + response = self.client.resource_guards.get_update_protected_item_requests_objects( + resource_group_name=resource_group.name, + resource_guards_name="str", + api_version="2024-04-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_get_default_disable_soft_delete_requests_object(self, resource_group): + response = await self.client.resource_guards.get_default_disable_soft_delete_requests_object( + resource_group_name=resource_group.name, + resource_guards_name="str", + request_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_default_delete_resource_guard_proxy_requests_object(self, resource_group): + response = await self.client.resource_guards.get_default_delete_resource_guard_proxy_requests_object( + resource_group_name=resource_group.name, + resource_guards_name="str", + request_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_default_backup_security_pin_requests_object(self, resource_group): + response = await self.client.resource_guards.get_default_backup_security_pin_requests_object( + resource_group_name=resource_group.name, + resource_guards_name="str", + request_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_default_delete_protected_item_requests_object(self, resource_group): + response = await self.client.resource_guards.get_default_delete_protected_item_requests_object( + resource_group_name=resource_group.name, + resource_guards_name="str", + request_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_default_update_protection_policy_requests_object(self, resource_group): + response = await self.client.resource_guards.get_default_update_protection_policy_requests_object( + resource_group_name=resource_group.name, + resource_guards_name="str", + request_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_default_update_protected_item_requests_object(self, resource_group): + response = await self.client.resource_guards.get_default_update_protected_item_requests_object( + resource_group_name=resource_group.name, + resource_guards_name="str", + request_name="str", + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_restorable_time_ranges_operations.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_restorable_time_ranges_operations.py new file mode 100644 index 000000000000..7a92f789b444 --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_restorable_time_ranges_operations.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection import DataProtectionMgmtClient + +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 TestDataProtectionMgmtRestorableTimeRangesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_find(self, resource_group): + response = self.client.restorable_time_ranges.find( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + parameters={"sourceDataStoreType": "str", "endTime": "str", "startTime": "str"}, + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_restorable_time_ranges_operations_async.py b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_restorable_time_ranges_operations_async.py new file mode 100644 index 000000000000..6b92ef37abff --- /dev/null +++ b/sdk/dataprotection/azure-mgmt-dataprotection/generated_tests/test_data_protection_mgmt_restorable_time_ranges_operations_async.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.dataprotection.aio import DataProtectionMgmtClient + +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 TestDataProtectionMgmtRestorableTimeRangesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(DataProtectionMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_find(self, resource_group): + response = await self.client.restorable_time_ranges.find( + resource_group_name=resource_group.name, + vault_name="str", + backup_instance_name="str", + parameters={"sourceDataStoreType": "str", "endTime": "str", "startTime": "str"}, + api_version="2024-04-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/dataprotection/azure-mgmt-dataprotection/setup.py b/sdk/dataprotection/azure-mgmt-dataprotection/setup.py index 1dcaa2bd590d..2e6612624983 100644 --- a/sdk/dataprotection/azure-mgmt-dataprotection/setup.py +++ b/sdk/dataprotection/azure-mgmt-dataprotection/setup.py @@ -53,11 +53,11 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -74,10 +74,10 @@ "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7", + python_requires=">=3.8", )