diff --git a/sdk/netapp/azure-mgmt-netapp/_meta.json b/sdk/netapp/azure-mgmt-netapp/_meta.json index 2a7696d3ad4d..5d8529ab4e3e 100644 --- a/sdk/netapp/azure-mgmt-netapp/_meta.json +++ b/sdk/netapp/azure-mgmt-netapp/_meta.json @@ -1,11 +1,11 @@ { - "commit": "4f093ebabe4525a5d10ca57e5804523a27dce7bf", + "commit": "dbbc230a7fb55d687985dca8ce40540d4f232fa8", "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.13.16", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/netapp/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/netapp/resource-manager/readme.md --generate-sample=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.13.16 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/netapp/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_configuration.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_configuration.py index 2c9da59a4b4c..f77e3a43f775 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_configuration.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_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 NetAppManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class NetAppManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for NetAppManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class NetAppManagementClientConfiguration(Configuration): # pylint: disable=too :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-07-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-11-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(NetAppManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-07-01") + api_version: str = kwargs.pop("api_version", "2023-11-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-netapp/{}".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/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_net_app_management_client.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_net_app_management_client.py index 680cd019a03a..1a372274fd09 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_net_app_management_client.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_net_app_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +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 NetAppManagementClientConfiguration @@ -18,9 +20,14 @@ from .operations import ( AccountsOperations, BackupPoliciesOperations, + BackupVaultsOperations, BackupsOperations, + BackupsUnderAccountOperations, + BackupsUnderBackupVaultOperations, + BackupsUnderVolumeOperations, NetAppResourceOperations, NetAppResourceQuotaLimitsOperations, + NetAppResourceRegionInfosOperations, Operations, PoolsOperations, SnapshotPoliciesOperations, @@ -46,6 +53,9 @@ class NetAppManagementClient: # pylint: disable=client-accepts-api-version-keyw :ivar net_app_resource_quota_limits: NetAppResourceQuotaLimitsOperations operations :vartype net_app_resource_quota_limits: azure.mgmt.netapp.operations.NetAppResourceQuotaLimitsOperations + :ivar net_app_resource_region_infos: NetAppResourceRegionInfosOperations operations + :vartype net_app_resource_region_infos: + azure.mgmt.netapp.operations.NetAppResourceRegionInfosOperations :ivar accounts: AccountsOperations operations :vartype accounts: azure.mgmt.netapp.operations.AccountsOperations :ivar pools: PoolsOperations operations @@ -56,8 +66,6 @@ class NetAppManagementClient: # pylint: disable=client-accepts-api-version-keyw :vartype snapshots: azure.mgmt.netapp.operations.SnapshotsOperations :ivar snapshot_policies: SnapshotPoliciesOperations operations :vartype snapshot_policies: azure.mgmt.netapp.operations.SnapshotPoliciesOperations - :ivar backups: BackupsOperations operations - :vartype backups: azure.mgmt.netapp.operations.BackupsOperations :ivar backup_policies: BackupPoliciesOperations operations :vartype backup_policies: azure.mgmt.netapp.operations.BackupPoliciesOperations :ivar volume_quota_rules: VolumeQuotaRulesOperations operations @@ -66,14 +74,25 @@ class NetAppManagementClient: # pylint: disable=client-accepts-api-version-keyw :vartype volume_groups: azure.mgmt.netapp.operations.VolumeGroupsOperations :ivar subvolumes: SubvolumesOperations operations :vartype subvolumes: azure.mgmt.netapp.operations.SubvolumesOperations + :ivar backups: BackupsOperations operations + :vartype backups: azure.mgmt.netapp.operations.BackupsOperations + :ivar backup_vaults: BackupVaultsOperations operations + :vartype backup_vaults: azure.mgmt.netapp.operations.BackupVaultsOperations + :ivar backups_under_backup_vault: BackupsUnderBackupVaultOperations operations + :vartype backups_under_backup_vault: + azure.mgmt.netapp.operations.BackupsUnderBackupVaultOperations + :ivar backups_under_volume: BackupsUnderVolumeOperations operations + :vartype backups_under_volume: azure.mgmt.netapp.operations.BackupsUnderVolumeOperations + :ivar backups_under_account: BackupsUnderAccountOperations operations + :vartype backups_under_account: azure.mgmt.netapp.operations.BackupsUnderAccountOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :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-07-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-11-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -89,7 +108,25 @@ def __init__( self._config = NetAppManagementClientConfiguration( 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) @@ -100,6 +137,9 @@ def __init__( self.net_app_resource_quota_limits = NetAppResourceQuotaLimitsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.net_app_resource_region_infos = NetAppResourceRegionInfosOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.accounts = AccountsOperations(self._client, self._config, self._serialize, self._deserialize) self.pools = PoolsOperations(self._client, self._config, self._serialize, self._deserialize) self.volumes = VolumesOperations(self._client, self._config, self._serialize, self._deserialize) @@ -107,15 +147,25 @@ def __init__( self.snapshot_policies = SnapshotPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.backups = BackupsOperations(self._client, self._config, self._serialize, self._deserialize) self.backup_policies = BackupPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) self.volume_quota_rules = VolumeQuotaRulesOperations( self._client, self._config, self._serialize, self._deserialize ) self.volume_groups = VolumeGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.subvolumes = SubvolumesOperations(self._client, self._config, self._serialize, self._deserialize) + self.backups = BackupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.backup_vaults = BackupVaultsOperations(self._client, self._config, self._serialize, self._deserialize) + self.backups_under_backup_vault = BackupsUnderBackupVaultOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.backups_under_volume = BackupsUnderVolumeOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.backups_under_account = BackupsUnderAccountOperations( + 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 @@ -135,7 +185,7 @@ 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() diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_patch.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_patch.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_serialization.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_serialization.py index 4bae2292227b..2f781d740827 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_serialization.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_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,7 @@ 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 raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -170,13 +170,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 +288,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 +333,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 +344,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 +383,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 +408,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 +438,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 +538,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 +554,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 +642,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 +661,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 +703,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 +723,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 +738,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 +747,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 +798,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 +818,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 +987,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 +1164,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 +1203,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 +1223,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 +1363,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 +1383,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,7 +1436,7 @@ 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) @@ -1481,7 +1473,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 +1507,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 +1570,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 +1644,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 +1692,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 +1749,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 +1800,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 +1853,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 +1884,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 +1901,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 +1936,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 +1973,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 +1989,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/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_version.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_version.py index c047f879b92f..e786ca9d2565 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_version.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "12.0.0" +VERSION = "5.1.0" diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/_configuration.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/_configuration.py index 3f3e66d7b7e2..48fe3c10ab1b 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/_configuration.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/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 NetAppManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class NetAppManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for NetAppManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class NetAppManagementClientConfiguration(Configuration): # pylint: disable=too :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-07-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-11-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(NetAppManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-07-01") + api_version: str = kwargs.pop("api_version", "2023-11-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-netapp/{}".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/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/_net_app_management_client.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/_net_app_management_client.py index 557cb42f8882..f781babe5b14 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/_net_app_management_client.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/_net_app_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +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 @@ -18,9 +20,14 @@ from .operations import ( AccountsOperations, BackupPoliciesOperations, + BackupVaultsOperations, BackupsOperations, + BackupsUnderAccountOperations, + BackupsUnderBackupVaultOperations, + BackupsUnderVolumeOperations, NetAppResourceOperations, NetAppResourceQuotaLimitsOperations, + NetAppResourceRegionInfosOperations, Operations, PoolsOperations, SnapshotPoliciesOperations, @@ -46,6 +53,9 @@ class NetAppManagementClient: # pylint: disable=client-accepts-api-version-keyw :ivar net_app_resource_quota_limits: NetAppResourceQuotaLimitsOperations operations :vartype net_app_resource_quota_limits: azure.mgmt.netapp.aio.operations.NetAppResourceQuotaLimitsOperations + :ivar net_app_resource_region_infos: NetAppResourceRegionInfosOperations operations + :vartype net_app_resource_region_infos: + azure.mgmt.netapp.aio.operations.NetAppResourceRegionInfosOperations :ivar accounts: AccountsOperations operations :vartype accounts: azure.mgmt.netapp.aio.operations.AccountsOperations :ivar pools: PoolsOperations operations @@ -56,8 +66,6 @@ class NetAppManagementClient: # pylint: disable=client-accepts-api-version-keyw :vartype snapshots: azure.mgmt.netapp.aio.operations.SnapshotsOperations :ivar snapshot_policies: SnapshotPoliciesOperations operations :vartype snapshot_policies: azure.mgmt.netapp.aio.operations.SnapshotPoliciesOperations - :ivar backups: BackupsOperations operations - :vartype backups: azure.mgmt.netapp.aio.operations.BackupsOperations :ivar backup_policies: BackupPoliciesOperations operations :vartype backup_policies: azure.mgmt.netapp.aio.operations.BackupPoliciesOperations :ivar volume_quota_rules: VolumeQuotaRulesOperations operations @@ -66,14 +74,25 @@ class NetAppManagementClient: # pylint: disable=client-accepts-api-version-keyw :vartype volume_groups: azure.mgmt.netapp.aio.operations.VolumeGroupsOperations :ivar subvolumes: SubvolumesOperations operations :vartype subvolumes: azure.mgmt.netapp.aio.operations.SubvolumesOperations + :ivar backups: BackupsOperations operations + :vartype backups: azure.mgmt.netapp.aio.operations.BackupsOperations + :ivar backup_vaults: BackupVaultsOperations operations + :vartype backup_vaults: azure.mgmt.netapp.aio.operations.BackupVaultsOperations + :ivar backups_under_backup_vault: BackupsUnderBackupVaultOperations operations + :vartype backups_under_backup_vault: + azure.mgmt.netapp.aio.operations.BackupsUnderBackupVaultOperations + :ivar backups_under_volume: BackupsUnderVolumeOperations operations + :vartype backups_under_volume: azure.mgmt.netapp.aio.operations.BackupsUnderVolumeOperations + :ivar backups_under_account: BackupsUnderAccountOperations operations + :vartype backups_under_account: azure.mgmt.netapp.aio.operations.BackupsUnderAccountOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :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-07-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-11-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -89,7 +108,25 @@ def __init__( self._config = NetAppManagementClientConfiguration( 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) @@ -100,6 +137,9 @@ def __init__( self.net_app_resource_quota_limits = NetAppResourceQuotaLimitsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.net_app_resource_region_infos = NetAppResourceRegionInfosOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.accounts = AccountsOperations(self._client, self._config, self._serialize, self._deserialize) self.pools = PoolsOperations(self._client, self._config, self._serialize, self._deserialize) self.volumes = VolumesOperations(self._client, self._config, self._serialize, self._deserialize) @@ -107,15 +147,27 @@ def __init__( self.snapshot_policies = SnapshotPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.backups = BackupsOperations(self._client, self._config, self._serialize, self._deserialize) self.backup_policies = BackupPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) self.volume_quota_rules = VolumeQuotaRulesOperations( self._client, self._config, self._serialize, self._deserialize ) self.volume_groups = VolumeGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.subvolumes = SubvolumesOperations(self._client, self._config, self._serialize, self._deserialize) + self.backups = BackupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.backup_vaults = BackupVaultsOperations(self._client, self._config, self._serialize, self._deserialize) + self.backups_under_backup_vault = BackupsUnderBackupVaultOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.backups_under_volume = BackupsUnderVolumeOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.backups_under_account = BackupsUnderAccountOperations( + 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 @@ -135,7 +187,7 @@ 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() diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/_patch.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/_patch.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/__init__.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/__init__.py index 207ff3039ab7..96d2b3958ac5 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/__init__.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/__init__.py @@ -9,16 +9,21 @@ from ._operations import Operations from ._net_app_resource_operations import NetAppResourceOperations from ._net_app_resource_quota_limits_operations import NetAppResourceQuotaLimitsOperations +from ._net_app_resource_region_infos_operations import NetAppResourceRegionInfosOperations from ._accounts_operations import AccountsOperations from ._pools_operations import PoolsOperations from ._volumes_operations import VolumesOperations from ._snapshots_operations import SnapshotsOperations from ._snapshot_policies_operations import SnapshotPoliciesOperations -from ._backups_operations import BackupsOperations from ._backup_policies_operations import BackupPoliciesOperations from ._volume_quota_rules_operations import VolumeQuotaRulesOperations from ._volume_groups_operations import VolumeGroupsOperations from ._subvolumes_operations import SubvolumesOperations +from ._backups_operations import BackupsOperations +from ._backup_vaults_operations import BackupVaultsOperations +from ._backups_under_backup_vault_operations import BackupsUnderBackupVaultOperations +from ._backups_under_volume_operations import BackupsUnderVolumeOperations +from ._backups_under_account_operations import BackupsUnderAccountOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -28,16 +33,21 @@ "Operations", "NetAppResourceOperations", "NetAppResourceQuotaLimitsOperations", + "NetAppResourceRegionInfosOperations", "AccountsOperations", "PoolsOperations", "VolumesOperations", "SnapshotsOperations", "SnapshotPoliciesOperations", - "BackupsOperations", "BackupPoliciesOperations", "VolumeQuotaRulesOperations", "VolumeGroupsOperations", "SubvolumesOperations", + "BackupsOperations", + "BackupVaultsOperations", + "BackupsUnderBackupVaultOperations", + "BackupsUnderVolumeOperations", + "BackupsUnderAccountOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_accounts_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_accounts_operations.py index 2a17f9e354c2..8ca3c466e4eb 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_accounts_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_accounts_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, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -32,15 +33,22 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._accounts_operations import ( + build_change_key_vault_request, build_create_or_update_request, build_delete_request, + build_get_change_key_vault_information_request, build_get_request, build_list_by_subscription_request, build_list_request, + build_migrate_encryption_key_request, build_renew_credentials_request, build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,7 +78,6 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.NetAppAc List and describe all NetApp accounts in the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either NetAppAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.netapp.models.NetAppAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -81,7 +88,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.NetAppAc api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NetAppAccountList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -92,15 +99,14 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.NetAppAc def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -112,13 +118,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("NetAppAccountList", pipeline_response) @@ -128,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 @@ -145,8 +151,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/netAppAccounts"} - @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.NetAppAccount"]: """Describe all NetApp Accounts in a resource group. @@ -156,7 +160,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model :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 NetAppAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.netapp.models.NetAppAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -167,7 +170,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NetAppAccountList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -178,16 +181,15 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -199,13 +201,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("NetAppAccountList", pipeline_response) @@ -215,11 +217,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 +234,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts" - } - @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.NetAppAccount: """Describe a NetApp Account. @@ -247,12 +245,11 @@ async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) :type resource_group_name: str :param account_name: The name of the NetApp account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NetAppAccount or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.NetAppAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -266,21 +263,20 @@ async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NetAppAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_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 = _convert_request(_request) + _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 @@ -293,18 +289,14 @@ async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) deserialized = self._deserialize("NetAppAccount", pipeline_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.NetApp/netAppAccounts/{accountName}" - } + return deserialized # type: ignore async def _create_or_update_initial( - self, resource_group_name: str, account_name: str, body: Union[_models.NetAppAccount, IO], **kwargs: Any + self, resource_group_name: str, account_name: str, body: Union[_models.NetAppAccount, IO[bytes]], **kwargs: Any ) -> _models.NetAppAccount: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -327,7 +319,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(body, "NetAppAccount") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -335,16 +327,15 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -365,10 +356,6 @@ async def _create_or_update_initial( return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}" - } - @overload async def begin_create_or_update( self, @@ -393,14 +380,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either NetAppAccount or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.NetAppAccount] @@ -412,7 +391,7 @@ async def begin_create_or_update( self, resource_group_name: str, account_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -427,18 +406,10 @@ async def begin_create_or_update( :param account_name: The name of the NetApp account. Required. :type account_name: str :param body: NetApp Account object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 NetAppAccount or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.NetAppAccount] @@ -447,7 +418,7 @@ async def begin_create_or_update( @distributed_trace_async async def begin_create_or_update( - self, resource_group_name: str, account_name: str, body: Union[_models.NetAppAccount, IO], **kwargs: Any + self, resource_group_name: str, account_name: str, body: Union[_models.NetAppAccount, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.NetAppAccount]: """Create or update a NetApp account. @@ -459,19 +430,8 @@ async def begin_create_or_update( :param account_name: The name of the NetApp account. Required. :type account_name: str :param body: NetApp Account object supplied in the body of the operation. Is either a - NetAppAccount type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.NetAppAccount 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. + NetAppAccount type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.NetAppAccount or IO[bytes] :return: An instance of AsyncLROPoller that returns either NetAppAccount or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.NetAppAccount] @@ -503,7 +463,7 @@ async def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("NetAppAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -516,22 +476,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.NetAppAccount].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.NetApp/netAppAccounts/{accountName}" - } + return AsyncLROPoller[_models.NetAppAccount]( + 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, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -545,21 +503,20 @@ async def _delete_initial( # 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, account_name=account_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 = _convert_request(_request) + _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 @@ -570,11 +527,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -587,14 +540,6 @@ async def begin_delete(self, resource_group_name: str, account_name: str, **kwar :type resource_group_name: str :param account_name: The name of the NetApp account. Required. :type account_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: @@ -621,7 +566,7 @@ async def begin_delete(self, resource_group_name: str, account_name: str, **kwar 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( @@ -632,22 +577,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _update_initial( - self, resource_group_name: str, account_name: str, body: Union[_models.NetAppAccountPatch, IO], **kwargs: Any + self, + resource_group_name: str, + account_name: str, + body: Union[_models.NetAppAccountPatch, IO[bytes]], + **kwargs: Any ) -> _models.NetAppAccount: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -670,7 +615,7 @@ async def _update_initial( else: _json = self._serialize.body(body, "NetAppAccountPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -678,16 +623,15 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -708,10 +652,6 @@ async def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}" - } - @overload async def begin_update( self, @@ -736,14 +676,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either NetAppAccount or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.NetAppAccount] @@ -755,7 +687,7 @@ async def begin_update( self, resource_group_name: str, account_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -770,18 +702,10 @@ async def begin_update( :param account_name: The name of the NetApp account. Required. :type account_name: str :param body: NetApp Account object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 NetAppAccount or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.NetAppAccount] @@ -790,7 +714,11 @@ async def begin_update( @distributed_trace_async async def begin_update( - self, resource_group_name: str, account_name: str, body: Union[_models.NetAppAccountPatch, IO], **kwargs: Any + self, + resource_group_name: str, + account_name: str, + body: Union[_models.NetAppAccountPatch, IO[bytes]], + **kwargs: Any ) -> AsyncLROPoller[_models.NetAppAccount]: """Update a NetApp account. @@ -802,19 +730,8 @@ async def begin_update( :param account_name: The name of the NetApp account. Required. :type account_name: str :param body: NetApp Account object supplied in the body of the operation. Is either a - NetAppAccountPatch type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.NetAppAccountPatch 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. + NetAppAccountPatch type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.NetAppAccountPatch or IO[bytes] :return: An instance of AsyncLROPoller that returns either NetAppAccount or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.NetAppAccount] @@ -846,7 +763,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("NetAppAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -858,22 +775,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.NetAppAccount].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.NetApp/netAppAccounts/{accountName}" - } + return AsyncLROPoller[_models.NetAppAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _renew_credentials_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -887,21 +802,20 @@ async def _renew_credentials_initial( # pylint: disable=inconsistent-return-sta api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_renew_credentials_request( + _request = build_renew_credentials_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._renew_credentials_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -912,11 +826,7 @@ async def _renew_credentials_initial( # pylint: disable=inconsistent-return-sta raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _renew_credentials_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/renewCredentials" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_renew_credentials( @@ -933,14 +843,6 @@ async def begin_renew_credentials( :type resource_group_name: str :param account_name: The name of the NetApp account. Required. :type account_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: @@ -967,7 +869,7 @@ async def begin_renew_credentials( 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( @@ -979,14 +881,510 @@ 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_renew_credentials.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/renewCredentials" - } + async def _migrate_encryption_key_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + body: Optional[Union[_models.EncryptionMigrationRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "EncryptionMigrationRequest") + else: + _json = None + + _request = build_migrate_encryption_key_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @overload + async def begin_migrate_encryption_key( + self, + resource_group_name: str, + account_name: str, + body: Optional[_models.EncryptionMigrationRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Migrate volumes encryption key source. + + Migrates all volumes in a VNet to a different encryption key source (Microsoft-managed key or + Azure Key Vault). Operation fails if targeted volumes share encryption sibling set with volumes + from another account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: The required parameters to perform encryption migration. Default value is None. + :type body: ~azure.mgmt.netapp.models.EncryptionMigrationRequest + :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_migrate_encryption_key( + self, + resource_group_name: str, + account_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Migrate volumes encryption key source. + + Migrates all volumes in a VNet to a different encryption key source (Microsoft-managed key or + Azure Key Vault). Operation fails if targeted volumes share encryption sibling set with volumes + from another account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: The required parameters to perform encryption migration. Default value is None. + :type body: 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_migrate_encryption_key( + self, + resource_group_name: str, + account_name: str, + body: Optional[Union[_models.EncryptionMigrationRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Migrate volumes encryption key source. + + Migrates all volumes in a VNet to a different encryption key source (Microsoft-managed key or + Azure Key Vault). Operation fails if targeted volumes share encryption sibling set with volumes + from another account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: The required parameters to perform encryption migration. Is either a + EncryptionMigrationRequest type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.netapp.models.EncryptionMigrationRequest 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 = 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._migrate_encryption_key_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _get_change_key_vault_information_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Optional[_models.ChangeKeyVault]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ChangeKeyVault]] = kwargs.pop("cls", None) + + _request = build_get_change_key_vault_information_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ChangeKeyVault", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_get_change_key_vault_information( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ChangeKeyVault]: + """Get information about how volumes under NetApp account are encrypted. + + Contains data from encryption.keyVaultProperties as well as information about which private + endpoint is used by each encryption sibling set. Response from this endpoint can be modified + and used as request body for POST request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :return: An instance of AsyncLROPoller that returns either ChangeKeyVault or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.ChangeKeyVault] + :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.ChangeKeyVault] = 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._get_change_key_vault_information_initial( + resource_group_name=resource_group_name, + account_name=account_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ChangeKeyVault", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ChangeKeyVault].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ChangeKeyVault]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _change_key_vault_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + body: Optional[Union[_models.ChangeKeyVault, IO[bytes]]] = None, + **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "ChangeKeyVault") + else: + _json = None + + _request = build_change_key_vault_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def begin_change_key_vault( + self, + resource_group_name: str, + account_name: str, + body: Optional[_models.ChangeKeyVault] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Change Key Vault/Managed HSM that is used for encryption of volumes under NetApp account. + + Affects existing volumes that are encrypted with Key Vault/Managed HSM, and new volumes. + Supports MHSM to Key Vault, Key Vault to MHSM, MHSM to MHSM and Key Vault to Key Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: The required parameters to perform encryption migration. Default value is None. + :type body: ~azure.mgmt.netapp.models.ChangeKeyVault + :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_change_key_vault( + self, + resource_group_name: str, + account_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Change Key Vault/Managed HSM that is used for encryption of volumes under NetApp account. + + Affects existing volumes that are encrypted with Key Vault/Managed HSM, and new volumes. + Supports MHSM to Key Vault, Key Vault to MHSM, MHSM to MHSM and Key Vault to Key Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: The required parameters to perform encryption migration. Default value is None. + :type body: 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_change_key_vault( + self, + resource_group_name: str, + account_name: str, + body: Optional[Union[_models.ChangeKeyVault, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Change Key Vault/Managed HSM that is used for encryption of volumes under NetApp account. + + Affects existing volumes that are encrypted with Key Vault/Managed HSM, and new volumes. + Supports MHSM to Key Vault, Key Vault to MHSM, MHSM to MHSM and Key Vault to Key Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: The required parameters to perform encryption migration. Is either a + ChangeKeyVault type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.netapp.models.ChangeKeyVault 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 = 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._change_key_vault_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backup_policies_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backup_policies_operations.py index b333bf2757cb..2a0d41349200 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backup_policies_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/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, cast, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,6 +40,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +78,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As :type resource_group_name: str :param account_name: The name of the NetApp account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BackupPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.netapp.models.BackupPolicy] :raises ~azure.core.exceptions.HttpResponseError: @@ -84,7 +88,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackupPoliciesList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,17 +99,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -117,13 +120,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BackupPoliciesList", pipeline_response) @@ -133,11 +136,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupPolicies" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, backup_policy_name: str, **kwargs: Any @@ -169,12 +168,11 @@ async def get( :type account_name: str :param backup_policy_name: Backup policy Name which uniquely identify backup policy. Required. :type backup_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BackupPolicy or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.BackupPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,22 +186,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackupPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_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 = _convert_request(_request) + _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 @@ -216,23 +213,19 @@ async def get( deserialized = self._deserialize("BackupPolicy", pipeline_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.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, backup_policy_name: str, - body: Union[_models.BackupPolicy, IO], + body: Union[_models.BackupPolicy, IO[bytes]], **kwargs: Any ) -> Optional[_models.BackupPolicy]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +248,7 @@ async def _create_initial( else: _json = self._serialize.body(body, "BackupPolicy") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, backup_policy_name=backup_policy_name, @@ -264,16 +257,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -291,13 +283,9 @@ async def _create_initial( deserialized = self._deserialize("BackupPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -326,14 +314,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either BackupPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.BackupPolicy] @@ -346,7 +326,7 @@ async def begin_create( resource_group_name: str, account_name: str, backup_policy_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -363,18 +343,10 @@ async def begin_create( :param backup_policy_name: Backup policy Name which uniquely identify backup policy. Required. :type backup_policy_name: str :param body: Backup policy object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 BackupPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.BackupPolicy] @@ -387,7 +359,7 @@ async def begin_create( resource_group_name: str, account_name: str, backup_policy_name: str, - body: Union[_models.BackupPolicy, IO], + body: Union[_models.BackupPolicy, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.BackupPolicy]: """Create a backup policy. @@ -402,19 +374,8 @@ async def begin_create( :param backup_policy_name: Backup policy Name which uniquely identify backup policy. Required. :type backup_policy_name: str :param body: Backup policy object supplied in the body of the operation. Is either a - BackupPolicy type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.BackupPolicy 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. + BackupPolicy type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.BackupPolicy or IO[bytes] :return: An instance of AsyncLROPoller that returns either BackupPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.BackupPolicy] @@ -447,7 +408,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BackupPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -460,27 +421,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BackupPolicy].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}" - } + return AsyncLROPoller[_models.BackupPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, account_name: str, backup_policy_name: str, - body: Union[_models.BackupPolicyPatch, IO], + body: Union[_models.BackupPolicyPatch, IO[bytes]], **kwargs: Any ) -> _models.BackupPolicy: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -503,7 +462,7 @@ async def _update_initial( else: _json = self._serialize.body(body, "BackupPolicyPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, backup_policy_name=backup_policy_name, @@ -512,16 +471,15 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -542,10 +500,6 @@ async def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}" - } - @overload async def begin_update( self, @@ -573,14 +527,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either BackupPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.BackupPolicy] @@ -593,7 +539,7 @@ async def begin_update( resource_group_name: str, account_name: str, backup_policy_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -610,18 +556,10 @@ async def begin_update( :param backup_policy_name: Backup policy Name which uniquely identify backup policy. Required. :type backup_policy_name: str :param body: Backup policy object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 BackupPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.BackupPolicy] @@ -634,7 +572,7 @@ async def begin_update( resource_group_name: str, account_name: str, backup_policy_name: str, - body: Union[_models.BackupPolicyPatch, IO], + body: Union[_models.BackupPolicyPatch, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.BackupPolicy]: """Patch a backup policy. @@ -649,19 +587,8 @@ async def begin_update( :param backup_policy_name: Backup policy Name which uniquely identify backup policy. Required. :type backup_policy_name: str :param body: Backup policy object supplied in the body of the operation. Is either a - BackupPolicyPatch type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.BackupPolicyPatch 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. + BackupPolicyPatch type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.BackupPolicyPatch or IO[bytes] :return: An instance of AsyncLROPoller that returns either BackupPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.BackupPolicy] @@ -694,7 +621,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BackupPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -707,22 +634,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BackupPolicy].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.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}" - } + return AsyncLROPoller[_models.BackupPolicy]( + 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, account_name: str, backup_policy_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -736,22 +661,21 @@ async def _delete_initial( # 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, account_name=account_name, backup_policy_name=backup_policy_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 = _convert_request(_request) + _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 @@ -762,11 +686,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_delete( @@ -783,14 +703,6 @@ async def begin_delete( :type account_name: str :param backup_policy_name: Backup policy Name which uniquely identify backup policy. Required. :type backup_policy_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: @@ -818,7 +730,7 @@ async def begin_delete( 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( @@ -829,14 +741,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backup_vaults_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backup_vaults_operations.py new file mode 100644 index 000000000000..d841db1a5afd --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backup_vaults_operations.py @@ -0,0 +1,757 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._backup_vaults_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_net_app_account_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BackupVaultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.netapp.aio.NetAppManagementClient`'s + :attr:`backup_vaults` 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_by_net_app_account( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BackupVault"]: + """Describe all Backup Vaults. + + List and describe all Backup Vaults in the NetApp account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :return: An iterator like instance of either BackupVault or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.netapp.models.BackupVault] + :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.BackupVaultsList] = 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_by_net_app_account_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BackupVaultsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, backup_vault_name: str, **kwargs: Any + ) -> _models.BackupVault: + """Describe the Backup Vault. + + Get the Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :return: BackupVault or the result of cls(response) + :rtype: ~azure.mgmt.netapp.models.BackupVault + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BackupVault] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BackupVault", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + body: Union[_models.BackupVault, IO[bytes]], + **kwargs: Any + ) -> _models.BackupVault: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackupVault] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "BackupVault") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BackupVault", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BackupVault", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + body: _models.BackupVault, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupVault]: + """Create or Update a Backup Vault. + + Create or update the specified Backup Vault in the NetApp account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param body: BackupVault object supplied in the body of the operation. Required. + :type body: ~azure.mgmt.netapp.models.BackupVault + :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 BackupVault or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.BackupVault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupVault]: + """Create or Update a Backup Vault. + + Create or update the specified Backup Vault in the NetApp account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param body: BackupVault object supplied in the body of the operation. Required. + :type body: 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 BackupVault or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.BackupVault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + body: Union[_models.BackupVault, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupVault]: + """Create or Update a Backup Vault. + + Create or update the specified Backup Vault in the NetApp account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param body: BackupVault object supplied in the body of the operation. Is either a BackupVault + type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.BackupVault or IO[bytes] + :return: An instance of AsyncLROPoller that returns either BackupVault or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.BackupVault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackupVault] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("BackupVault", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.BackupVault].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.BackupVault]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + body: Union[_models.BackupVaultPatch, IO[bytes]], + **kwargs: Any + ) -> _models.BackupVault: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackupVault] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "BackupVaultPatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("BackupVault", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("BackupVault", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + body: _models.BackupVaultPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupVault]: + """Update NetApp Backup Vault. + + Patch the specified NetApp Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param body: Backup Vault object supplied in the body of the operation. Required. + :type body: ~azure.mgmt.netapp.models.BackupVaultPatch + :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 BackupVault or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.BackupVault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupVault]: + """Update NetApp Backup Vault. + + Patch the specified NetApp Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param body: Backup Vault object supplied in the body of the operation. Required. + :type body: 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 BackupVault or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.BackupVault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + body: Union[_models.BackupVaultPatch, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupVault]: + """Update NetApp Backup Vault. + + Patch the specified NetApp Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param body: Backup Vault object supplied in the body of the operation. Is either a + BackupVaultPatch type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.BackupVaultPatch or IO[bytes] + :return: An instance of AsyncLROPoller that returns either BackupVault or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.BackupVault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackupVault] = 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._update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("BackupVault", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.BackupVault].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.BackupVault]( + 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, account_name: str, backup_vault_name: str, **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, account_name: str, backup_vault_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete NetApp Backup Vault. + + Delete the specified Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: 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: + """ + _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[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._delete_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backups_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backups_operations.py index 04ab5dbaac8a..f46fa9abbb59 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backups_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backups_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,8 +6,12 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +from io import IOBase +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse +from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,15 +22,30 @@ ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._backups_operations import build_get_volume_restore_status_request +from ...operations._backups_operations import ( + build_create_request, + build_delete_request, + build_get_latest_status_request, + build_get_request, + build_get_volume_latest_restore_status_request, + build_list_by_vault_request, + build_update_request, +) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -51,12 +70,79 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get_volume_restore_status( + async def get_latest_status( + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any + ) -> _models.BackupStatus: + """Get the latest backup status of a volume. + + Get the latest status of the backup for a volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: str + :return: BackupStatus or the result of cls(response) + :rtype: ~azure.mgmt.netapp.models.BackupStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BackupStatus] = kwargs.pop("cls", None) + + _request = build_get_latest_status_request( + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BackupStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_volume_latest_restore_status( self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any ) -> _models.RestoreStatus: - """Get volume's restore status. + """Get the latest restore status of a volume. - Get the status of the restore for a volume. + Get the latest status of the restore for a volume. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -67,12 +153,11 @@ async def get_volume_restore_status( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RestoreStatus or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.RestoreStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,23 +171,22 @@ async def get_volume_restore_status( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RestoreStatus] = kwargs.pop("cls", None) - request = build_get_volume_restore_status_request( + _request = build_get_volume_latest_restore_status_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_volume_restore_status.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -115,10 +199,741 @@ async def get_volume_restore_status( deserialized = self._deserialize("RestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_vault( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.Backup"]: + """List Backups. + + List all backups Under a Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param filter: An option to specify the VolumeResourceId. If present, then only returns the + backups under the specified volume. Default value is None. + :type filter: str + :return: An iterator like instance of either Backup or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.netapp.models.Backup] + :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.BackupsList] = 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_by_vault_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BackupsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, backup_vault_name: str, backup_name: str, **kwargs: Any + ) -> _models.Backup: + """Describe the Backup under Backup Vault. + + Get the specified Backup under Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :return: Backup or the result of cls(response) + :rtype: ~azure.mgmt.netapp.models.Backup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Backup] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Backup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: Union[_models.Backup, IO[bytes]], + **kwargs: Any + ) -> _models.Backup: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Backup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "Backup") + + _request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Backup", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Backup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: _models.Backup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Backup]: + """Create a backup. + + Create a backup under the Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Backup object supplied in the body of the operation. Required. + :type body: ~azure.mgmt.netapp.models.Backup + :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 Backup or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Backup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Backup]: + """Create a backup. + + Create a backup under the Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Backup object supplied in the body of the operation. Required. + :type body: 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 Backup or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Backup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: Union[_models.Backup, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Backup]: + """Create a backup. + + Create a backup under the Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Backup object supplied in the body of the operation. Is either a Backup type or a + IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.Backup or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Backup or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Backup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Backup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Backup", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Backup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Backup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: Optional[Union[_models.BackupPatch, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.Backup: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Backup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "BackupPatch") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Backup", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("Backup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: Optional[_models.BackupPatch] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Backup]: + """Patch a backup. + + Patch a Backup under the Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Backup object supplied in the body of the operation. Default value is None. + :type body: ~azure.mgmt.netapp.models.BackupPatch + :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 Backup or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Backup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Backup]: + """Patch a backup. + + Patch a Backup under the Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Backup object supplied in the body of the operation. Default value is None. + :type body: 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 Backup or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Backup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: Optional[Union[_models.BackupPatch, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.Backup]: + """Patch a backup. + + Patch a Backup under the Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Backup object supplied in the body of the operation. Is either a BackupPatch type + or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.netapp.models.BackupPatch or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Backup or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Backup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Backup] = 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._update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Backup", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Backup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Backup]( + 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, account_name: str, backup_vault_name: str, backup_name: str, **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, account_name: str, backup_vault_name: str, backup_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete backup. + + Delete a Backup under the Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: 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: + """ + _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[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._delete_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - return deserialized + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - get_volume_restore_status.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/restoreStatus" - } + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backups_under_account_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backups_under_account_operations.py new file mode 100644 index 000000000000..06ee3726030f --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backups_under_account_operations.py @@ -0,0 +1,249 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._backups_under_account_operations import build_migrate_backups_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 BackupsUnderAccountOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.netapp.aio.NetAppManagementClient`'s + :attr:`backups_under_account` 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") + + async def _migrate_backups_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + body: Union[_models.BackupsMigrationRequest, IO[bytes]], + **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "BackupsMigrationRequest") + + _request = build_migrate_backups_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @overload + async def begin_migrate_backups( + self, + resource_group_name: str, + account_name: str, + body: _models.BackupsMigrationRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a new migrate request for backups under account. + + Migrate the backups under a NetApp account to backup vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: Migrate backups under an account payload supplied in the body of the operation. + Required. + :type body: ~azure.mgmt.netapp.models.BackupsMigrationRequest + :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_migrate_backups( + self, + resource_group_name: str, + account_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a new migrate request for backups under account. + + Migrate the backups under a NetApp account to backup vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: Migrate backups under an account payload supplied in the body of the operation. + Required. + :type body: 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_migrate_backups( + self, + resource_group_name: str, + account_name: str, + body: Union[_models.BackupsMigrationRequest, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a new migrate request for backups under account. + + Migrate the backups under a NetApp account to backup vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: Migrate backups under an account payload supplied in the body of the operation. Is + either a BackupsMigrationRequest type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.BackupsMigrationRequest 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 = 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._migrate_backups_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backups_under_backup_vault_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backups_under_backup_vault_operations.py new file mode 100644 index 000000000000..48edca1de576 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backups_under_backup_vault_operations.py @@ -0,0 +1,271 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._backups_under_backup_vault_operations import build_restore_files_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 BackupsUnderBackupVaultOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.netapp.aio.NetAppManagementClient`'s + :attr:`backups_under_backup_vault` 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") + + async def _restore_files_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: Union[_models.BackupRestoreFiles, IO[bytes]], + **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "BackupRestoreFiles") + + _request = build_restore_files_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @overload + async def begin_restore_files( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: _models.BackupRestoreFiles, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a new Backup Restore Files request. + + Restore the specified files from the specified backup to the active filesystem. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Restore payload supplied in the body of the operation. Required. + :type body: ~azure.mgmt.netapp.models.BackupRestoreFiles + :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_restore_files( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a new Backup Restore Files request. + + Restore the specified files from the specified backup to the active filesystem. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Restore payload supplied in the body of the operation. Required. + :type body: 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_restore_files( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: Union[_models.BackupRestoreFiles, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a new Backup Restore Files request. + + Restore the specified files from the specified backup to the active filesystem. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Restore payload supplied in the body of the operation. Is either a + BackupRestoreFiles type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.BackupRestoreFiles 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 = 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._restore_files_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backups_under_volume_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backups_under_volume_operations.py new file mode 100644 index 000000000000..17993be12add --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_backups_under_volume_operations.py @@ -0,0 +1,273 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._backups_under_volume_operations import build_migrate_backups_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 BackupsUnderVolumeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.netapp.aio.NetAppManagementClient`'s + :attr:`backups_under_volume` 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") + + async def _migrate_backups_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: Union[_models.BackupsMigrationRequest, IO[bytes]], + **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "BackupsMigrationRequest") + + _request = build_migrate_backups_request( + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @overload + async def begin_migrate_backups( + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: _models.BackupsMigrationRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a new migrate request for backups under volume. + + Migrate the backups under volume to backup vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: str + :param body: Migrate backups under volume payload supplied in the body of the operation. + Required. + :type body: ~azure.mgmt.netapp.models.BackupsMigrationRequest + :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_migrate_backups( + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a new migrate request for backups under volume. + + Migrate the backups under volume to backup vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: str + :param body: Migrate backups under volume payload supplied in the body of the operation. + Required. + :type body: 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_migrate_backups( + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: Union[_models.BackupsMigrationRequest, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Create a new migrate request for backups under volume. + + Migrate the backups under volume to backup vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: str + :param body: Migrate backups under volume payload supplied in the body of the operation. Is + either a BackupsMigrationRequest type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.BackupsMigrationRequest 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 = 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._migrate_backups_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_net_app_resource_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_net_app_resource_operations.py index a3b76155bec6..75fb2893499e 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_net_app_resource_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_net_app_resource_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, Optional, Type, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -36,6 +37,10 @@ build_update_network_sibling_set_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,12 +88,11 @@ async def check_name_availability( :type type: str or ~azure.mgmt.netapp.models.CheckNameResourceTypes :param resource_group: Resource group name. Required. :type resource_group: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckAvailabilityResponse or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.CheckAvailabilityResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -106,22 +110,21 @@ async def check_name_availability( _body = _models.ResourceNameAvailabilityRequest(name=name, resource_group=resource_group, type=type) _json = self._serialize.body(_body, "ResourceNameAvailabilityRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - 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 = _convert_request(_request) + _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 @@ -134,17 +137,13 @@ async def check_name_availability( deserialized = self._deserialize("CheckAvailabilityResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace_async async def check_file_path_availability( - self, location: str, name: str, subnet_id: str, **kwargs: Any + self, location: str, name: str, subnet_id: str, availability_zone: Optional[str] = None, **kwargs: Any ) -> _models.CheckAvailabilityResponse: """Check file path availability. @@ -157,12 +156,15 @@ async def check_file_path_availability( :param subnet_id: The Azure Resource URI for a delegated subnet. Must have the delegation Microsoft.NetApp/volumes. Required. :type subnet_id: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param availability_zone: The Azure Resource logical availability zone which is used within + zone mapping lookup for the subscription and region. The lookup will retrieve the physical zone + where volume is placed. Default value is None. + :type availability_zone: str :return: CheckAvailabilityResponse or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.CheckAvailabilityResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -177,25 +179,24 @@ async def check_file_path_availability( content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) cls: ClsType[_models.CheckAvailabilityResponse] = kwargs.pop("cls", None) - _body = _models.FilePathAvailabilityRequest(name=name, subnet_id=subnet_id) + _body = _models.FilePathAvailabilityRequest(availability_zone=availability_zone, name=name, subnet_id=subnet_id) _json = self._serialize.body(_body, "FilePathAvailabilityRequest") - request = build_check_file_path_availability_request( + _request = build_check_file_path_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_file_path_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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,13 +209,9 @@ async def check_file_path_availability( deserialized = self._deserialize("CheckAvailabilityResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_file_path_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/checkFilePathAvailability" - } + return deserialized # type: ignore @distributed_trace_async async def check_quota_availability( @@ -240,12 +237,11 @@ async def check_quota_availability( :type type: str or ~azure.mgmt.netapp.models.CheckQuotaNameResourceTypes :param resource_group: Resource group name. Required. :type resource_group: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckAvailabilityResponse or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.CheckAvailabilityResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -263,22 +259,21 @@ async def check_quota_availability( _body = _models.QuotaAvailabilityRequest(name=name, resource_group=resource_group, type=type) _json = self._serialize.body(_body, "QuotaAvailabilityRequest") - request = build_check_quota_availability_request( + _request = build_check_quota_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_quota_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -291,13 +286,9 @@ async def check_quota_availability( deserialized = self._deserialize("CheckAvailabilityResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - check_quota_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/checkQuotaAvailability" - } + return deserialized # type: ignore @distributed_trace_async async def query_region_info(self, location: str, **kwargs: Any) -> _models.RegionInfo: @@ -307,12 +298,11 @@ async def query_region_info(self, location: str, **kwargs: Any) -> _models.Regio :param location: The name of the Azure region. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RegionInfo or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.RegionInfo :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -326,20 +316,19 @@ async def query_region_info(self, location: str, **kwargs: Any) -> _models.Regio api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RegionInfo] = kwargs.pop("cls", None) - request = build_query_region_info_request( + _request = build_query_region_info_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.query_region_info.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -352,13 +341,9 @@ async def query_region_info(self, location: str, **kwargs: Any) -> _models.Regio deserialized = self._deserialize("RegionInfo", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - query_region_info.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/regionInfo" - } + return deserialized # type: ignore @distributed_trace_async async def query_network_sibling_set( @@ -378,12 +363,11 @@ async def query_network_sibling_set( /subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/{mySubnet}. Required. :type subnet_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NetworkSiblingSet or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.NetworkSiblingSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -403,22 +387,21 @@ async def query_network_sibling_set( ) _json = self._serialize.body(_body, "QueryNetworkSiblingSetRequest") - request = build_query_network_sibling_set_request( + _request = build_query_network_sibling_set_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.query_network_sibling_set.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -431,13 +414,9 @@ async def query_network_sibling_set( deserialized = self._deserialize("NetworkSiblingSet", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - query_network_sibling_set.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/queryNetworkSiblingSet" - } + return deserialized # type: ignore async def _update_network_sibling_set_initial( self, @@ -448,7 +427,7 @@ async def _update_network_sibling_set_initial( network_features: Union[str, _models.NetworkFeatures] = "Basic", **kwargs: Any ) -> Optional[_models.NetworkSiblingSet]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -471,22 +450,21 @@ async def _update_network_sibling_set_initial( ) _json = self._serialize.body(_body, "UpdateNetworkSiblingSetRequest") - request = build_update_network_sibling_set_request( + _request = build_update_network_sibling_set_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_network_sibling_set_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -505,13 +483,9 @@ async def _update_network_sibling_set_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_network_sibling_set_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/updateNetworkSiblingSet" - } + return deserialized # type: ignore @distributed_trace_async async def begin_update_network_sibling_set( @@ -540,17 +514,9 @@ async def begin_update_network_sibling_set( :param network_sibling_set_state_id: Network sibling set state Id identifying the current state of the sibling set. Required. :type network_sibling_set_state_id: str - :param network_features: Network features available to the volume, some such. Known values are: - "Basic", "Standard", "Basic_Standard", and "Standard_Basic". Default value is "Basic". + :param network_features: Network features available to the volume. Known values are: "Basic", + "Standard", "Basic_Standard", and "Standard_Basic". Default value is "Basic". :type network_features: str or ~azure.mgmt.netapp.models.NetworkFeatures - :keyword callable cls: A custom type or function that will be passed the direct response - :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 NetworkSiblingSet or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.NetworkSiblingSet] @@ -584,7 +550,7 @@ async def begin_update_network_sibling_set( def get_long_running_output(pipeline_response): deserialized = self._deserialize("NetworkSiblingSet", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -596,14 +562,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.NetworkSiblingSet].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_network_sibling_set.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/updateNetworkSiblingSet" - } + return AsyncLROPoller[_models.NetworkSiblingSet]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_net_app_resource_quota_limits_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_net_app_resource_quota_limits_operations.py index bb295f87c6c9..22f2a7df50ca 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_net_app_resource_quota_limits_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_net_app_resource_quota_limits_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 @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._net_app_resource_quota_limits_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]] @@ -61,7 +66,6 @@ def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Subscript :param location: The name of the Azure region. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SubscriptionQuotaItem or the result of cls(response) :rtype: @@ -74,7 +78,7 @@ def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Subscript api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubscriptionQuotaItemList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -85,16 +89,15 @@ def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Subscript def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -106,13 +109,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SubscriptionQuotaItemList", pipeline_response) @@ -122,11 +125,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -139,10 +142,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/quotaLimits" - } - @distributed_trace_async async def get(self, location: str, quota_limit_name: str, **kwargs: Any) -> _models.SubscriptionQuotaItem: """Get quota limits. @@ -153,12 +152,11 @@ async def get(self, location: str, quota_limit_name: str, **kwargs: Any) -> _mod :type location: str :param quota_limit_name: The name of the Quota Limit. Required. :type quota_limit_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionQuotaItem or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.SubscriptionQuotaItem :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -172,21 +170,20 @@ async def get(self, location: str, quota_limit_name: str, **kwargs: Any) -> _mod api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubscriptionQuotaItem] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( location=location, quota_limit_name=quota_limit_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 = _convert_request(_request) + _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 @@ -199,10 +196,6 @@ async def get(self, location: str, quota_limit_name: str, **kwargs: Any) -> _mod deserialized = self._deserialize("SubscriptionQuotaItem", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/quotaLimits/{quotaLimitName}" - } + return deserialized # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_net_app_resource_region_infos_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_net_app_resource_region_infos_operations.py new file mode 100644 index 000000000000..a9c61eaba1b8 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_net_app_resource_region_infos_operations.py @@ -0,0 +1,196 @@ +# 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.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._net_app_resource_region_infos_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]] + + +class NetAppResourceRegionInfosOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.netapp.aio.NetAppManagementClient`'s + :attr:`net_app_resource_region_infos` 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, location: str, **kwargs: Any) -> AsyncIterable["_models.RegionInfoResource"]: + """Describes region specific information. + + Provides region specific information. + + :param location: The name of the Azure region. Required. + :type location: str + :return: An iterator like instance of either RegionInfoResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.netapp.models.RegionInfoResource] + :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.RegionInfosList] = 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( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RegionInfosList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, location: str, **kwargs: Any) -> _models.RegionInfoResource: + """Describes region specific information. + + Provides storage to network proximity and logical zone mapping information. + + :param location: The name of the Azure region. Required. + :type location: str + :return: RegionInfoResource or the result of cls(response) + :rtype: ~azure.mgmt.netapp.models.RegionInfoResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RegionInfoResource] = kwargs.pop("cls", None) + + _request = build_get_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegionInfoResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_operations.py index 05f0d7ad4f10..6d3781205601 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,7 +63,6 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: Lists all of the available Microsoft.NetApp Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.netapp.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -69,7 +73,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,14 +84,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -99,13 +102,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -115,11 +118,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -131,5 +134,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.NetApp/operations"} diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_pools_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_pools_operations.py index f60fd08d05e6..10163300562e 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_pools_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_pools_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, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,6 +40,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +78,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As :type resource_group_name: str :param account_name: The name of the NetApp account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CapacityPool or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.netapp.models.CapacityPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -84,7 +88,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CapacityPoolList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,17 +99,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -117,13 +120,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("CapacityPoolList", pipeline_response) @@ -133,11 +136,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, pool_name: str, **kwargs: Any @@ -169,12 +168,11 @@ async def get( :type account_name: str :param pool_name: The name of the capacity pool. Required. :type pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CapacityPool or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.CapacityPool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,22 +186,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CapacityPool] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_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 = _convert_request(_request) + _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 @@ -216,23 +213,19 @@ async def get( deserialized = self._deserialize("CapacityPool", pipeline_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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, account_name: str, pool_name: str, - body: Union[_models.CapacityPool, IO], + body: Union[_models.CapacityPool, IO[bytes]], **kwargs: Any ) -> _models.CapacityPool: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,7 +248,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(body, "CapacityPool") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -264,16 +257,15 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -294,10 +286,6 @@ async def _create_or_update_initial( return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}" - } - @overload async def begin_create_or_update( self, @@ -325,14 +313,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either CapacityPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.CapacityPool] @@ -345,7 +325,7 @@ async def begin_create_or_update( resource_group_name: str, account_name: str, pool_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -362,18 +342,10 @@ async def begin_create_or_update( :param pool_name: The name of the capacity pool. Required. :type pool_name: str :param body: Capacity pool object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 CapacityPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.CapacityPool] @@ -386,7 +358,7 @@ async def begin_create_or_update( resource_group_name: str, account_name: str, pool_name: str, - body: Union[_models.CapacityPool, IO], + body: Union[_models.CapacityPool, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.CapacityPool]: """Create or Update the specified capacity pool within the resource group. @@ -401,19 +373,8 @@ async def begin_create_or_update( :param pool_name: The name of the capacity pool. Required. :type pool_name: str :param body: Capacity pool object supplied in the body of the operation. Is either a - CapacityPool type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.CapacityPool 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. + CapacityPool type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.CapacityPool or IO[bytes] :return: An instance of AsyncLROPoller that returns either CapacityPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.CapacityPool] @@ -446,7 +407,7 @@ async def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("CapacityPool", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -458,27 +419,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.CapacityPool].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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}" - } + return AsyncLROPoller[_models.CapacityPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, account_name: str, pool_name: str, - body: Union[_models.CapacityPoolPatch, IO], + body: Union[_models.CapacityPoolPatch, IO[bytes]], **kwargs: Any ) -> Optional[_models.CapacityPool]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -501,7 +460,7 @@ async def _update_initial( else: _json = self._serialize.body(body, "CapacityPoolPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -510,16 +469,15 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -534,13 +492,9 @@ async def _update_initial( deserialized = self._deserialize("CapacityPool", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -569,14 +523,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either CapacityPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.CapacityPool] @@ -589,7 +535,7 @@ async def begin_update( resource_group_name: str, account_name: str, pool_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -606,18 +552,10 @@ async def begin_update( :param pool_name: The name of the capacity pool. Required. :type pool_name: str :param body: Capacity pool object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 CapacityPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.CapacityPool] @@ -630,7 +568,7 @@ async def begin_update( resource_group_name: str, account_name: str, pool_name: str, - body: Union[_models.CapacityPoolPatch, IO], + body: Union[_models.CapacityPoolPatch, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.CapacityPool]: """Update a capacity pool. @@ -645,19 +583,8 @@ async def begin_update( :param pool_name: The name of the capacity pool. Required. :type pool_name: str :param body: Capacity pool object supplied in the body of the operation. Is either a - CapacityPoolPatch type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.CapacityPoolPatch 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. + CapacityPoolPatch type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.CapacityPoolPatch or IO[bytes] :return: An instance of AsyncLROPoller that returns either CapacityPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.CapacityPool] @@ -690,7 +617,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("CapacityPool", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -702,22 +629,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.CapacityPool].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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}" - } + return AsyncLROPoller[_models.CapacityPool]( + 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, account_name: str, pool_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -731,22 +656,21 @@ async def _delete_initial( # 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, account_name=account_name, pool_name=pool_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 = _convert_request(_request) + _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 @@ -757,11 +681,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_delete( @@ -778,14 +698,6 @@ async def begin_delete( :type account_name: str :param pool_name: The name of the capacity pool. Required. :type pool_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: @@ -813,7 +725,7 @@ async def begin_delete( 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( @@ -824,14 +736,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_snapshot_policies_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_snapshot_policies_operations.py index 3d4a8820ef54..2c9666e46463 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_snapshot_policies_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_snapshot_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, cast, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,7 +79,6 @@ def list( :type resource_group_name: str :param account_name: The name of the NetApp account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SnapshotPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.netapp.models.SnapshotPolicy] :raises ~azure.core.exceptions.HttpResponseError: @@ -85,7 +89,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SnapshotPoliciesList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,17 +100,16 @@ 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, account_name=account_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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,13 +121,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SnapshotPoliciesList", pipeline_response) @@ -134,11 +137,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, snapshot_policy_name: str, **kwargs: Any @@ -168,12 +167,11 @@ async def get( :type account_name: str :param snapshot_policy_name: The name of the snapshot policy. Required. :type snapshot_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SnapshotPolicy or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.SnapshotPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,22 +185,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SnapshotPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, snapshot_policy_name=snapshot_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 = _convert_request(_request) + _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,13 +212,9 @@ async def get( deserialized = self._deserialize("SnapshotPolicy", pipeline_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.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}" - } + return deserialized # type: ignore @overload async def create( @@ -248,7 +241,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SnapshotPolicy or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.SnapshotPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -260,7 +252,7 @@ async def create( resource_group_name: str, account_name: str, snapshot_policy_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -275,11 +267,10 @@ async def create( :param snapshot_policy_name: The name of the snapshot policy. Required. :type snapshot_policy_name: str :param body: Snapshot policy object supplied in the body of the operation. Required. - :type body: IO + :type body: 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: SnapshotPolicy or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.SnapshotPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -291,7 +282,7 @@ async def create( resource_group_name: str, account_name: str, snapshot_policy_name: str, - body: Union[_models.SnapshotPolicy, IO], + body: Union[_models.SnapshotPolicy, IO[bytes]], **kwargs: Any ) -> _models.SnapshotPolicy: """Create a snapshot policy. @@ -304,17 +295,13 @@ async def create( :param snapshot_policy_name: The name of the snapshot policy. Required. :type snapshot_policy_name: str :param body: Snapshot policy object supplied in the body of the operation. Is either a - SnapshotPolicy type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.SnapshotPolicy 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 + SnapshotPolicy type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.SnapshotPolicy or IO[bytes] :return: SnapshotPolicy or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.SnapshotPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -337,7 +324,7 @@ async def create( else: _json = self._serialize.body(body, "SnapshotPolicy") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, snapshot_policy_name=snapshot_policy_name, @@ -346,16 +333,15 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -376,19 +362,15 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}" - } - async def _update_initial( self, resource_group_name: str, account_name: str, snapshot_policy_name: str, - body: Union[_models.SnapshotPolicyPatch, IO], + body: Union[_models.SnapshotPolicyPatch, IO[bytes]], **kwargs: Any ) -> _models.SnapshotPolicy: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -411,7 +393,7 @@ async def _update_initial( else: _json = self._serialize.body(body, "SnapshotPolicyPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, snapshot_policy_name=snapshot_policy_name, @@ -420,16 +402,15 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -450,10 +431,6 @@ async def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}" - } - @overload async def begin_update( self, @@ -479,14 +456,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either SnapshotPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.SnapshotPolicy] @@ -499,7 +468,7 @@ async def begin_update( resource_group_name: str, account_name: str, snapshot_policy_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -514,18 +483,10 @@ async def begin_update( :param snapshot_policy_name: The name of the snapshot policy. Required. :type snapshot_policy_name: str :param body: Snapshot policy object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 SnapshotPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.SnapshotPolicy] @@ -538,7 +499,7 @@ async def begin_update( resource_group_name: str, account_name: str, snapshot_policy_name: str, - body: Union[_models.SnapshotPolicyPatch, IO], + body: Union[_models.SnapshotPolicyPatch, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.SnapshotPolicy]: """Patch a snapshot policy. @@ -551,19 +512,8 @@ async def begin_update( :param snapshot_policy_name: The name of the snapshot policy. Required. :type snapshot_policy_name: str :param body: Snapshot policy object supplied in the body of the operation. Is either a - SnapshotPolicyPatch type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.SnapshotPolicyPatch 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. + SnapshotPolicyPatch type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.SnapshotPolicyPatch or IO[bytes] :return: An instance of AsyncLROPoller that returns either SnapshotPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.SnapshotPolicy] @@ -596,7 +546,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("SnapshotPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -608,22 +558,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SnapshotPolicy].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.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}" - } + return AsyncLROPoller[_models.SnapshotPolicy]( + 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, account_name: str, snapshot_policy_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -637,22 +585,21 @@ async def _delete_initial( # 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, account_name=account_name, snapshot_policy_name=snapshot_policy_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 = _convert_request(_request) + _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 @@ -663,11 +610,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_delete( @@ -682,14 +625,6 @@ async def begin_delete( :type account_name: str :param snapshot_policy_name: The name of the snapshot policy. Required. :type snapshot_policy_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: @@ -717,7 +652,7 @@ async def begin_delete( 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( @@ -728,17 +663,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def list_volumes( @@ -755,12 +686,11 @@ async def list_volumes( :type account_name: str :param snapshot_policy_name: The name of the snapshot policy. Required. :type snapshot_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SnapshotPolicyVolumeList or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.SnapshotPolicyVolumeList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -774,22 +704,21 @@ async def list_volumes( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SnapshotPolicyVolumeList] = kwargs.pop("cls", None) - request = build_list_volumes_request( + _request = build_list_volumes_request( resource_group_name=resource_group_name, account_name=account_name, snapshot_policy_name=snapshot_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_volumes.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -802,10 +731,6 @@ async def list_volumes( deserialized = self._deserialize("SnapshotPolicyVolumeList", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_volumes.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}/volumes" - } + return deserialized # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_snapshots_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_snapshots_operations.py index b1e531eb9bc2..3b50269b252a 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_snapshots_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_snapshots_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -86,7 +86,6 @@ def list( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Snapshot or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.netapp.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: @@ -97,7 +96,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SnapshotsList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -108,19 +107,18 @@ 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, account_name=account_name, pool_name=pool_name, volume_name=volume_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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -132,13 +130,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SnapshotsList", pipeline_response) @@ -148,11 +146,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -165,10 +163,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots" - } - @distributed_trace_async async def get( self, @@ -194,12 +188,11 @@ async def get( :type volume_name: str :param snapshot_name: The name of the snapshot. Required. :type snapshot_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Snapshot or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.Snapshot :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -213,7 +206,7 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -221,16 +214,15 @@ async def get( snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -243,13 +235,9 @@ async def get( deserialized = self._deserialize("Snapshot", pipeline_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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}" - } + return deserialized # type: ignore async def _create_initial( self, @@ -258,10 +246,10 @@ async def _create_initial( pool_name: str, volume_name: str, snapshot_name: str, - body: Union[_models.Snapshot, IO], + body: Union[_models.Snapshot, IO[bytes]], **kwargs: Any ) -> Optional[_models.Snapshot]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -284,7 +272,7 @@ async def _create_initial( else: _json = self._serialize.body(body, "Snapshot") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -295,16 +283,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -319,13 +306,9 @@ async def _create_initial( deserialized = self._deserialize("Snapshot", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -360,14 +343,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Snapshot or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Snapshot] @@ -382,7 +357,7 @@ async def begin_create( pool_name: str, volume_name: str, snapshot_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -403,18 +378,10 @@ async def begin_create( :param snapshot_name: The name of the snapshot. Required. :type snapshot_name: str :param body: Snapshot object supplied in the body of the operation. Required. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Snapshot or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Snapshot] @@ -429,7 +396,7 @@ async def begin_create( pool_name: str, volume_name: str, snapshot_name: str, - body: Union[_models.Snapshot, IO], + body: Union[_models.Snapshot, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Snapshot]: """Create a snapshot. @@ -448,19 +415,8 @@ async def begin_create( :param snapshot_name: The name of the snapshot. Required. :type snapshot_name: str :param body: Snapshot object supplied in the body of the operation. Is either a Snapshot type - or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.Snapshot or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.Snapshot or IO[bytes] :return: An instance of AsyncLROPoller that returns either Snapshot or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Snapshot] @@ -495,7 +451,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Snapshot", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -507,17 +463,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Snapshot].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}" - } + return AsyncLROPoller[_models.Snapshot]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, @@ -529,7 +483,7 @@ async def _update_initial( body: JSON, **kwargs: Any ) -> Optional[_models.Snapshot]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -546,7 +500,7 @@ async def _update_initial( _json = self._serialize.body(body, "object") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -556,16 +510,15 @@ async def _update_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -580,13 +533,9 @@ async def _update_initial( deserialized = self._deserialize("Snapshot", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_update( @@ -616,14 +565,6 @@ async def begin_update( :type snapshot_name: str :param body: Snapshot object supplied in the body of the operation. Required. :type body: JSON - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Snapshot or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Snapshot] @@ -658,7 +599,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Snapshot", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -670,17 +611,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Snapshot].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}" - } + return AsyncLROPoller[_models.Snapshot]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -691,7 +630,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -705,7 +644,7 @@ async def _delete_initial( # 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, account_name=account_name, pool_name=pool_name, @@ -713,16 +652,15 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -733,11 +671,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_delete( @@ -764,14 +698,6 @@ async def begin_delete( :type volume_name: str :param snapshot_name: The name of the snapshot. Required. :type snapshot_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -801,7 +727,7 @@ async def begin_delete( 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( @@ -812,17 +738,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _restore_files_initial( # pylint: disable=inconsistent-return-statements self, @@ -831,10 +753,10 @@ async def _restore_files_initial( # pylint: disable=inconsistent-return-stateme pool_name: str, volume_name: str, snapshot_name: str, - body: Union[_models.SnapshotRestoreFiles, IO], + body: Union[_models.SnapshotRestoreFiles, IO[bytes]], **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -857,7 +779,7 @@ async def _restore_files_initial( # pylint: disable=inconsistent-return-stateme else: _json = self._serialize.body(body, "SnapshotRestoreFiles") - request = build_restore_files_request( + _request = build_restore_files_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -868,16 +790,15 @@ async def _restore_files_initial( # pylint: disable=inconsistent-return-stateme content_type=content_type, json=_json, content=_content, - template_url=self._restore_files_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -888,11 +809,7 @@ async def _restore_files_initial( # pylint: disable=inconsistent-return-stateme raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _restore_files_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}/restoreFiles" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def begin_restore_files( @@ -927,14 +844,6 @@ async def begin_restore_files( :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: @@ -948,7 +857,7 @@ async def begin_restore_files( pool_name: str, volume_name: str, snapshot_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -969,18 +878,10 @@ async def begin_restore_files( :param snapshot_name: The name of the snapshot. Required. :type snapshot_name: str :param body: Restore payload supplied in the body of the operation. Required. - :type body: IO + :type body: 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: @@ -994,7 +895,7 @@ async def begin_restore_files( pool_name: str, volume_name: str, snapshot_name: str, - body: Union[_models.SnapshotRestoreFiles, IO], + body: Union[_models.SnapshotRestoreFiles, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[None]: """Create a new Snapshot Restore Files request. @@ -1013,19 +914,8 @@ async def begin_restore_files( :param snapshot_name: The name of the snapshot. Required. :type snapshot_name: str :param body: Restore payload supplied in the body of the operation. Is either a - SnapshotRestoreFiles type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.SnapshotRestoreFiles 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. + SnapshotRestoreFiles type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.SnapshotRestoreFiles 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: @@ -1058,7 +948,7 @@ async def begin_restore_files( 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( @@ -1069,14 +959,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_restore_files.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}/restoreFiles" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_subvolumes_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_subvolumes_operations.py index e1022193f8dc..2cb9a6fa7a0a 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_subvolumes_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_subvolumes_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, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -80,7 +85,6 @@ def list_by_volume( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SubvolumeInfo or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.netapp.models.SubvolumeInfo] :raises ~azure.core.exceptions.HttpResponseError: @@ -91,7 +95,7 @@ def list_by_volume( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubvolumesList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -102,19 +106,18 @@ def list_by_volume( def prepare_request(next_link=None): if not next_link: - request = build_list_by_volume_request( + _request = build_list_by_volume_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_volume.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -126,13 +129,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SubvolumesList", pipeline_response) @@ -142,11 +145,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 @@ -159,10 +162,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_volume.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes" - } - @distributed_trace_async async def get( self, @@ -188,12 +187,11 @@ async def get( :type volume_name: str :param subvolume_name: The name of the subvolume. Required. :type subvolume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SubvolumeInfo or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.SubvolumeInfo :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -207,7 +205,7 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubvolumeInfo] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -215,16 +213,15 @@ async def get( subvolume_name=subvolume_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 = _convert_request(_request) + _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 @@ -237,13 +234,9 @@ async def get( deserialized = self._deserialize("SubvolumeInfo", pipeline_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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}" - } + return deserialized # type: ignore async def _create_initial( self, @@ -252,10 +245,10 @@ async def _create_initial( pool_name: str, volume_name: str, subvolume_name: str, - body: Union[_models.SubvolumeInfo, IO], + body: Union[_models.SubvolumeInfo, IO[bytes]], **kwargs: Any ) -> Optional[_models.SubvolumeInfo]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -278,7 +271,7 @@ async def _create_initial( else: _json = self._serialize.body(body, "SubvolumeInfo") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -289,16 +282,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -316,13 +308,9 @@ async def _create_initial( deserialized = self._deserialize("SubvolumeInfo", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -357,14 +345,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either SubvolumeInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.SubvolumeInfo] @@ -379,7 +359,7 @@ async def begin_create( pool_name: str, volume_name: str, subvolume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -400,18 +380,10 @@ async def begin_create( :param subvolume_name: The name of the subvolume. Required. :type subvolume_name: str :param body: Subvolume object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 SubvolumeInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.SubvolumeInfo] @@ -426,7 +398,7 @@ async def begin_create( pool_name: str, volume_name: str, subvolume_name: str, - body: Union[_models.SubvolumeInfo, IO], + body: Union[_models.SubvolumeInfo, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.SubvolumeInfo]: """Create or clone a new subvolume. @@ -445,19 +417,8 @@ async def begin_create( :param subvolume_name: The name of the subvolume. Required. :type subvolume_name: str :param body: Subvolume object supplied in the body of the operation. Is either a SubvolumeInfo - type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.SubvolumeInfo or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.SubvolumeInfo or IO[bytes] :return: An instance of AsyncLROPoller that returns either SubvolumeInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.SubvolumeInfo] @@ -492,7 +453,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("SubvolumeInfo", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -505,17 +466,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SubvolumeInfo].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}" - } + return AsyncLROPoller[_models.SubvolumeInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, @@ -524,10 +483,10 @@ async def _update_initial( pool_name: str, volume_name: str, subvolume_name: str, - body: Union[_models.SubvolumePatchRequest, IO], + body: Union[_models.SubvolumePatchRequest, IO[bytes]], **kwargs: Any ) -> Optional[_models.SubvolumeInfo]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -550,7 +509,7 @@ async def _update_initial( else: _json = self._serialize.body(body, "SubvolumePatchRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -561,16 +520,15 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -585,13 +543,9 @@ async def _update_initial( deserialized = self._deserialize("SubvolumeInfo", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -626,14 +580,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either SubvolumeInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.SubvolumeInfo] @@ -648,7 +594,7 @@ async def begin_update( pool_name: str, volume_name: str, subvolume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -669,18 +615,10 @@ async def begin_update( :param subvolume_name: The name of the subvolume. Required. :type subvolume_name: str :param body: Subvolume object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 SubvolumeInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.SubvolumeInfo] @@ -695,7 +633,7 @@ async def begin_update( pool_name: str, volume_name: str, subvolume_name: str, - body: Union[_models.SubvolumePatchRequest, IO], + body: Union[_models.SubvolumePatchRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.SubvolumeInfo]: """Update a subvolume. @@ -714,19 +652,8 @@ async def begin_update( :param subvolume_name: The name of the subvolume. Required. :type subvolume_name: str :param body: Subvolume object supplied in the body of the operation. Is either a - SubvolumePatchRequest type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.SubvolumePatchRequest 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. + SubvolumePatchRequest type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.SubvolumePatchRequest or IO[bytes] :return: An instance of AsyncLROPoller that returns either SubvolumeInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.SubvolumeInfo] @@ -761,7 +688,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("SubvolumeInfo", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -774,17 +701,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SubvolumeInfo].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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}" - } + return AsyncLROPoller[_models.SubvolumeInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -795,7 +720,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subvolume_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -809,7 +734,7 @@ async def _delete_initial( # 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, account_name=account_name, pool_name=pool_name, @@ -817,16 +742,15 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subvolume_name=subvolume_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 = _convert_request(_request) + _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 @@ -837,11 +761,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_delete( @@ -868,14 +788,6 @@ async def begin_delete( :type volume_name: str :param subvolume_name: The name of the subvolume. Required. :type subvolume_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: @@ -905,7 +817,7 @@ async def begin_delete( 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( @@ -917,17 +829,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _get_metadata_initial( self, @@ -938,7 +846,7 @@ async def _get_metadata_initial( subvolume_name: str, **kwargs: Any ) -> Optional[_models.SubvolumeModel]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -952,7 +860,7 @@ async def _get_metadata_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.SubvolumeModel]] = kwargs.pop("cls", None) - request = build_get_metadata_request( + _request = build_get_metadata_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -960,16 +868,15 @@ async def _get_metadata_initial( subvolume_name=subvolume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._get_metadata_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -984,13 +891,9 @@ async def _get_metadata_initial( deserialized = self._deserialize("SubvolumeModel", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _get_metadata_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}/getMetadata" - } + return deserialized # type: ignore @distributed_trace_async async def begin_get_metadata( @@ -1017,14 +920,6 @@ async def begin_get_metadata( :type volume_name: str :param subvolume_name: The name of the subvolume. Required. :type subvolume_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 SubvolumeModel or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.SubvolumeModel] @@ -1056,7 +951,7 @@ async def begin_get_metadata( def get_long_running_output(pipeline_response): deserialized = self._deserialize("SubvolumeModel", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1069,14 +964,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SubvolumeModel].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_get_metadata.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}/getMetadata" - } + return AsyncLROPoller[_models.SubvolumeModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_volume_groups_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_volume_groups_operations.py index 4fd5354e2221..9f3f95efaacc 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_volume_groups_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_volume_groups_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -38,6 +39,10 @@ build_list_by_net_app_account_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]] @@ -74,7 +79,6 @@ def list_by_net_app_account( :type resource_group_name: str :param account_name: The name of the NetApp account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VolumeGroup or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.netapp.models.VolumeGroup] :raises ~azure.core.exceptions.HttpResponseError: @@ -85,7 +89,7 @@ def list_by_net_app_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VolumeGroupList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,17 +100,16 @@ def list_by_net_app_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_net_app_account_request( + _request = build_list_by_net_app_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_net_app_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,13 +121,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("VolumeGroupList", pipeline_response) @@ -134,11 +137,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_net_app_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/volumeGroups" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, volume_group_name: str, **kwargs: Any @@ -170,12 +169,11 @@ async def get( :type account_name: str :param volume_group_name: The name of the volumeGroup. Required. :type volume_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VolumeGroupDetails or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.VolumeGroupDetails :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -189,22 +187,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VolumeGroupDetails] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, volume_group_name=volume_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -217,23 +214,19 @@ async def get( deserialized = self._deserialize("VolumeGroupDetails", pipeline_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.NetApp/netAppAccounts/{accountName}/volumeGroups/{volumeGroupName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, volume_group_name: str, - body: Union[_models.VolumeGroupDetails, IO], + body: Union[_models.VolumeGroupDetails, IO[bytes]], **kwargs: Any ) -> _models.VolumeGroupDetails: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,7 +249,7 @@ async def _create_initial( else: _json = self._serialize.body(body, "VolumeGroupDetails") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, volume_group_name=volume_group_name, @@ -265,16 +258,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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,13 +279,9 @@ async def _create_initial( deserialized = self._deserialize("VolumeGroupDetails", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/volumeGroups/{volumeGroupName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -324,14 +312,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VolumeGroupDetails or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.VolumeGroupDetails] @@ -344,7 +324,7 @@ async def begin_create( resource_group_name: str, account_name: str, volume_group_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -363,18 +343,10 @@ async def begin_create( :param volume_group_name: The name of the volumeGroup. Required. :type volume_group_name: str :param body: Volume Group object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 VolumeGroupDetails or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.VolumeGroupDetails] @@ -387,7 +359,7 @@ async def begin_create( resource_group_name: str, account_name: str, volume_group_name: str, - body: Union[_models.VolumeGroupDetails, IO], + body: Union[_models.VolumeGroupDetails, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.VolumeGroupDetails]: """Create the specified volume group and volumes. Creating volume group will create all the @@ -404,19 +376,8 @@ async def begin_create( :param volume_group_name: The name of the volumeGroup. Required. :type volume_group_name: str :param body: Volume Group object supplied in the body of the operation. Is either a - VolumeGroupDetails type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.VolumeGroupDetails 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. + VolumeGroupDetails type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.VolumeGroupDetails or IO[bytes] :return: An instance of AsyncLROPoller that returns either VolumeGroupDetails or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.VolumeGroupDetails] @@ -449,7 +410,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("VolumeGroupDetails", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -459,22 +420,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VolumeGroupDetails].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/volumeGroups/{volumeGroupName}" - } + return AsyncLROPoller[_models.VolumeGroupDetails]( + 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, account_name: str, volume_group_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -488,22 +447,21 @@ async def _delete_initial( # 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, account_name=account_name, volume_group_name=volume_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -514,11 +472,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/volumeGroups/{volumeGroupName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_delete( @@ -535,14 +489,6 @@ async def begin_delete( :type account_name: str :param volume_group_name: The name of the volumeGroup. Required. :type volume_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -570,7 +516,7 @@ async def begin_delete( 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)) @@ -579,14 +525,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/volumeGroups/{volumeGroupName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_volume_quota_rules_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_volume_quota_rules_operations.py index f71ad144a52b..68917e8d5881 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_volume_quota_rules_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_volume_quota_rules_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, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -39,6 +40,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +84,6 @@ def list_by_volume( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VolumeQuotaRule or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.netapp.models.VolumeQuotaRule] :raises ~azure.core.exceptions.HttpResponseError: @@ -90,7 +94,7 @@ def list_by_volume( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VolumeQuotaRulesList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,19 +105,18 @@ def list_by_volume( def prepare_request(next_link=None): if not next_link: - request = build_list_by_volume_request( + _request = build_list_by_volume_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_volume.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,13 +128,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("VolumeQuotaRulesList", pipeline_response) @@ -141,11 +144,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -158,10 +161,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_volume.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/volumeQuotaRules" - } - @distributed_trace_async async def get( self, @@ -187,12 +186,11 @@ async def get( :type volume_name: str :param volume_quota_rule_name: The name of volume quota rule. Required. :type volume_quota_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VolumeQuotaRule or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.VolumeQuotaRule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -206,7 +204,7 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VolumeQuotaRule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -214,16 +212,15 @@ async def get( volume_quota_rule_name=volume_quota_rule_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 = _convert_request(_request) + _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 @@ -236,13 +233,9 @@ async def get( deserialized = self._deserialize("VolumeQuotaRule", pipeline_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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/volumeQuotaRules/{volumeQuotaRuleName}" - } + return deserialized # type: ignore async def _create_initial( self, @@ -251,10 +244,10 @@ async def _create_initial( pool_name: str, volume_name: str, volume_quota_rule_name: str, - body: Union[_models.VolumeQuotaRule, IO], + body: Union[_models.VolumeQuotaRule, IO[bytes]], **kwargs: Any ) -> _models.VolumeQuotaRule: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -277,7 +270,7 @@ async def _create_initial( else: _json = self._serialize.body(body, "VolumeQuotaRule") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -288,16 +281,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -318,10 +310,6 @@ async def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/volumeQuotaRules/{volumeQuotaRuleName}" - } - @overload async def begin_create( self, @@ -355,14 +343,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VolumeQuotaRule or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.VolumeQuotaRule] @@ -377,7 +357,7 @@ async def begin_create( pool_name: str, volume_name: str, volume_quota_rule_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -398,18 +378,10 @@ async def begin_create( :param volume_quota_rule_name: The name of volume quota rule. Required. :type volume_quota_rule_name: str :param body: Quota rule object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 VolumeQuotaRule or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.VolumeQuotaRule] @@ -424,7 +396,7 @@ async def begin_create( pool_name: str, volume_name: str, volume_quota_rule_name: str, - body: Union[_models.VolumeQuotaRule, IO], + body: Union[_models.VolumeQuotaRule, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.VolumeQuotaRule]: """Create a quota rule. @@ -443,19 +415,8 @@ async def begin_create( :param volume_quota_rule_name: The name of volume quota rule. Required. :type volume_quota_rule_name: str :param body: Quota rule object supplied in the body of the operation. Is either a - VolumeQuotaRule type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.VolumeQuotaRule 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. + VolumeQuotaRule type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.VolumeQuotaRule or IO[bytes] :return: An instance of AsyncLROPoller that returns either VolumeQuotaRule or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.VolumeQuotaRule] @@ -490,7 +451,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("VolumeQuotaRule", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -502,17 +463,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VolumeQuotaRule].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/volumeQuotaRules/{volumeQuotaRuleName}" - } + return AsyncLROPoller[_models.VolumeQuotaRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, @@ -521,10 +480,10 @@ async def _update_initial( pool_name: str, volume_name: str, volume_quota_rule_name: str, - body: Union[_models.VolumeQuotaRulePatch, IO], + body: Union[_models.VolumeQuotaRulePatch, IO[bytes]], **kwargs: Any ) -> Optional[_models.VolumeQuotaRule]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -547,7 +506,7 @@ async def _update_initial( else: _json = self._serialize.body(body, "VolumeQuotaRulePatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -558,16 +517,15 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -582,13 +540,9 @@ async def _update_initial( deserialized = self._deserialize("VolumeQuotaRule", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/volumeQuotaRules/{volumeQuotaRuleName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -623,14 +577,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VolumeQuotaRule or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.VolumeQuotaRule] @@ -645,7 +591,7 @@ async def begin_update( pool_name: str, volume_name: str, volume_quota_rule_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -666,18 +612,10 @@ async def begin_update( :param volume_quota_rule_name: The name of volume quota rule. Required. :type volume_quota_rule_name: str :param body: Quota rule object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 VolumeQuotaRule or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.VolumeQuotaRule] @@ -692,7 +630,7 @@ async def begin_update( pool_name: str, volume_name: str, volume_quota_rule_name: str, - body: Union[_models.VolumeQuotaRulePatch, IO], + body: Union[_models.VolumeQuotaRulePatch, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.VolumeQuotaRule]: """Update a quota rule. @@ -711,19 +649,8 @@ async def begin_update( :param volume_quota_rule_name: The name of volume quota rule. Required. :type volume_quota_rule_name: str :param body: Quota rule object supplied in the body of the operation. Is either a - VolumeQuotaRulePatch type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.VolumeQuotaRulePatch 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. + VolumeQuotaRulePatch type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.VolumeQuotaRulePatch or IO[bytes] :return: An instance of AsyncLROPoller that returns either VolumeQuotaRule or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.VolumeQuotaRule] @@ -758,7 +685,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("VolumeQuotaRule", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -770,17 +697,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VolumeQuotaRule].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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/volumeQuotaRules/{volumeQuotaRuleName}" - } + return AsyncLROPoller[_models.VolumeQuotaRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -791,7 +716,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements volume_quota_rule_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -805,7 +730,7 @@ async def _delete_initial( # 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, account_name=account_name, pool_name=pool_name, @@ -813,16 +738,15 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements volume_quota_rule_name=volume_quota_rule_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 = _convert_request(_request) + _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 @@ -833,11 +757,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/volumeQuotaRules/{volumeQuotaRuleName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_delete( @@ -864,14 +784,6 @@ async def begin_delete( :type volume_name: str :param volume_quota_rule_name: The name of volume quota rule. Required. :type volume_quota_rule_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: @@ -901,7 +813,7 @@ async def begin_delete( 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( @@ -912,14 +824,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/volumeQuotaRules/{volumeQuotaRuleName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_volumes_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_volumes_operations.py index 3028d87de7b2..fbc44f27f6eb 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_volumes_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/aio/operations/_volumes_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -35,14 +36,18 @@ build_authorize_replication_request, build_break_file_locks_request, build_break_replication_request, + build_create_on_prem_migration_replication_request, build_create_or_update_request, build_delete_replication_request, build_delete_request, + build_finalize_on_prem_migration_request, build_finalize_relocation_request, build_get_request, build_list_get_group_id_list_for_ldap_user_request, build_list_replications_request, build_list_request, + build_peer_cluster_for_on_prem_migration_request, + build_perform_replication_transfer_request, build_pool_change_request, build_populate_availability_zone_request, build_re_initialize_replication_request, @@ -53,9 +58,14 @@ build_resync_replication_request, build_revert_relocation_request, build_revert_request, + build_split_clone_from_parent_request, build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -94,7 +104,6 @@ def list( :type account_name: str :param pool_name: The name of the capacity pool. Required. :type pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Volume or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.netapp.models.Volume] :raises ~azure.core.exceptions.HttpResponseError: @@ -105,7 +114,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VolumeList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -116,18 +125,17 @@ 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, account_name=account_name, pool_name=pool_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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -139,13 +147,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("VolumeList", pipeline_response) @@ -155,11 +163,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 @@ -172,10 +180,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any @@ -193,12 +197,11 @@ async def get( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Volume or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.Volume :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,23 +215,22 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Volume] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -241,13 +243,9 @@ async def get( deserialized = self._deserialize("Volume", pipeline_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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, @@ -255,10 +253,10 @@ async def _create_or_update_initial( account_name: str, pool_name: str, volume_name: str, - body: Union[_models.Volume, IO], + body: Union[_models.Volume, IO[bytes]], **kwargs: Any ) -> Optional[_models.Volume]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -281,7 +279,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(body, "Volume") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -291,16 +289,15 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -318,13 +315,9 @@ async def _create_or_update_initial( deserialized = self._deserialize("Volume", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -356,14 +349,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Volume] @@ -377,7 +362,7 @@ async def begin_create_or_update( account_name: str, pool_name: str, volume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -396,18 +381,10 @@ async def begin_create_or_update( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Volume object supplied in the body of the operation. Required. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Volume] @@ -421,7 +398,7 @@ async def begin_create_or_update( account_name: str, pool_name: str, volume_name: str, - body: Union[_models.Volume, IO], + body: Union[_models.Volume, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Volume]: """Create or Update a volume. @@ -438,19 +415,8 @@ async def begin_create_or_update( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Volume object supplied in the body of the operation. Is either a Volume type or a - IO type. Required. - :type body: ~azure.mgmt.netapp.models.Volume or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.Volume or IO[bytes] :return: An instance of AsyncLROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Volume] @@ -484,7 +450,7 @@ async def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Volume", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -497,17 +463,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Volume].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}" - } + return AsyncLROPoller[_models.Volume]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, @@ -515,10 +479,10 @@ async def _update_initial( account_name: str, pool_name: str, volume_name: str, - body: Union[_models.VolumePatch, IO], + body: Union[_models.VolumePatch, IO[bytes]], **kwargs: Any ) -> Optional[_models.Volume]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -541,7 +505,7 @@ async def _update_initial( else: _json = self._serialize.body(body, "VolumePatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -551,16 +515,15 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -575,13 +538,9 @@ async def _update_initial( deserialized = self._deserialize("Volume", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -613,14 +572,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Volume] @@ -634,7 +585,7 @@ async def begin_update( account_name: str, pool_name: str, volume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -653,18 +604,10 @@ async def begin_update( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Volume object supplied in the body of the operation. Required. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Volume] @@ -678,7 +621,7 @@ async def begin_update( account_name: str, pool_name: str, volume_name: str, - body: Union[_models.VolumePatch, IO], + body: Union[_models.VolumePatch, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Volume]: """Update a volume. @@ -695,19 +638,8 @@ async def begin_update( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Volume object supplied in the body of the operation. Is either a VolumePatch type - or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.VolumePatch 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 body: ~azure.mgmt.netapp.models.VolumePatch or IO[bytes] :return: An instance of AsyncLROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Volume] @@ -741,7 +673,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Volume", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -753,17 +685,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Volume].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}" - } + return AsyncLROPoller[_models.Volume]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -774,7 +704,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -788,7 +718,7 @@ async def _delete_initial( # 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, account_name=account_name, pool_name=pool_name, @@ -796,16 +726,15 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, force_delete=force_delete, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -816,11 +745,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_delete( @@ -848,14 +773,6 @@ async def begin_delete( :param force_delete: An option to force delete the volume. Will cleanup resources connected to the particular volume. Default value is None. :type force_delete: bool - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -885,7 +802,7 @@ async def begin_delete( 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( @@ -896,22 +813,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _populate_availability_zone_initial( self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any ) -> Optional[_models.Volume]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -925,23 +838,22 @@ async def _populate_availability_zone_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.Volume]] = kwargs.pop("cls", None) - request = build_populate_availability_zone_request( + _request = build_populate_availability_zone_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._populate_availability_zone_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -960,13 +872,9 @@ async def _populate_availability_zone_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _populate_availability_zone_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/populateAvailabilityZone" - } + return deserialized # type: ignore @distributed_trace_async async def begin_populate_availability_zone( @@ -985,14 +893,6 @@ async def begin_populate_availability_zone( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.Volume] @@ -1023,7 +923,7 @@ async def begin_populate_availability_zone( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Volume", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1035,17 +935,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Volume].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_populate_availability_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/populateAvailabilityZone" - } + return AsyncLROPoller[_models.Volume]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _revert_initial( # pylint: disable=inconsistent-return-statements self, @@ -1053,10 +951,10 @@ async def _revert_initial( # pylint: disable=inconsistent-return-statements account_name: str, pool_name: str, volume_name: str, - body: Union[_models.VolumeRevert, IO], + body: Union[_models.VolumeRevert, IO[bytes]], **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1079,7 +977,7 @@ async def _revert_initial( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(body, "VolumeRevert") - request = build_revert_request( + _request = build_revert_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -1089,16 +987,15 @@ async def _revert_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self._revert_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -1109,11 +1006,7 @@ async def _revert_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _revert_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/revert" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def begin_revert( @@ -1145,14 +1038,6 @@ async def begin_revert( :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: @@ -1165,7 +1050,7 @@ async def begin_revert( account_name: str, pool_name: str, volume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1184,18 +1069,10 @@ async def begin_revert( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Object for snapshot to revert supplied in the body of the operation. Required. - :type body: IO + :type body: 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: @@ -1208,7 +1085,7 @@ async def begin_revert( account_name: str, pool_name: str, volume_name: str, - body: Union[_models.VolumeRevert, IO], + body: Union[_models.VolumeRevert, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[None]: """Revert a volume to one of its snapshots. @@ -1225,19 +1102,8 @@ async def begin_revert( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Object for snapshot to revert supplied in the body of the operation. Is either a - VolumeRevert type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.VolumeRevert 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. + VolumeRevert type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.VolumeRevert 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: @@ -1269,7 +1135,7 @@ async def begin_revert( 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( @@ -1280,22 +1146,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_revert.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/revert" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _reset_cifs_password_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1309,23 +1171,22 @@ async def _reset_cifs_password_initial( # pylint: disable=inconsistent-return-s api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_reset_cifs_password_request( + _request = build_reset_cifs_password_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._reset_cifs_password_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -1339,11 +1200,7 @@ async def _reset_cifs_password_initial( # pylint: disable=inconsistent-return-s response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, None, response_headers) - - _reset_cifs_password_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/resetCifsPassword" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_reset_cifs_password( @@ -1362,14 +1219,6 @@ async def begin_reset_cifs_password( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -1398,7 +1247,7 @@ async def begin_reset_cifs_password( 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)) @@ -1407,17 +1256,125 @@ 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 + + async def _split_clone_from_parent_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_split_clone_from_parent_request( + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def begin_split_clone_from_parent( + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Split clone from parent volume. + + Split operation to convert clone volume to an independent volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: 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: + """ + _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[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._split_clone_from_parent_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore - begin_reset_cifs_password.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/resetCifsPassword" - } + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _break_file_locks_initial( # pylint: disable=inconsistent-return-statements self, @@ -1425,10 +1382,10 @@ async def _break_file_locks_initial( # pylint: disable=inconsistent-return-stat account_name: str, pool_name: str, volume_name: str, - body: Optional[Union[_models.BreakFileLocksRequest, IO]] = None, + body: Optional[Union[_models.BreakFileLocksRequest, IO[bytes]]] = None, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1454,7 +1411,7 @@ async def _break_file_locks_initial( # pylint: disable=inconsistent-return-stat else: _json = None - request = build_break_file_locks_request( + _request = build_break_file_locks_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -1464,16 +1421,15 @@ async def _break_file_locks_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, content=_content, - template_url=self._break_file_locks_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -1488,11 +1444,7 @@ async def _break_file_locks_initial( # pylint: disable=inconsistent-return-stat response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, None, response_headers) - - _break_file_locks_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/breakFileLocks" - } + return cls(pipeline_response, None, response_headers) # type: ignore @overload async def begin_break_file_locks( @@ -1525,14 +1477,6 @@ async def begin_break_file_locks( :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: @@ -1545,7 +1489,7 @@ async def begin_break_file_locks( account_name: str, pool_name: str, volume_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1565,18 +1509,10 @@ async def begin_break_file_locks( :type volume_name: str :param body: Optional body to provide the ability to clear file locks with selected options. Default value is None. - :type body: IO + :type body: 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: @@ -1589,7 +1525,7 @@ async def begin_break_file_locks( account_name: str, pool_name: str, volume_name: str, - body: Optional[Union[_models.BreakFileLocksRequest, IO]] = None, + body: Optional[Union[_models.BreakFileLocksRequest, IO[bytes]]] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Break file locks. @@ -1606,19 +1542,8 @@ async def begin_break_file_locks( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Optional body to provide the ability to clear file locks with selected options. Is - either a BreakFileLocksRequest type or a IO type. Default value is None. - :type body: ~azure.mgmt.netapp.models.BreakFileLocksRequest 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. + either a BreakFileLocksRequest type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.netapp.models.BreakFileLocksRequest 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: @@ -1650,7 +1575,7 @@ async def begin_break_file_locks( 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( @@ -1661,28 +1586,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_break_file_locks.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/breakFileLocks" - } - - async def _list_get_group_id_list_for_ldap_user_initial( + async def _list_get_group_id_list_for_ldap_user_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, - body: Union[_models.GetGroupIdListForLDAPUserRequest, IO], + body: Union[_models.GetGroupIdListForLDAPUserRequest, IO[bytes]], **kwargs: Any ) -> Optional[_models.GetGroupIdListForLDAPUserResponse]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1705,7 +1626,7 @@ async def _list_get_group_id_list_for_ldap_user_initial( else: _json = self._serialize.body(body, "GetGroupIdListForLDAPUserRequest") - request = build_list_get_group_id_list_for_ldap_user_request( + _request = build_list_get_group_id_list_for_ldap_user_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -1715,16 +1636,15 @@ async def _list_get_group_id_list_for_ldap_user_initial( content_type=content_type, json=_json, content=_content, - template_url=self._list_get_group_id_list_for_ldap_user_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -1743,16 +1663,12 @@ async def _list_get_group_id_list_for_ldap_user_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _list_get_group_id_list_for_ldap_user_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/getGroupIdListForLdapUser" - } + return deserialized # type: ignore @overload - async def begin_list_get_group_id_list_for_ldap_user( + async def begin_list_get_group_id_list_for_ldap_user( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, @@ -1781,14 +1697,6 @@ async def begin_list_get_group_id_list_for_ldap_user( :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 GetGroupIdListForLDAPUserResponse or the result of cls(response) :rtype: @@ -1797,13 +1705,13 @@ async def begin_list_get_group_id_list_for_ldap_user( """ @overload - async def begin_list_get_group_id_list_for_ldap_user( + async def begin_list_get_group_id_list_for_ldap_user( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1822,18 +1730,10 @@ async def begin_list_get_group_id_list_for_ldap_user( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Returns group Id list for a specific LDAP user. Required. - :type body: IO + :type body: 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 GetGroupIdListForLDAPUserResponse or the result of cls(response) :rtype: @@ -1842,13 +1742,13 @@ async def begin_list_get_group_id_list_for_ldap_user( """ @distributed_trace_async - async def begin_list_get_group_id_list_for_ldap_user( + async def begin_list_get_group_id_list_for_ldap_user( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, - body: Union[_models.GetGroupIdListForLDAPUserRequest, IO], + body: Union[_models.GetGroupIdListForLDAPUserRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.GetGroupIdListForLDAPUserResponse]: """Get Group Id List for LDAP User. @@ -1865,19 +1765,8 @@ async def begin_list_get_group_id_list_for_ldap_user( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Returns group Id list for a specific LDAP user. Is either a - GetGroupIdListForLDAPUserRequest type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.GetGroupIdListForLDAPUserRequest 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. + GetGroupIdListForLDAPUserRequest type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.GetGroupIdListForLDAPUserRequest or IO[bytes] :return: An instance of AsyncLROPoller that returns either GetGroupIdListForLDAPUserResponse or the result of cls(response) :rtype: @@ -1912,7 +1801,7 @@ async def begin_list_get_group_id_list_for_ldap_user( def get_long_running_output(pipeline_response): deserialized = self._deserialize("GetGroupIdListForLDAPUserResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1924,17 +1813,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.GetGroupIdListForLDAPUserResponse].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_list_get_group_id_list_for_ldap_user.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/getGroupIdListForLdapUser" - } + return AsyncLROPoller[_models.GetGroupIdListForLDAPUserResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _break_replication_initial( # pylint: disable=inconsistent-return-statements self, @@ -1942,10 +1829,10 @@ async def _break_replication_initial( # pylint: disable=inconsistent-return-sta account_name: str, pool_name: str, volume_name: str, - body: Optional[Union[_models.BreakReplicationRequest, IO]] = None, + body: Optional[Union[_models.BreakReplicationRequest, IO[bytes]]] = None, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1971,7 +1858,7 @@ async def _break_replication_initial( # pylint: disable=inconsistent-return-sta else: _json = None - request = build_break_replication_request( + _request = build_break_replication_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -1981,16 +1868,15 @@ async def _break_replication_initial( # pylint: disable=inconsistent-return-sta content_type=content_type, json=_json, content=_content, - template_url=self._break_replication_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -2001,11 +1887,7 @@ async def _break_replication_initial( # pylint: disable=inconsistent-return-sta raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _break_replication_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/breakReplication" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def begin_break_replication( @@ -2037,14 +1919,6 @@ async def begin_break_replication( :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: @@ -2057,7 +1931,7 @@ async def begin_break_replication( account_name: str, pool_name: str, volume_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2076,18 +1950,10 @@ async def begin_break_replication( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Optional body to force break the replication. Default value is None. - :type body: IO + :type body: 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: @@ -2100,7 +1966,7 @@ async def begin_break_replication( account_name: str, pool_name: str, volume_name: str, - body: Optional[Union[_models.BreakReplicationRequest, IO]] = None, + body: Optional[Union[_models.BreakReplicationRequest, IO[bytes]]] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Break volume replication. @@ -2117,19 +1983,8 @@ async def begin_break_replication( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Optional body to force break the replication. Is either a BreakReplicationRequest - type or a IO type. Default value is None. - :type body: ~azure.mgmt.netapp.models.BreakReplicationRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.netapp.models.BreakReplicationRequest 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: @@ -2161,7 +2016,7 @@ async def begin_break_replication( 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( @@ -2172,17 +2027,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_break_replication.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/breakReplication" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _reestablish_replication_initial( # pylint: disable=inconsistent-return-statements self, @@ -2190,10 +2041,10 @@ async def _reestablish_replication_initial( # pylint: disable=inconsistent-retu account_name: str, pool_name: str, volume_name: str, - body: Union[_models.ReestablishReplicationRequest, IO], + body: Union[_models.ReestablishReplicationRequest, IO[bytes]], **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2216,7 +2067,7 @@ async def _reestablish_replication_initial( # pylint: disable=inconsistent-retu else: _json = self._serialize.body(body, "ReestablishReplicationRequest") - request = build_reestablish_replication_request( + _request = build_reestablish_replication_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -2226,16 +2077,15 @@ async def _reestablish_replication_initial( # pylint: disable=inconsistent-retu content_type=content_type, json=_json, content=_content, - template_url=self._reestablish_replication_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -2246,11 +2096,7 @@ async def _reestablish_replication_initial( # pylint: disable=inconsistent-retu raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _reestablish_replication_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/reestablishReplication" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def begin_reestablish_replication( @@ -2283,14 +2129,6 @@ async def begin_reestablish_replication( :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: @@ -2303,7 +2141,7 @@ async def begin_reestablish_replication( account_name: str, pool_name: str, volume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2323,18 +2161,10 @@ async def begin_reestablish_replication( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: body for the id of the source volume. Required. - :type body: IO + :type body: 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: @@ -2347,7 +2177,7 @@ async def begin_reestablish_replication( account_name: str, pool_name: str, volume_name: str, - body: Union[_models.ReestablishReplicationRequest, IO], + body: Union[_models.ReestablishReplicationRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[None]: """Re-establish volume replication. @@ -2365,19 +2195,8 @@ async def begin_reestablish_replication( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: body for the id of the source volume. Is either a ReestablishReplicationRequest - type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.ReestablishReplicationRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.ReestablishReplicationRequest 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: @@ -2409,7 +2228,7 @@ async def begin_reestablish_replication( 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( @@ -2420,17 +2239,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_reestablish_replication.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/reestablishReplication" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def replication_status( @@ -2449,12 +2264,11 @@ async def replication_status( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ReplicationStatus or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.ReplicationStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2468,23 +2282,22 @@ async def replication_status( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReplicationStatus] = kwargs.pop("cls", None) - request = build_replication_status_request( + _request = build_replication_status_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.replication_status.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -2497,13 +2310,9 @@ async def replication_status( deserialized = self._deserialize("ReplicationStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - replication_status.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/replicationStatus" - } + return deserialized # type: ignore @distributed_trace def list_replications( @@ -2522,7 +2331,6 @@ def list_replications( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Replication or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.netapp.models.Replication] :raises ~azure.core.exceptions.HttpResponseError: @@ -2533,7 +2341,7 @@ def list_replications( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListReplications] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2544,19 +2352,18 @@ def list_replications( def prepare_request(next_link=None): if not next_link: - request = build_list_replications_request( + _request = build_list_replications_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_replications.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -2568,13 +2375,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListReplications", pipeline_response) @@ -2584,11 +2391,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2601,14 +2408,10 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_replications.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/listReplications" - } - async def _resync_replication_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2622,23 +2425,22 @@ async def _resync_replication_initial( # pylint: disable=inconsistent-return-st api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_resync_replication_request( + _request = build_resync_replication_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._resync_replication_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -2649,11 +2451,7 @@ async def _resync_replication_initial( # pylint: disable=inconsistent-return-st raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _resync_replication_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/resyncReplication" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_resync_replication( @@ -2673,14 +2471,6 @@ async def begin_resync_replication( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -2709,7 +2499,7 @@ async def begin_resync_replication( 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( @@ -2720,22 +2510,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_resync_replication.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/resyncReplication" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _delete_replication_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2749,23 +2535,22 @@ async def _delete_replication_initial( # pylint: disable=inconsistent-return-st 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_replication_request( + _request = build_delete_replication_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_replication_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -2776,11 +2561,7 @@ async def _delete_replication_initial( # pylint: disable=inconsistent-return-st raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_replication_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/deleteReplication" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_delete_replication( @@ -2800,14 +2581,6 @@ async def begin_delete_replication( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -2836,7 +2609,7 @@ async def begin_delete_replication( 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( @@ -2847,17 +2620,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete_replication.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/deleteReplication" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _authorize_replication_initial( # pylint: disable=inconsistent-return-statements self, @@ -2865,10 +2634,10 @@ async def _authorize_replication_initial( # pylint: disable=inconsistent-return account_name: str, pool_name: str, volume_name: str, - body: Union[_models.AuthorizeRequest, IO], + body: Union[_models.AuthorizeRequest, IO[bytes]], **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2891,7 +2660,7 @@ async def _authorize_replication_initial( # pylint: disable=inconsistent-return else: _json = self._serialize.body(body, "AuthorizeRequest") - request = build_authorize_replication_request( + _request = build_authorize_replication_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -2901,16 +2670,15 @@ async def _authorize_replication_initial( # pylint: disable=inconsistent-return content_type=content_type, json=_json, content=_content, - template_url=self._authorize_replication_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -2921,11 +2689,7 @@ async def _authorize_replication_initial( # pylint: disable=inconsistent-return raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _authorize_replication_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/authorizeReplication" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def begin_authorize_replication( @@ -2957,14 +2721,6 @@ async def begin_authorize_replication( :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: @@ -2977,7 +2733,7 @@ async def begin_authorize_replication( account_name: str, pool_name: str, volume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2996,18 +2752,10 @@ async def begin_authorize_replication( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Authorize request object supplied in the body of the operation. Required. - :type body: IO + :type body: 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: @@ -3020,7 +2768,7 @@ async def begin_authorize_replication( account_name: str, pool_name: str, volume_name: str, - body: Union[_models.AuthorizeRequest, IO], + body: Union[_models.AuthorizeRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[None]: """Authorize source volume replication. @@ -3037,19 +2785,8 @@ async def begin_authorize_replication( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Authorize request object supplied in the body of the operation. Is either a - AuthorizeRequest type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.AuthorizeRequest 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. + AuthorizeRequest type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.AuthorizeRequest 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: @@ -3081,7 +2818,7 @@ async def begin_authorize_replication( 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( @@ -3092,22 +2829,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_authorize_replication.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/authorizeReplication" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _re_initialize_replication_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3121,23 +2854,22 @@ async def _re_initialize_replication_initial( # pylint: disable=inconsistent-re api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_re_initialize_replication_request( + _request = build_re_initialize_replication_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._re_initialize_replication_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -3148,11 +2880,7 @@ async def _re_initialize_replication_initial( # pylint: disable=inconsistent-re raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _re_initialize_replication_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/reinitializeReplication" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_re_initialize_replication( @@ -3171,14 +2899,6 @@ async def begin_re_initialize_replication( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -3207,7 +2927,7 @@ async def begin_re_initialize_replication( 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( @@ -3218,28 +2938,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_re_initialize_replication.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/reinitializeReplication" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _pool_change_initial( # pylint: disable=inconsistent-return-statements + async def _peer_cluster_for_on_prem_migration_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, - body: Union[_models.PoolChangeRequest, IO], + body: Union[_models.PeerClusterForVolumeMigrationRequest, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> Optional[_models.ClusterPeerCommandResponse]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3252,7 +2968,7 @@ async def _pool_change_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[Optional[_models.ClusterPeerCommandResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -3260,9 +2976,9 @@ async def _pool_change_initial( # pylint: disable=inconsistent-return-statement if isinstance(body, (IOBase, bytes)): _content = body else: - _json = self._serialize.body(body, "PoolChangeRequest") + _json = self._serialize.body(body, "PeerClusterForVolumeMigrationRequest") - request = build_pool_change_request( + _request = build_peer_cluster_for_on_prem_migration_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -3272,16 +2988,15 @@ async def _pool_change_initial( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, content=_content, - template_url=self._pool_change_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -3291,28 +3006,34 @@ async def _pool_change_initial( # pylint: disable=inconsistent-return-statement 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("ClusterPeerCommandResponse", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _pool_change_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/poolChange" - } + return deserialized # type: ignore @overload - async def begin_pool_change( + async def begin_peer_cluster_for_on_prem_migration( self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, - body: _models.PoolChangeRequest, + body: _models.PeerClusterForVolumeMigrationRequest, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Change pool for volume. + ) -> AsyncLROPoller[_models.ClusterPeerCommandResponse]: + """Start Cluster peering. - Moves volume to another pool. + Starts peering the cluster for this migration volume. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3323,39 +3044,33 @@ async def begin_pool_change( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :param body: Move volume to the pool supplied in the body of the operation. Required. - :type body: ~azure.mgmt.netapp.models.PoolChangeRequest + :param body: Cluster peer request object supplied in the body of the operation. Required. + :type body: ~azure.mgmt.netapp.models.PeerClusterForVolumeMigrationRequest :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] + :return: An instance of AsyncLROPoller that returns either ClusterPeerCommandResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.ClusterPeerCommandResponse] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def begin_pool_change( + async def begin_peer_cluster_for_on_prem_migration( self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[None]: - """Change pool for volume. + ) -> AsyncLROPoller[_models.ClusterPeerCommandResponse]: + """Start Cluster peering. - Moves volume to another pool. + Starts peering the cluster for this migration volume. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3366,37 +3081,31 @@ async def begin_pool_change( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :param body: Move volume to the pool supplied in the body of the operation. Required. - :type body: IO + :param body: Cluster peer request object supplied in the body of the operation. Required. + :type body: 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] + :return: An instance of AsyncLROPoller that returns either ClusterPeerCommandResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.ClusterPeerCommandResponse] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def begin_pool_change( + async def begin_peer_cluster_for_on_prem_migration( self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, - body: Union[_models.PoolChangeRequest, IO], + body: Union[_models.PeerClusterForVolumeMigrationRequest, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[None]: - """Change pool for volume. + ) -> AsyncLROPoller[_models.ClusterPeerCommandResponse]: + """Start Cluster peering. - Moves volume to another pool. + Starts peering the cluster for this migration volume. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3407,22 +3116,13 @@ async def begin_pool_change( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :param body: Move volume to the pool supplied in the body of the operation. Is either a - PoolChangeRequest type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.PoolChangeRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :param body: Cluster peer request object supplied in the body of the operation. Is either a + PeerClusterForVolumeMigrationRequest type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.PeerClusterForVolumeMigrationRequest or IO[bytes] + :return: An instance of AsyncLROPoller that returns either ClusterPeerCommandResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.ClusterPeerCommandResponse] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -3430,12 +3130,12 @@ async def begin_pool_change( 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[_models.ClusterPeerCommandResponse] = 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._pool_change_initial( # type: ignore + raw_result = await self._peer_cluster_for_on_prem_migration_initial( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -3450,9 +3150,11 @@ async def begin_pool_change( ) kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ClusterPeerCommandResponse", pipeline_response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: polling_method: AsyncPollingMethod = cast( @@ -3463,28 +3165,20 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ClusterPeerCommandResponse].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_pool_change.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/poolChange" - } + return AsyncLROPoller[_models.ClusterPeerCommandResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _relocate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - pool_name: str, - volume_name: str, - body: Optional[Union[_models.RelocateVolumeRequest, IO]] = None, - **kwargs: Any - ) -> None: - error_map = { + async def _create_on_prem_migration_replication_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any + ) -> Optional[_models.SvmPeerCommandResponse]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3492,44 +3186,28 @@ async def _relocate_initial( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "RelocateVolumeRequest") - else: - _json = None + cls: ClsType[Optional[_models.SvmPeerCommandResponse]] = kwargs.pop("cls", None) - request = build_relocate_request( + _request = build_create_on_prem_migration_replication_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._relocate_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -3539,28 +3217,27 @@ async def _relocate_initial( # pylint: disable=inconsistent-return-statements 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("SvmPeerCommandResponse", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _relocate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/relocate" - } + return deserialized # type: ignore - @overload - async def begin_relocate( - self, - resource_group_name: str, - account_name: str, - pool_name: str, - volume_name: str, - body: Optional[_models.RelocateVolumeRequest] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Relocate volume. + @distributed_trace_async + async def begin_create_on_prem_migration_replication( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.SvmPeerCommandResponse]: + """Start migration process. - Relocates volume to a new stamp. + Starts SVM peering and returns a command to be run on the external ONTAP to accept it. Once + the SVMs have been peered a SnapMirror will be created. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -3571,32 +3248,601 @@ async def begin_relocate( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :param body: Relocate volume request. Default value is None. - :type body: ~azure.mgmt.netapp.models.RelocateVolumeRequest - :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] + :return: An instance of AsyncLROPoller that returns either SvmPeerCommandResponse or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.netapp.models.SvmPeerCommandResponse] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - @overload - async def begin_relocate( - self, + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SvmPeerCommandResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_on_prem_migration_replication_initial( + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SvmPeerCommandResponse", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SvmPeerCommandResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SvmPeerCommandResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _finalize_on_prem_migration_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_finalize_on_prem_migration_request( + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def begin_finalize_on_prem_migration( + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Finalize migration process. + + Finalizes the migration of a volume by performing a final sync on the replication, breaking and + releasing the replication, and breaking the cluster peering if no other migration is active. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: 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: + """ + _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[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._finalize_on_prem_migration_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _perform_replication_transfer_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_perform_replication_transfer_request( + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def begin_perform_replication_transfer( + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Perform a replication transfer. + + Performs an adhoc replication transfer on a volume with volumeType Migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: 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: + """ + _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[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._perform_replication_transfer_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _pool_change_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: Union[_models.PoolChangeRequest, IO[bytes]], + **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "PoolChangeRequest") + + _request = build_pool_change_request( + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def begin_pool_change( + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: _models.PoolChangeRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Change pool for volume. + + Moves volume to another pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: str + :param body: Move volume to the pool supplied in the body of the operation. Required. + :type body: ~azure.mgmt.netapp.models.PoolChangeRequest + :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_pool_change( + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Change pool for volume. + + Moves volume to another pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: str + :param body: Move volume to the pool supplied in the body of the operation. Required. + :type body: 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_pool_change( + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: Union[_models.PoolChangeRequest, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Change pool for volume. + + Moves volume to another pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: str + :param body: Move volume to the pool supplied in the body of the operation. Is either a + PoolChangeRequest type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.PoolChangeRequest 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 = 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._pool_change_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _relocate_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: Optional[Union[_models.RelocateVolumeRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "RelocateVolumeRequest") + else: + _json = None + + _request = build_relocate_request( + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def begin_relocate( + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: Optional[_models.RelocateVolumeRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Relocate volume. + + Relocates volume to a new stamp. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: str + :param body: Relocate volume request. Default value is None. + :type body: ~azure.mgmt.netapp.models.RelocateVolumeRequest + :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_relocate( + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -3615,18 +3861,10 @@ async def begin_relocate( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Relocate volume request. Default value is None. - :type body: IO + :type body: 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: @@ -3639,7 +3877,7 @@ async def begin_relocate( account_name: str, pool_name: str, volume_name: str, - body: Optional[Union[_models.RelocateVolumeRequest, IO]] = None, + body: Optional[Union[_models.RelocateVolumeRequest, IO[bytes]]] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Relocate volume. @@ -3655,20 +3893,9 @@ async def begin_relocate( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :param body: Relocate volume request. Is either a RelocateVolumeRequest type or a IO type. - Default value is None. - :type body: ~azure.mgmt.netapp.models.RelocateVolumeRequest 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 body: Relocate volume request. Is either a RelocateVolumeRequest type or a IO[bytes] + type. Default value is None. + :type body: ~azure.mgmt.netapp.models.RelocateVolumeRequest 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: @@ -3700,7 +3927,7 @@ async def begin_relocate( 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)) @@ -3709,22 +3936,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_relocate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/relocate" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _finalize_relocation_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3738,23 +3961,22 @@ async def _finalize_relocation_initial( # pylint: disable=inconsistent-return-s api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_finalize_relocation_request( + _request = build_finalize_relocation_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._finalize_relocation_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -3765,11 +3987,7 @@ async def _finalize_relocation_initial( # pylint: disable=inconsistent-return-s raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _finalize_relocation_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/finalizeRelocation" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_finalize_relocation( @@ -3788,14 +4006,6 @@ async def begin_finalize_relocation( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -3824,7 +4034,7 @@ async def begin_finalize_relocation( 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)) @@ -3833,22 +4043,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_finalize_relocation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/finalizeRelocation" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _revert_relocation_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3862,23 +4068,22 @@ async def _revert_relocation_initial( # pylint: disable=inconsistent-return-sta api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revert_relocation_request( + _request = build_revert_relocation_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._revert_relocation_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -3889,11 +4094,7 @@ async def _revert_relocation_initial( # pylint: disable=inconsistent-return-sta raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _revert_relocation_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/revertRelocation" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_revert_relocation( @@ -3913,14 +4114,6 @@ async def begin_revert_relocation( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -3949,7 +4142,7 @@ async def begin_revert_relocation( 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)) @@ -3958,14 +4151,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_revert_relocation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/revertRelocation" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/models/__init__.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/models/__init__.py index 3c9468d61272..d5fc4ba8e08f 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/models/__init__.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/models/__init__.py @@ -9,19 +9,31 @@ from ._models_py3 import AccountEncryption from ._models_py3 import ActiveDirectory from ._models_py3 import AuthorizeRequest +from ._models_py3 import Backup +from ._models_py3 import BackupPatch from ._models_py3 import BackupPoliciesList from ._models_py3 import BackupPolicy from ._models_py3 import BackupPolicyPatch +from ._models_py3 import BackupRestoreFiles +from ._models_py3 import BackupStatus +from ._models_py3 import BackupVault +from ._models_py3 import BackupVaultPatch +from ._models_py3 import BackupVaultsList +from ._models_py3 import BackupsList +from ._models_py3 import BackupsMigrationRequest from ._models_py3 import BreakFileLocksRequest from ._models_py3 import BreakReplicationRequest from ._models_py3 import CapacityPool from ._models_py3 import CapacityPoolList from ._models_py3 import CapacityPoolPatch +from ._models_py3 import ChangeKeyVault from ._models_py3 import CheckAvailabilityResponse from ._models_py3 import CloudErrorBody +from ._models_py3 import ClusterPeerCommandResponse from ._models_py3 import DailySchedule from ._models_py3 import Dimension from ._models_py3 import EncryptionIdentity +from ._models_py3 import EncryptionMigrationRequest from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse @@ -30,6 +42,7 @@ from ._models_py3 import GetGroupIdListForLDAPUserRequest from ._models_py3 import GetGroupIdListForLDAPUserResponse from ._models_py3 import HourlySchedule +from ._models_py3 import KeyVaultPrivateEndpoint from ._models_py3 import KeyVaultProperties from ._models_py3 import LdapSearchScopeOpt from ._models_py3 import ListReplications @@ -47,6 +60,7 @@ from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult +from ._models_py3 import PeerClusterForVolumeMigrationRequest from ._models_py3 import PlacementKeyValuePairs from ._models_py3 import PoolChangeRequest from ._models_py3 import ProxyResource @@ -55,7 +69,10 @@ from ._models_py3 import ReestablishReplicationRequest from ._models_py3 import RegionInfo from ._models_py3 import RegionInfoAvailabilityZoneMappingsItem +from ._models_py3 import RegionInfoResource +from ._models_py3 import RegionInfosList from ._models_py3 import RelocateVolumeRequest +from ._models_py3 import RemotePath from ._models_py3 import Replication from ._models_py3 import ReplicationObject from ._models_py3 import ReplicationStatus @@ -78,11 +95,13 @@ from ._models_py3 import SubvolumeModel from ._models_py3 import SubvolumePatchRequest from ._models_py3 import SubvolumesList +from ._models_py3 import SvmPeerCommandResponse from ._models_py3 import SystemData from ._models_py3 import TrackedResource from ._models_py3 import UpdateNetworkSiblingSetRequest from ._models_py3 import UserAssignedIdentity from ._models_py3 import Volume +from ._models_py3 import VolumeBackupProperties from ._models_py3 import VolumeBackups from ._models_py3 import VolumeGroup from ._models_py3 import VolumeGroupDetails @@ -103,9 +122,11 @@ from ._models_py3 import VolumeSnapshotProperties from ._models_py3 import WeeklySchedule +from ._net_app_management_client_enums import AcceptGrowCapacityPoolForShortTermCloneSplit from ._net_app_management_client_enums import ActiveDirectoryStatus from ._net_app_management_client_enums import ApplicationType from ._net_app_management_client_enums import AvsDataStore +from ._net_app_management_client_enums import BackupType from ._net_app_management_client_enums import CheckNameResourceTypes from ._net_app_management_client_enums import CheckQuotaNameResourceTypes from ._net_app_management_client_enums import ChownMode @@ -134,6 +155,7 @@ from ._net_app_management_client_enums import SmbAccessBasedEnumeration from ._net_app_management_client_enums import SmbNonBrowsable from ._net_app_management_client_enums import Type +from ._net_app_management_client_enums import VolumeLanguage from ._net_app_management_client_enums import VolumeStorageToNetworkProximity from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -143,19 +165,31 @@ "AccountEncryption", "ActiveDirectory", "AuthorizeRequest", + "Backup", + "BackupPatch", "BackupPoliciesList", "BackupPolicy", "BackupPolicyPatch", + "BackupRestoreFiles", + "BackupStatus", + "BackupVault", + "BackupVaultPatch", + "BackupVaultsList", + "BackupsList", + "BackupsMigrationRequest", "BreakFileLocksRequest", "BreakReplicationRequest", "CapacityPool", "CapacityPoolList", "CapacityPoolPatch", + "ChangeKeyVault", "CheckAvailabilityResponse", "CloudErrorBody", + "ClusterPeerCommandResponse", "DailySchedule", "Dimension", "EncryptionIdentity", + "EncryptionMigrationRequest", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", @@ -164,6 +198,7 @@ "GetGroupIdListForLDAPUserRequest", "GetGroupIdListForLDAPUserResponse", "HourlySchedule", + "KeyVaultPrivateEndpoint", "KeyVaultProperties", "LdapSearchScopeOpt", "ListReplications", @@ -181,6 +216,7 @@ "Operation", "OperationDisplay", "OperationListResult", + "PeerClusterForVolumeMigrationRequest", "PlacementKeyValuePairs", "PoolChangeRequest", "ProxyResource", @@ -189,7 +225,10 @@ "ReestablishReplicationRequest", "RegionInfo", "RegionInfoAvailabilityZoneMappingsItem", + "RegionInfoResource", + "RegionInfosList", "RelocateVolumeRequest", + "RemotePath", "Replication", "ReplicationObject", "ReplicationStatus", @@ -212,11 +251,13 @@ "SubvolumeModel", "SubvolumePatchRequest", "SubvolumesList", + "SvmPeerCommandResponse", "SystemData", "TrackedResource", "UpdateNetworkSiblingSetRequest", "UserAssignedIdentity", "Volume", + "VolumeBackupProperties", "VolumeBackups", "VolumeGroup", "VolumeGroupDetails", @@ -236,9 +277,11 @@ "VolumeRevert", "VolumeSnapshotProperties", "WeeklySchedule", + "AcceptGrowCapacityPoolForShortTermCloneSplit", "ActiveDirectoryStatus", "ApplicationType", "AvsDataStore", + "BackupType", "CheckNameResourceTypes", "CheckQuotaNameResourceTypes", "ChownMode", @@ -267,6 +310,7 @@ "SmbAccessBasedEnumeration", "SmbNonBrowsable", "Type", + "VolumeLanguage", "VolumeStorageToNetworkProximity", ] __all__.extend([p for p in _patch_all if p not in __all__]) diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/models/_models_py3.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/models/_models_py3.py index 0998bc5922ea..b38887471d6a 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/models/_models_py3.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/models/_models_py3.py @@ -308,33 +308,55 @@ def __init__(self, *, remote_volume_resource_id: Optional[str] = None, **kwargs: self.remote_volume_resource_id = remote_volume_resource_id -class BackupPoliciesList(_serialization.Model): - """List of Backup Policies. +class Resource(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. - :ivar value: A list of backup policies. - :vartype value: list[~azure.mgmt.netapp.models.BackupPolicy] + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.netapp.models.SystemData """ + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + _attribute_map = { - "value": {"key": "value", "type": "[BackupPolicy]"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__(self, *, value: Optional[List["_models.BackupPolicy"]] = None, **kwargs: Any) -> None: - """ - :keyword value: A list of backup policies. - :paramtype value: list[~azure.mgmt.netapp.models.BackupPolicy] - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.value = value + self.id = None + self.name = None + self.type = None + self.system_data = None -class Resource(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -346,11 +368,69 @@ class Resource(_serialization.Model): :vartype system_data: ~azure.mgmt.netapp.models.SystemData """ + +class Backup(ProxyResource): # pylint: disable=too-many-instance-attributes + """Backup under a 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 server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.netapp.models.SystemData + :ivar backup_id: UUID v4 used to identify the Backup. + :vartype backup_id: str + :ivar creation_date: The creation date of the backup. + :vartype creation_date: ~datetime.datetime + :ivar provisioning_state: Azure lifecycle management. + :vartype provisioning_state: str + :ivar size: Size of backup in bytes. + :vartype size: int + :ivar label: Label for backup. + :vartype label: str + :ivar backup_type: Type of backup Manual or Scheduled. Known values are: "Manual" and + "Scheduled". + :vartype backup_type: str or ~azure.mgmt.netapp.models.BackupType + :ivar failure_reason: Failure reason. + :vartype failure_reason: str + :ivar volume_resource_id: ResourceId used to identify the Volume. Required. + :vartype volume_resource_id: str + :ivar use_existing_snapshot: Manual backup an already existing snapshot. This will always be + false for scheduled backups and true/false for manual backups. + :vartype use_existing_snapshot: bool + :ivar snapshot_name: The name of the snapshot. + :vartype snapshot_name: str + :ivar backup_policy_resource_id: ResourceId used to identify the backup policy. + :vartype backup_policy_resource_id: str + """ + _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, + "backup_id": { + "readonly": True, + "max_length": 36, + "min_length": 36, + "pattern": r"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", + }, + "creation_date": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "size": {"readonly": True}, + "backup_type": {"readonly": True}, + "failure_reason": {"readonly": True}, + "volume_resource_id": {"required": True}, + "backup_policy_resource_id": {"readonly": True}, } _attribute_map = { @@ -358,15 +438,91 @@ class Resource(_serialization.Model): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, + "backup_id": {"key": "properties.backupId", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "size": {"key": "properties.size", "type": "int"}, + "label": {"key": "properties.label", "type": "str"}, + "backup_type": {"key": "properties.backupType", "type": "str"}, + "failure_reason": {"key": "properties.failureReason", "type": "str"}, + "volume_resource_id": {"key": "properties.volumeResourceId", "type": "str"}, + "use_existing_snapshot": {"key": "properties.useExistingSnapshot", "type": "bool"}, + "snapshot_name": {"key": "properties.snapshotName", "type": "str"}, + "backup_policy_resource_id": {"key": "properties.backupPolicyResourceId", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, + *, + volume_resource_id: str, + label: Optional[str] = None, + use_existing_snapshot: bool = False, + snapshot_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword label: Label for backup. + :paramtype label: str + :keyword volume_resource_id: ResourceId used to identify the Volume. Required. + :paramtype volume_resource_id: str + :keyword use_existing_snapshot: Manual backup an already existing snapshot. This will always be + false for scheduled backups and true/false for manual backups. + :paramtype use_existing_snapshot: bool + :keyword snapshot_name: The name of the snapshot. + :paramtype snapshot_name: str + """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None + self.backup_id = None + self.creation_date = None + self.provisioning_state = None + self.size = None + self.label = label + self.backup_type = None + self.failure_reason = None + self.volume_resource_id = volume_resource_id + self.use_existing_snapshot = use_existing_snapshot + self.snapshot_name = snapshot_name + self.backup_policy_resource_id = None + + +class BackupPatch(_serialization.Model): + """Backup patch. + + :ivar label: Label for backup. + :vartype label: str + """ + + _attribute_map = { + "label": {"key": "properties.label", "type": "str"}, + } + + def __init__(self, *, label: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword label: Label for backup. + :paramtype label: str + """ + super().__init__(**kwargs) + self.label = label + + +class BackupPoliciesList(_serialization.Model): + """List of Backup Policies. + + :ivar value: A list of backup policies. + :vartype value: list[~azure.mgmt.netapp.models.BackupPolicy] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[BackupPolicy]"}, + } + + def __init__(self, *, value: Optional[List["_models.BackupPolicy"]] = None, **kwargs: Any) -> None: + """ + :keyword value: A list of backup policies. + :paramtype value: list[~azure.mgmt.netapp.models.BackupPolicy] + """ + super().__init__(**kwargs) + self.value = value class TrackedResource(Resource): @@ -375,10 +531,10 @@ class TrackedResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -428,10 +584,10 @@ class BackupPolicy(TrackedResource): # pylint: disable=too-many-instance-attrib Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -633,6 +789,283 @@ def __init__( self.volume_backups = None +class BackupRestoreFiles(_serialization.Model): + """Restore payload for Single File Backup Restore. + + All required parameters must be populated in order to send to server. + + :ivar file_list: List of files to be restored. Required. + :vartype file_list: list[str] + :ivar restore_file_path: Destination folder where the files will be restored. The path name + should start with a forward slash. If it is omitted from request then restore is done at the + root folder of the destination volume by default. + :vartype restore_file_path: str + :ivar destination_volume_id: Resource Id of the destination volume on which the files need to + be restored. Required. + :vartype destination_volume_id: str + """ + + _validation = { + "file_list": {"required": True, "max_items": 8, "min_items": 1}, + "restore_file_path": {"pattern": r"^\/.*$"}, + "destination_volume_id": {"required": True}, + } + + _attribute_map = { + "file_list": {"key": "fileList", "type": "[str]"}, + "restore_file_path": {"key": "restoreFilePath", "type": "str"}, + "destination_volume_id": {"key": "destinationVolumeId", "type": "str"}, + } + + def __init__( + self, + *, + file_list: List[str], + destination_volume_id: str, + restore_file_path: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword file_list: List of files to be restored. Required. + :paramtype file_list: list[str] + :keyword restore_file_path: Destination folder where the files will be restored. The path name + should start with a forward slash. If it is omitted from request then restore is done at the + root folder of the destination volume by default. + :paramtype restore_file_path: str + :keyword destination_volume_id: Resource Id of the destination volume on which the files need + to be restored. Required. + :paramtype destination_volume_id: str + """ + super().__init__(**kwargs) + self.file_list = file_list + self.restore_file_path = restore_file_path + self.destination_volume_id = destination_volume_id + + +class BackupsList(_serialization.Model): + """List of Backups. + + :ivar value: A list of Backups. + :vartype value: list[~azure.mgmt.netapp.models.Backup] + :ivar next_link: URL to get the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Backup]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.Backup"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: A list of Backups. + :paramtype value: list[~azure.mgmt.netapp.models.Backup] + :keyword next_link: URL to get the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BackupsMigrationRequest(_serialization.Model): + """Migrate Backups Request. + + All required parameters must be populated in order to send to server. + + :ivar backup_vault_id: The ResourceId of the Backup Vault. Required. + :vartype backup_vault_id: str + """ + + _validation = { + "backup_vault_id": {"required": True}, + } + + _attribute_map = { + "backup_vault_id": {"key": "backupVaultId", "type": "str"}, + } + + def __init__(self, *, backup_vault_id: str, **kwargs: Any) -> None: + """ + :keyword backup_vault_id: The ResourceId of the Backup Vault. Required. + :paramtype backup_vault_id: str + """ + super().__init__(**kwargs) + self.backup_vault_id = backup_vault_id + + +class BackupStatus(_serialization.Model): + """Backup status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar healthy: Backup health status. + :vartype healthy: bool + :ivar relationship_status: Status of the backup mirror relationship. Known values are: "Idle", + "Transferring", "Failed", and "Unknown". + :vartype relationship_status: str or ~azure.mgmt.netapp.models.RelationshipStatus + :ivar mirror_state: The status of the backup. Known values are: "Uninitialized", "Mirrored", + and "Broken". + :vartype mirror_state: str or ~azure.mgmt.netapp.models.MirrorState + :ivar unhealthy_reason: Reason for the unhealthy backup relationship. + :vartype unhealthy_reason: str + :ivar error_message: Displays error message if the backup is in an error state. + :vartype error_message: str + :ivar last_transfer_size: Displays the last transfer size. + :vartype last_transfer_size: int + :ivar last_transfer_type: Displays the last transfer type. + :vartype last_transfer_type: str + :ivar total_transfer_bytes: Displays the total bytes transferred. + :vartype total_transfer_bytes: int + :ivar transfer_progress_bytes: Displays the total number of bytes transferred for the ongoing + operation. + :vartype transfer_progress_bytes: int + """ + + _validation = { + "healthy": {"readonly": True}, + "relationship_status": {"readonly": True}, + "mirror_state": {"readonly": True}, + "unhealthy_reason": {"readonly": True}, + "error_message": {"readonly": True}, + "last_transfer_size": {"readonly": True}, + "last_transfer_type": {"readonly": True}, + "total_transfer_bytes": {"readonly": True}, + "transfer_progress_bytes": {"readonly": True}, + } + + _attribute_map = { + "healthy": {"key": "healthy", "type": "bool"}, + "relationship_status": {"key": "relationshipStatus", "type": "str"}, + "mirror_state": {"key": "mirrorState", "type": "str"}, + "unhealthy_reason": {"key": "unhealthyReason", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + "last_transfer_size": {"key": "lastTransferSize", "type": "int"}, + "last_transfer_type": {"key": "lastTransferType", "type": "str"}, + "total_transfer_bytes": {"key": "totalTransferBytes", "type": "int"}, + "transfer_progress_bytes": {"key": "transferProgressBytes", "type": "int"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.healthy = None + self.relationship_status = None + self.mirror_state = None + self.unhealthy_reason = None + self.error_message = None + self.last_transfer_size = None + self.last_transfer_type = None + self.total_transfer_bytes = None + self.transfer_progress_bytes = None + + +class BackupVault(TrackedResource): + """Backup Vault information. + + 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 server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.netapp.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar provisioning_state: Azure lifecycle management. + :vartype provisioning_state: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(tags=tags, location=location, **kwargs) + self.provisioning_state = None + + +class BackupVaultPatch(_serialization.Model): + """Backup Vault information. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class BackupVaultsList(_serialization.Model): + """List of Backup Vaults. + + :ivar value: A list of Backup Vaults. + :vartype value: list[~azure.mgmt.netapp.models.BackupVault] + :ivar next_link: URL to get the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[BackupVault]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.BackupVault"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: A list of Backup Vaults. + :paramtype value: list[~azure.mgmt.netapp.models.BackupVault] + :keyword next_link: URL to get the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + class BreakFileLocksRequest(_serialization.Model): """Break file locks request. @@ -696,10 +1129,10 @@ class CapacityPool(TrackedResource): # pylint: disable=too-many-instance-attrib Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -718,7 +1151,7 @@ class CapacityPool(TrackedResource): # pylint: disable=too-many-instance-attrib :ivar pool_id: UUID v4 used to identify the Pool. :vartype pool_id: str :ivar size: Provisioned size of the pool (in bytes). Allowed values are in 1TiB chunks (value - must be multiply of 4398046511104). + must be multiply of 1099511627776). :vartype size: int :ivar service_level: The service level of the file system. Known values are: "Standard", "Premium", "Ultra", and "StandardZRS". @@ -796,7 +1229,7 @@ def __init__( :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword size: Provisioned size of the pool (in bytes). Allowed values are in 1TiB chunks - (value must be multiply of 4398046511104). + (value must be multiply of 1099511627776). :paramtype size: int :keyword service_level: The service level of the file system. Known values are: "Standard", "Premium", "Ultra", and "StandardZRS". @@ -926,6 +1359,69 @@ def __init__( self.cool_access = cool_access +class ChangeKeyVault(_serialization.Model): + """Change key vault request. + + All required parameters must be populated in order to send to server. + + :ivar key_vault_uri: The URI of the key vault/managed HSM that should be used for encryption. + Required. + :vartype key_vault_uri: str + :ivar key_name: The name of the key that should be used for encryption. Required. + :vartype key_name: str + :ivar key_vault_resource_id: Azure resource ID of the key vault/managed HSM that should be used + for encryption. Required. + :vartype key_vault_resource_id: str + :ivar key_vault_private_endpoints: Pairs of virtual network ID and private endpoint ID. Every + virtual network that has volumes encrypted with customer-managed keys needs its own key vault + private endpoint. Required. + :vartype key_vault_private_endpoints: list[~azure.mgmt.netapp.models.KeyVaultPrivateEndpoint] + """ + + _validation = { + "key_vault_uri": {"required": True}, + "key_name": {"required": True}, + "key_vault_resource_id": {"required": True}, + "key_vault_private_endpoints": {"required": True}, + } + + _attribute_map = { + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, + "key_name": {"key": "keyName", "type": "str"}, + "key_vault_resource_id": {"key": "keyVaultResourceId", "type": "str"}, + "key_vault_private_endpoints": {"key": "keyVaultPrivateEndpoints", "type": "[KeyVaultPrivateEndpoint]"}, + } + + def __init__( + self, + *, + key_vault_uri: str, + key_name: str, + key_vault_resource_id: str, + key_vault_private_endpoints: List["_models.KeyVaultPrivateEndpoint"], + **kwargs: Any + ) -> None: + """ + :keyword key_vault_uri: The URI of the key vault/managed HSM that should be used for + encryption. Required. + :paramtype key_vault_uri: str + :keyword key_name: The name of the key that should be used for encryption. Required. + :paramtype key_name: str + :keyword key_vault_resource_id: Azure resource ID of the key vault/managed HSM that should be + used for encryption. Required. + :paramtype key_vault_resource_id: str + :keyword key_vault_private_endpoints: Pairs of virtual network ID and private endpoint ID. + Every virtual network that has volumes encrypted with customer-managed keys needs its own key + vault private endpoint. Required. + :paramtype key_vault_private_endpoints: list[~azure.mgmt.netapp.models.KeyVaultPrivateEndpoint] + """ + super().__init__(**kwargs) + self.key_vault_uri = key_vault_uri + self.key_name = key_name + self.key_vault_resource_id = key_vault_resource_id + self.key_vault_private_endpoints = key_vault_private_endpoints + + class CheckAvailabilityResponse(_serialization.Model): """Information regarding availability of a resource. @@ -993,18 +1489,42 @@ class CloudErrorBody(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + """ + super().__init__(**kwargs) + self.code = code + self.message = message + + +class ClusterPeerCommandResponse(_serialization.Model): + """Information about cluster peering process. + + :ivar peer_accept_command: A command that needs to be run on the external ONTAP to accept + cluster peering. Will only be present if :code:`clusterPeeringStatus` is + :code:`pending`. + :vartype peer_accept_command: str + """ + + _attribute_map = { + "peer_accept_command": {"key": "peerAcceptCommand", "type": "str"}, + } + + def __init__(self, *, peer_accept_command: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :paramtype code: str - :keyword message: A message describing the error, intended to be suitable for display in a user - interface. - :paramtype message: str + :keyword peer_accept_command: A command that needs to be run on the external ONTAP to accept + cluster peering. Will only be present if :code:`clusterPeeringStatus` is + :code:`pending`. + :paramtype peer_accept_command: str """ super().__init__(**kwargs) - self.code = code - self.message = message + self.peer_accept_command = peer_accept_command class DailySchedule(_serialization.Model): @@ -1114,6 +1634,41 @@ def __init__(self, *, user_assigned_identity: Optional[str] = None, **kwargs: An self.user_assigned_identity = user_assigned_identity +class EncryptionMigrationRequest(_serialization.Model): + """Encryption migration request. + + All required parameters must be populated in order to send to server. + + :ivar virtual_network_id: Identifier for the virtual network. Required. + :vartype virtual_network_id: str + :ivar private_endpoint_id: Identifier of the private endpoint to reach the Azure Key Vault. + Required. + :vartype private_endpoint_id: str + """ + + _validation = { + "virtual_network_id": {"required": True}, + "private_endpoint_id": {"required": True}, + } + + _attribute_map = { + "virtual_network_id": {"key": "virtualNetworkId", "type": "str"}, + "private_endpoint_id": {"key": "privateEndpointId", "type": "str"}, + } + + def __init__(self, *, virtual_network_id: str, private_endpoint_id: str, **kwargs: Any) -> None: + """ + :keyword virtual_network_id: Identifier for the virtual network. Required. + :paramtype virtual_network_id: str + :keyword private_endpoint_id: Identifier of the private endpoint to reach the Azure Key Vault. + Required. + :paramtype private_endpoint_id: str + """ + super().__init__(**kwargs) + self.virtual_network_id = virtual_network_id + self.private_endpoint_id = private_endpoint_id + + class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. @@ -1351,13 +1906,17 @@ def __init__( class FilePathAvailabilityRequest(_serialization.Model): """File path availability request content - availability is based on the name and the subnetId. - 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: File path to verify. Required. :vartype name: str :ivar subnet_id: The Azure Resource URI for a delegated subnet. Must have the delegation Microsoft.NetApp/volumes. Required. :vartype subnet_id: str + :ivar availability_zone: The Azure Resource logical availability zone which is used within zone + mapping lookup for the subscription and region. The lookup will retrieve the physical zone + where volume is placed. + :vartype availability_zone: str """ _validation = { @@ -1368,25 +1927,31 @@ class FilePathAvailabilityRequest(_serialization.Model): _attribute_map = { "name": {"key": "name", "type": "str"}, "subnet_id": {"key": "subnetId", "type": "str"}, + "availability_zone": {"key": "availabilityZone", "type": "str"}, } - def __init__(self, *, name: str, subnet_id: str, **kwargs: Any) -> None: + def __init__(self, *, name: str, subnet_id: str, availability_zone: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: File path to verify. Required. :paramtype name: str :keyword subnet_id: The Azure Resource URI for a delegated subnet. Must have the delegation Microsoft.NetApp/volumes. Required. :paramtype subnet_id: str + :keyword availability_zone: The Azure Resource logical availability zone which is used within + zone mapping lookup for the subscription and region. The lookup will retrieve the physical zone + where volume is placed. + :paramtype availability_zone: str """ super().__init__(**kwargs) self.name = name self.subnet_id = subnet_id + self.availability_zone = availability_zone class GetGroupIdListForLDAPUserRequest(_serialization.Model): """Get group Id list for LDAP User 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 username: username is required to fetch the group to which user is part of. Required. :vartype username: str @@ -1468,12 +2033,41 @@ def __init__( self.used_bytes = used_bytes +class KeyVaultPrivateEndpoint(_serialization.Model): + """Pairs of virtual network ID and private endpoint ID. Every virtual network that has volumes + encrypted with customer-managed keys needs its own key vault private endpoint. + + :ivar virtual_network_id: Identifier for the virtual network id. + :vartype virtual_network_id: str + :ivar private_endpoint_id: Identifier of the private endpoint to reach the Azure Key Vault. + :vartype private_endpoint_id: str + """ + + _attribute_map = { + "virtual_network_id": {"key": "virtualNetworkId", "type": "str"}, + "private_endpoint_id": {"key": "privateEndpointId", "type": "str"}, + } + + def __init__( + self, *, virtual_network_id: Optional[str] = None, private_endpoint_id: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword virtual_network_id: Identifier for the virtual network id. + :paramtype virtual_network_id: str + :keyword private_endpoint_id: Identifier of the private endpoint to reach the Azure Key Vault. + :paramtype private_endpoint_id: str + """ + super().__init__(**kwargs) + self.virtual_network_id = virtual_network_id + self.private_endpoint_id = private_endpoint_id + + class KeyVaultProperties(_serialization.Model): """Properties of key 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 key_vault_id: UUID v4 used to identify the Azure Key Vault configuration. :vartype key_vault_id: str @@ -1624,7 +2218,7 @@ class ManagedServiceIdentity(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar principal_id: The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. @@ -1638,7 +2232,7 @@ class ManagedServiceIdentity(_serialization.Model): :vartype type: str or ~azure.mgmt.netapp.models.ManagedServiceIdentityType :ivar user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long The dictionary values can be empty objects ({}) in requests. :vartype user_assigned_identities: dict[str, ~azure.mgmt.netapp.models.UserAssignedIdentity] """ @@ -1670,7 +2264,7 @@ def __init__( :paramtype type: str or ~azure.mgmt.netapp.models.ManagedServiceIdentityType :keyword user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long The dictionary values can be empty objects ({}) in requests. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.netapp.models.UserAssignedIdentity] """ @@ -1874,7 +2468,7 @@ class MountTarget(_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 location: Resource location. Required. :vartype location: str @@ -1964,7 +2558,7 @@ class MountTargetProperties(_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 mount_target_id: UUID v4 used to identify the MountTarget. :vartype mount_target_id: str @@ -2018,10 +2612,10 @@ class NetAppAccount(TrackedResource): # pylint: disable=too-many-instance-attri Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -2048,6 +2642,11 @@ class NetAppAccount(TrackedResource): # pylint: disable=too-many-instance-attri :ivar disable_showmount: Shows the status of disableShowmount for all volumes under the subscription, null equals false. :vartype disable_showmount: bool + :ivar nfs_v4_id_domain: Domain for NFSv4 user ID mapping. This property will be set for all + NetApp accounts in the subscription and region and only affect non ldap NFSv4 volumes. + :vartype nfs_v4_id_domain: str + :ivar is_multi_ad_enabled: This will have true value only if account is Multiple AD enabled. + :vartype is_multi_ad_enabled: bool """ _validation = { @@ -2059,6 +2658,8 @@ class NetAppAccount(TrackedResource): # pylint: disable=too-many-instance-attri "etag": {"readonly": True}, "provisioning_state": {"readonly": True}, "disable_showmount": {"readonly": True}, + "nfs_v4_id_domain": {"max_length": 255, "pattern": r"^[a-zA-Z0-9][a-zA-Z0-9.-]{0,253}[a-zA-Z0-9]$"}, + "is_multi_ad_enabled": {"readonly": True}, } _attribute_map = { @@ -2074,6 +2675,8 @@ class NetAppAccount(TrackedResource): # pylint: disable=too-many-instance-attri "active_directories": {"key": "properties.activeDirectories", "type": "[ActiveDirectory]"}, "encryption": {"key": "properties.encryption", "type": "AccountEncryption"}, "disable_showmount": {"key": "properties.disableShowmount", "type": "bool"}, + "nfs_v4_id_domain": {"key": "properties.nfsV4IDDomain", "type": "str"}, + "is_multi_ad_enabled": {"key": "properties.isMultiAdEnabled", "type": "bool"}, } def __init__( @@ -2084,6 +2687,7 @@ def __init__( identity: Optional["_models.ManagedServiceIdentity"] = None, active_directories: Optional[List["_models.ActiveDirectory"]] = None, encryption: Optional["_models.AccountEncryption"] = None, + nfs_v4_id_domain: Optional[str] = None, **kwargs: Any ) -> None: """ @@ -2097,6 +2701,9 @@ def __init__( :paramtype active_directories: list[~azure.mgmt.netapp.models.ActiveDirectory] :keyword encryption: Encryption settings. :paramtype encryption: ~azure.mgmt.netapp.models.AccountEncryption + :keyword nfs_v4_id_domain: Domain for NFSv4 user ID mapping. This property will be set for all + NetApp accounts in the subscription and region and only affect non ldap NFSv4 volumes. + :paramtype nfs_v4_id_domain: str """ super().__init__(tags=tags, location=location, **kwargs) self.etag = None @@ -2105,6 +2712,8 @@ def __init__( self.active_directories = active_directories self.encryption = encryption self.disable_showmount = None + self.nfs_v4_id_domain = nfs_v4_id_domain + self.is_multi_ad_enabled = None class NetAppAccountList(_serialization.Model): @@ -2135,7 +2744,7 @@ def __init__( self.next_link = next_link -class NetAppAccountPatch(_serialization.Model): +class NetAppAccountPatch(_serialization.Model): # pylint: disable=too-many-instance-attributes """NetApp account patch resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2161,6 +2770,11 @@ class NetAppAccountPatch(_serialization.Model): :ivar disable_showmount: Shows the status of disableShowmount for all volumes under the subscription, null equals false. :vartype disable_showmount: bool + :ivar nfs_v4_id_domain: Domain for NFSv4 user ID mapping. This property will be set for all + NetApp accounts in the subscription and region and only affect non ldap NFSv4 volumes. + :vartype nfs_v4_id_domain: str + :ivar is_multi_ad_enabled: This will have true value only if account is Multiple AD enabled. + :vartype is_multi_ad_enabled: bool """ _validation = { @@ -2169,6 +2783,8 @@ class NetAppAccountPatch(_serialization.Model): "type": {"readonly": True}, "provisioning_state": {"readonly": True}, "disable_showmount": {"readonly": True}, + "nfs_v4_id_domain": {"max_length": 255, "pattern": r"^[a-zA-Z0-9][a-zA-Z0-9.-]{0,253}[a-zA-Z0-9]$"}, + "is_multi_ad_enabled": {"readonly": True}, } _attribute_map = { @@ -2182,6 +2798,8 @@ class NetAppAccountPatch(_serialization.Model): "active_directories": {"key": "properties.activeDirectories", "type": "[ActiveDirectory]"}, "encryption": {"key": "properties.encryption", "type": "AccountEncryption"}, "disable_showmount": {"key": "properties.disableShowmount", "type": "bool"}, + "nfs_v4_id_domain": {"key": "properties.nfsV4IDDomain", "type": "str"}, + "is_multi_ad_enabled": {"key": "properties.isMultiAdEnabled", "type": "bool"}, } def __init__( @@ -2192,6 +2810,7 @@ def __init__( identity: Optional["_models.ManagedServiceIdentity"] = None, active_directories: Optional[List["_models.ActiveDirectory"]] = None, encryption: Optional["_models.AccountEncryption"] = None, + nfs_v4_id_domain: Optional[str] = None, **kwargs: Any ) -> None: """ @@ -2205,6 +2824,9 @@ def __init__( :paramtype active_directories: list[~azure.mgmt.netapp.models.ActiveDirectory] :keyword encryption: Encryption settings. :paramtype encryption: ~azure.mgmt.netapp.models.AccountEncryption + :keyword nfs_v4_id_domain: Domain for NFSv4 user ID mapping. This property will be set for all + NetApp accounts in the subscription and region and only affect non ldap NFSv4 volumes. + :paramtype nfs_v4_id_domain: str """ super().__init__(**kwargs) self.location = location @@ -2217,6 +2839,8 @@ def __init__( self.active_directories = active_directories self.encryption = encryption self.disable_showmount = None + self.nfs_v4_id_domain = nfs_v4_id_domain + self.is_multi_ad_enabled = None class NetworkSiblingSet(_serialization.Model): @@ -2229,7 +2853,7 @@ class NetworkSiblingSet(_serialization.Model): :vartype network_sibling_set_id: str :ivar subnet_id: The Azure Resource URI for a delegated subnet. Must have the delegation Microsoft.NetApp/volumes. Example - /subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/{mySubnet}. + /subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/{mySubnet}. # pylint: disable=line-too-long :vartype subnet_id: str :ivar network_sibling_set_state_id: Network sibling set state Id identifying the current state of the sibling set. @@ -2279,7 +2903,7 @@ def __init__( :paramtype network_sibling_set_id: str :keyword subnet_id: The Azure Resource URI for a delegated subnet. Must have the delegation Microsoft.NetApp/volumes. Example - /subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/{mySubnet}. + /subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/{mySubnet}. # pylint: disable=line-too-long :paramtype subnet_id: str :keyword network_sibling_set_state_id: Network sibling set state Id identifying the current state of the sibling set. @@ -2442,10 +3066,48 @@ def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwarg self.value = value +class PeerClusterForVolumeMigrationRequest(_serialization.Model): + """Source cluster properties for a cluster peer request. + + All required parameters must be populated in order to send to server. + + :ivar peer_addresses: A list of IC-LIF IPs that can be used to connect to the on-prem cluster. + Required. + :vartype peer_addresses: list[str] + :ivar remote_path: The full path to a volume that is to be migrated into ANF. Required for + Migration volumes. + :vartype remote_path: ~azure.mgmt.netapp.models.RemotePath + """ + + _validation = { + "peer_addresses": {"required": True, "min_items": 1}, + } + + _attribute_map = { + "peer_addresses": {"key": "peerAddresses", "type": "[str]"}, + "remote_path": {"key": "remotePath", "type": "RemotePath"}, + } + + def __init__( + self, *, peer_addresses: List[str], remote_path: Optional["_models.RemotePath"] = None, **kwargs: Any + ) -> None: + """ + :keyword peer_addresses: A list of IC-LIF IPs that can be used to connect to the on-prem + cluster. Required. + :paramtype peer_addresses: list[str] + :keyword remote_path: The full path to a volume that is to be migrated into ANF. Required for + Migration volumes. + :paramtype remote_path: ~azure.mgmt.netapp.models.RemotePath + """ + super().__init__(**kwargs) + self.peer_addresses = peer_addresses + self.remote_path = remote_path + + class PlacementKeyValuePairs(_serialization.Model): """Application specific parameters for the placement of volumes in the volume group. - 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 key: Key for an application specific parameter for the placement of volumes in the volume group. Required. @@ -2482,7 +3144,7 @@ def __init__(self, *, key: str, value: str, **kwargs: Any) -> None: class PoolChangeRequest(_serialization.Model): """Pool change 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 new_pool_resource_id: Resource id of the pool to move volume to. Required. :vartype new_pool_resource_id: str @@ -2505,55 +3167,17 @@ def __init__(self, *, new_pool_resource_id: str, **kwargs: Any) -> None: self.new_pool_resource_id = new_pool_resource_id -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have - tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.netapp.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - - class QueryNetworkSiblingSetRequest(_serialization.Model): """Network sibling set query. - 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 network_sibling_set_id: Network Sibling Set ID for a group of volumes sharing networking resources in a subnet. Required. :vartype network_sibling_set_id: str :ivar subnet_id: The Azure Resource URI for a delegated subnet. Must have the delegation Microsoft.NetApp/volumes. Example - /subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/{mySubnet}. + /subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/{mySubnet}. # pylint: disable=line-too-long Required. :vartype subnet_id: str """ @@ -2580,7 +3204,7 @@ def __init__(self, *, network_sibling_set_id: str, subnet_id: str, **kwargs: Any :paramtype network_sibling_set_id: str :keyword subnet_id: The Azure Resource URI for a delegated subnet. Must have the delegation Microsoft.NetApp/volumes. Example - /subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/{mySubnet}. + /subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/{mySubnet}. # pylint: disable=line-too-long Required. :paramtype subnet_id: str """ @@ -2592,7 +3216,7 @@ def __init__(self, *, network_sibling_set_id: str, subnet_id: str, **kwargs: Any class QuotaAvailabilityRequest(_serialization.Model): """Quota availability request content. - 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: Name of the resource to verify. Required. :vartype name: str @@ -2730,6 +3354,107 @@ def __init__( self.is_available = is_available +class RegionInfoResource(ProxyResource): + """Information regarding regionInfo Item. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.netapp.models.SystemData + :ivar storage_to_network_proximity: Provides storage to network proximity information in the + region. Known values are: "Default", "T1", "T2", "AcrossT2", "T1AndT2", "T1AndAcrossT2", + "T2AndAcrossT2", and "T1AndT2AndAcrossT2". + :vartype storage_to_network_proximity: str or + ~azure.mgmt.netapp.models.RegionStorageToNetworkProximity + :ivar availability_zone_mappings: Provides logical availability zone mappings for the + subscription for a region. + :vartype availability_zone_mappings: + list[~azure.mgmt.netapp.models.RegionInfoAvailabilityZoneMappingsItem] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "storage_to_network_proximity": {"key": "properties.storageToNetworkProximity", "type": "str"}, + "availability_zone_mappings": { + "key": "properties.availabilityZoneMappings", + "type": "[RegionInfoAvailabilityZoneMappingsItem]", + }, + } + + def __init__( + self, + *, + storage_to_network_proximity: Optional[Union[str, "_models.RegionStorageToNetworkProximity"]] = None, + availability_zone_mappings: Optional[List["_models.RegionInfoAvailabilityZoneMappingsItem"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword storage_to_network_proximity: Provides storage to network proximity information in the + region. Known values are: "Default", "T1", "T2", "AcrossT2", "T1AndT2", "T1AndAcrossT2", + "T2AndAcrossT2", and "T1AndT2AndAcrossT2". + :paramtype storage_to_network_proximity: str or + ~azure.mgmt.netapp.models.RegionStorageToNetworkProximity + :keyword availability_zone_mappings: Provides logical availability zone mappings for the + subscription for a region. + :paramtype availability_zone_mappings: + list[~azure.mgmt.netapp.models.RegionInfoAvailabilityZoneMappingsItem] + """ + super().__init__(**kwargs) + self.storage_to_network_proximity = storage_to_network_proximity + self.availability_zone_mappings = availability_zone_mappings + + +class RegionInfosList(_serialization.Model): + """List of regionInfo resources. + + :ivar value: A list of regionInfo resources. + :vartype value: list[~azure.mgmt.netapp.models.RegionInfoResource] + :ivar next_link: URL to get the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[RegionInfoResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.RegionInfoResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: A list of regionInfo resources. + :paramtype value: list[~azure.mgmt.netapp.models.RegionInfoResource] + :keyword next_link: URL to get the next set of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + class RelocateVolumeRequest(_serialization.Model): """Relocate volume request. @@ -2750,11 +3475,55 @@ def __init__(self, *, creation_token: Optional[str] = None, **kwargs: Any) -> No self.creation_token = creation_token +class RemotePath(_serialization.Model): + """The full path to a volume that is to be migrated into ANF. Required for Migration volumes. + + All required parameters must be populated in order to send to server. + + :ivar external_host_name: The Path to a ONTAP Host. Required. + :vartype external_host_name: str + :ivar server_name: The name of a server on the ONTAP Host. Required. + :vartype server_name: str + :ivar volume_name: The name of a volume on the server. Required. + :vartype volume_name: str + """ + + _validation = { + "external_host_name": {"required": True}, + "server_name": {"required": True}, + "volume_name": {"required": True}, + } + + _attribute_map = { + "external_host_name": {"key": "externalHostName", "type": "str"}, + "server_name": {"key": "serverName", "type": "str"}, + "volume_name": {"key": "volumeName", "type": "str"}, + } + + def __init__(self, *, external_host_name: str, server_name: str, volume_name: str, **kwargs: Any) -> None: + """ + :keyword external_host_name: The Path to a ONTAP Host. Required. + :paramtype external_host_name: str + :keyword server_name: The name of a server on the ONTAP Host. Required. + :paramtype server_name: str + :keyword volume_name: The name of a volume on the server. Required. + :paramtype volume_name: str + """ + super().__init__(**kwargs) + self.external_host_name = external_host_name + self.server_name = server_name + self.volume_name = volume_name + + class Replication(_serialization.Model): """Replication properties. - All required parameters must be populated in order to send to Azure. + 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 server. + :ivar replication_id: UUID v4 used to identify the replication. + :vartype replication_id: str :ivar endpoint_type: Indicates whether the local volume is the source or destination for the Volume Replication. Known values are: "src" and "dst". :vartype endpoint_type: str or ~azure.mgmt.netapp.models.EndpointType @@ -2767,10 +3536,17 @@ class Replication(_serialization.Model): """ _validation = { + "replication_id": { + "readonly": True, + "max_length": 36, + "min_length": 36, + "pattern": r"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", + }, "remote_volume_resource_id": {"required": True}, } _attribute_map = { + "replication_id": {"key": "replicationId", "type": "str"}, "endpoint_type": {"key": "endpointType", "type": "str"}, "replication_schedule": {"key": "replicationSchedule", "type": "str"}, "remote_volume_resource_id": {"key": "remoteVolumeResourceId", "type": "str"}, @@ -2799,6 +3575,7 @@ def __init__( :paramtype remote_volume_region: str """ super().__init__(**kwargs) + self.replication_id = None self.endpoint_type = endpoint_type self.replication_schedule = replication_schedule self.remote_volume_resource_id = remote_volume_resource_id @@ -2810,7 +3587,7 @@ class ReplicationObject(_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 replication_id: Id. :vartype replication_id: str @@ -2819,8 +3596,12 @@ class ReplicationObject(_serialization.Model): :vartype endpoint_type: str or ~azure.mgmt.netapp.models.EndpointType :ivar replication_schedule: Schedule. Known values are: "_10minutely", "hourly", and "daily". :vartype replication_schedule: str or ~azure.mgmt.netapp.models.ReplicationSchedule - :ivar remote_volume_resource_id: The resource ID of the remote volume. Required. + :ivar remote_volume_resource_id: The resource ID of the remote volume. Required for cross + region and cross zone replication. Required. :vartype remote_volume_resource_id: str + :ivar remote_path: The full path to a volume that is to be migrated into ANF. Required for + Migration volumes. + :vartype remote_path: ~azure.mgmt.netapp.models.RemotePath :ivar remote_volume_region: The remote region for the other end of the Volume Replication. :vartype remote_volume_region: str """ @@ -2835,6 +3616,7 @@ class ReplicationObject(_serialization.Model): "endpoint_type": {"key": "endpointType", "type": "str"}, "replication_schedule": {"key": "replicationSchedule", "type": "str"}, "remote_volume_resource_id": {"key": "remoteVolumeResourceId", "type": "str"}, + "remote_path": {"key": "remotePath", "type": "RemotePath"}, "remote_volume_region": {"key": "remoteVolumeRegion", "type": "str"}, } @@ -2844,6 +3626,7 @@ def __init__( remote_volume_resource_id: str, endpoint_type: Optional[Union[str, "_models.EndpointType"]] = None, replication_schedule: Optional[Union[str, "_models.ReplicationSchedule"]] = None, + remote_path: Optional["_models.RemotePath"] = None, remote_volume_region: Optional[str] = None, **kwargs: Any ) -> None: @@ -2854,8 +3637,12 @@ def __init__( :keyword replication_schedule: Schedule. Known values are: "_10minutely", "hourly", and "daily". :paramtype replication_schedule: str or ~azure.mgmt.netapp.models.ReplicationSchedule - :keyword remote_volume_resource_id: The resource ID of the remote volume. Required. + :keyword remote_volume_resource_id: The resource ID of the remote volume. Required for cross + region and cross zone replication. Required. :paramtype remote_volume_resource_id: str + :keyword remote_path: The full path to a volume that is to be migrated into ANF. Required for + Migration volumes. + :paramtype remote_path: ~azure.mgmt.netapp.models.RemotePath :keyword remote_volume_region: The remote region for the other end of the Volume Replication. :paramtype remote_volume_region: str """ @@ -2864,6 +3651,7 @@ def __init__( self.endpoint_type = endpoint_type self.replication_schedule = replication_schedule self.remote_volume_resource_id = remote_volume_resource_id + self.remote_path = remote_path self.remote_volume_region = remote_volume_region @@ -2962,7 +3750,7 @@ def __init__(self, *, type: Optional[str] = None, **kwargs: Any) -> None: class ResourceNameAvailabilityRequest(_serialization.Model): """Resource name availability request content. - 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: Resource name to verify. Required. :vartype name: str @@ -3094,10 +3882,10 @@ class Snapshot(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -3181,10 +3969,10 @@ class SnapshotPolicy(TrackedResource): # pylint: disable=too-many-instance-attr Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -3485,7 +4273,7 @@ def __init__(self, *, value: Optional[List["_models.Volume"]] = None, **kwargs: class SnapshotRestoreFiles(_serialization.Model): """Restore payload for Single File Snapshot 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 file_paths: List of files to be restored. Required. :vartype file_paths: list[str] @@ -3540,7 +4328,7 @@ class SubscriptionQuotaItem(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -3607,7 +4395,7 @@ class SubvolumeInfo(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -3831,6 +4619,30 @@ def __init__( self.next_link = next_link +class SvmPeerCommandResponse(_serialization.Model): + """Information about SVM peering process. + + :ivar svm_peering_command: A command that needs to be run on the external ONTAP to accept SVM + peering. Will only be present if :code:`svmPeeringStatus` is + :code:`pending`. + :vartype svm_peering_command: str + """ + + _attribute_map = { + "svm_peering_command": {"key": "svmPeeringCommand", "type": "str"}, + } + + def __init__(self, *, svm_peering_command: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword svm_peering_command: A command that needs to be run on the external ONTAP to accept + SVM peering. Will only be present if :code:`svmPeeringStatus` is + :code:`pending`. + :paramtype svm_peering_command: str + """ + super().__init__(**kwargs) + self.svm_peering_command = svm_peering_command + + class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. @@ -3898,21 +4710,21 @@ def __init__( class UpdateNetworkSiblingSetRequest(_serialization.Model): """Network sibling set update. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar network_sibling_set_id: Network Sibling Set ID for a group of volumes sharing networking resources in a subnet. Required. :vartype network_sibling_set_id: str :ivar subnet_id: The Azure Resource URI for a delegated subnet. Must have the delegation Microsoft.NetApp/volumes. Example - /subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/{mySubnet}. + /subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/{mySubnet}. # pylint: disable=line-too-long Required. :vartype subnet_id: str :ivar network_sibling_set_state_id: Network sibling set state Id identifying the current state of the sibling set. Required. :vartype network_sibling_set_state_id: str - :ivar network_features: Network features available to the volume, some such. Known values are: - "Basic", "Standard", "Basic_Standard", and "Standard_Basic". + :ivar network_features: Network features available to the volume. Known values are: "Basic", + "Standard", "Basic_Standard", and "Standard_Basic". :vartype network_features: str or ~azure.mgmt.netapp.models.NetworkFeatures """ @@ -3950,14 +4762,14 @@ def __init__( :paramtype network_sibling_set_id: str :keyword subnet_id: The Azure Resource URI for a delegated subnet. Must have the delegation Microsoft.NetApp/volumes. Example - /subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/{mySubnet}. + /subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/{mySubnet}. # pylint: disable=line-too-long Required. :paramtype subnet_id: str :keyword network_sibling_set_state_id: Network sibling set state Id identifying the current state of the sibling set. Required. :paramtype network_sibling_set_state_id: str - :keyword network_features: Network features available to the volume, some such. Known values - are: "Basic", "Standard", "Basic_Standard", and "Standard_Basic". + :keyword network_features: Network features available to the volume. Known values are: "Basic", + "Standard", "Basic_Standard", and "Standard_Basic". :paramtype network_features: str or ~azure.mgmt.netapp.models.NetworkFeatures """ super().__init__(**kwargs) @@ -4000,10 +4812,10 @@ class Volume(TrackedResource): # pylint: disable=too-many-instance-attributes Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -4039,12 +4851,12 @@ class Volume(TrackedResource): # pylint: disable=too-many-instance-attributes :vartype protocol_types: list[str] :ivar provisioning_state: Azure lifecycle management. :vartype provisioning_state: str - :ivar snapshot_id: UUID v4 or resource identifier used to identify the Snapshot. + :ivar snapshot_id: Resource identifier used to identify the Snapshot. :vartype snapshot_id: str :ivar delete_base_snapshot: If enabled (true) the snapshot the volume was created from will be automatically deleted after the volume create operation has finished. Defaults to false. :vartype delete_base_snapshot: bool - :ivar backup_id: UUID v4 or resource identifier used to identify the Backup. + :ivar backup_id: Resource identifier used to identify the Backup. :vartype backup_id: str :ivar baremetal_tenant_id: Unique Baremetal Tenant Identifier. :vartype baremetal_tenant_id: str @@ -4064,11 +4876,18 @@ class Volume(TrackedResource): # pylint: disable=too-many-instance-attributes :ivar mount_targets: List of mount targets. :vartype mount_targets: list[~azure.mgmt.netapp.models.MountTargetProperties] :ivar volume_type: What type of volume is this. For destination volumes in Cross Region - Replication, set type to DataProtection. + Replication, set type to DataProtection. For creating clone volume, set type to ShortTermClone. :vartype volume_type: str :ivar data_protection: DataProtection type volumes include an object containing details of the replication. :vartype data_protection: ~azure.mgmt.netapp.models.VolumePropertiesDataProtection + :ivar accept_grow_capacity_pool_for_short_term_clone_split: While auto splitting the short term + clone volume, if the parent pool does not have enough space to accommodate the volume after + split, it will be automatically resized, which will lead to increased billing. To accept + capacity pool size auto grow and create a short term clone volume, set the property as + accepted. Known values are: "Accepted" and "Declined". + :vartype accept_grow_capacity_pool_for_short_term_clone_split: str or + ~azure.mgmt.netapp.models.AcceptGrowCapacityPoolForShortTermCloneSplit :ivar is_restoring: Restoring. :vartype is_restoring: bool :ivar snapshot_directory_visible: If enabled (true) the volume will contain a read-only @@ -4186,6 +5005,19 @@ class Volume(TrackedResource): # pylint: disable=too-many-instance-attributes :vartype is_large_volume: bool :ivar originating_resource_id: Id of the snapshot or backup that the volume is restored from. :vartype originating_resource_id: str + :ivar inherited_size_in_bytes: Space shared by short term clone volume with parent volume in + bytes. + :vartype inherited_size_in_bytes: int + :ivar language: Language supported for volume. Known values are: "c.utf-8", "utf8mb4", "ar", + "ar.utf-8", "hr", "hr.utf-8", "cs", "cs.utf-8", "da", "da.utf-8", "nl", "nl.utf-8", "en", + "en.utf-8", "fi", "fi.utf-8", "fr", "fr.utf-8", "de", "de.utf-8", "he", "he.utf-8", "hu", + "hu.utf-8", "it", "it.utf-8", "ja", "ja.utf-8", "ja-v1", "ja-v1.utf-8", "ja-jp.pck", + "ja-jp.pck.utf-8", "ja-jp.932", "ja-jp.932.utf-8", "ja-jp.pck-v2", "ja-jp.pck-v2.utf-8", "ko", + "ko.utf-8", "no", "no.utf-8", "pl", "pl.utf-8", "pt", "pt.utf-8", "c", "ro", "ro.utf-8", "ru", + "ru.utf-8", "zh", "zh.utf-8", "zh.gbk", "zh.gbk.utf-8", "zh-tw.big5", "zh-tw.big5.utf-8", + "zh-tw", "zh-tw.utf-8", "sk", "sk.utf-8", "sl", "sl.utf-8", "es", "es.utf-8", "sv", "sv.utf-8", + "tr", "tr.utf-8", "en-us", and "en-us.utf-8". + :vartype language: str or ~azure.mgmt.netapp.models.VolumeLanguage """ _validation = { @@ -4220,7 +5052,7 @@ class Volume(TrackedResource): # pylint: disable=too-many-instance-attributes "storage_to_network_proximity": {"readonly": True}, "mount_targets": {"readonly": True}, "actual_throughput_mibps": {"readonly": True}, - "coolness_period": {"maximum": 183, "minimum": 7}, + "coolness_period": {"maximum": 183, "minimum": 2}, "unix_permissions": {"max_length": 4, "min_length": 4}, "clone_progress": {"readonly": True}, "file_access_logs": {"readonly": True}, @@ -4231,6 +5063,7 @@ class Volume(TrackedResource): # pylint: disable=too-many-instance-attributes "encrypted": {"readonly": True}, "provisioned_availability_zone": {"readonly": True}, "originating_resource_id": {"readonly": True}, + "inherited_size_in_bytes": {"readonly": True}, } _attribute_map = { @@ -4260,6 +5093,10 @@ class Volume(TrackedResource): # pylint: disable=too-many-instance-attributes "mount_targets": {"key": "properties.mountTargets", "type": "[MountTargetProperties]"}, "volume_type": {"key": "properties.volumeType", "type": "str"}, "data_protection": {"key": "properties.dataProtection", "type": "VolumePropertiesDataProtection"}, + "accept_grow_capacity_pool_for_short_term_clone_split": { + "key": "properties.acceptGrowCapacityPoolForShortTermCloneSplit", + "type": "str", + }, "is_restoring": {"key": "properties.isRestoring", "type": "bool"}, "snapshot_directory_visible": {"key": "properties.snapshotDirectoryVisible", "type": "bool"}, "kerberos_enabled": {"key": "properties.kerberosEnabled", "type": "bool"}, @@ -4299,6 +5136,8 @@ class Volume(TrackedResource): # pylint: disable=too-many-instance-attributes "provisioned_availability_zone": {"key": "properties.provisionedAvailabilityZone", "type": "str"}, "is_large_volume": {"key": "properties.isLargeVolume", "type": "bool"}, "originating_resource_id": {"key": "properties.originatingResourceId", "type": "str"}, + "inherited_size_in_bytes": {"key": "properties.inheritedSizeInBytes", "type": "int"}, + "language": {"key": "properties.language", "type": "str"}, } def __init__( # pylint: disable=too-many-locals @@ -4319,6 +5158,9 @@ def __init__( # pylint: disable=too-many-locals network_features: Union[str, "_models.NetworkFeatures"] = "Basic", volume_type: Optional[str] = None, data_protection: Optional["_models.VolumePropertiesDataProtection"] = None, + accept_grow_capacity_pool_for_short_term_clone_split: Optional[ + Union[str, "_models.AcceptGrowCapacityPoolForShortTermCloneSplit"] + ] = None, is_restoring: Optional[bool] = None, snapshot_directory_visible: bool = True, kerberos_enabled: bool = False, @@ -4345,6 +5187,7 @@ def __init__( # pylint: disable=too-many-locals placement_rules: Optional[List["_models.PlacementKeyValuePairs"]] = None, enable_subvolumes: Union[str, "_models.EnableSubvolumes"] = "Disabled", is_large_volume: bool = False, + language: Optional[Union[str, "_models.VolumeLanguage"]] = None, **kwargs: Any ) -> None: """ @@ -4368,12 +5211,12 @@ def __init__( # pylint: disable=too-many-locals :paramtype export_policy: ~azure.mgmt.netapp.models.VolumePropertiesExportPolicy :keyword protocol_types: Set of protocol types, default NFSv3, CIFS for SMB protocol. :paramtype protocol_types: list[str] - :keyword snapshot_id: UUID v4 or resource identifier used to identify the Snapshot. + :keyword snapshot_id: Resource identifier used to identify the Snapshot. :paramtype snapshot_id: str :keyword delete_base_snapshot: If enabled (true) the snapshot the volume was created from will be automatically deleted after the volume create operation has finished. Defaults to false. :paramtype delete_base_snapshot: bool - :keyword backup_id: UUID v4 or resource identifier used to identify the Backup. + :keyword backup_id: Resource identifier used to identify the Backup. :paramtype backup_id: str :keyword subnet_id: The Azure Resource URI for a delegated subnet. Must have the delegation Microsoft.NetApp/volumes. Required. @@ -4382,11 +5225,18 @@ def __init__( # pylint: disable=too-many-locals update. Known values are: "Basic", "Standard", "Basic_Standard", and "Standard_Basic". :paramtype network_features: str or ~azure.mgmt.netapp.models.NetworkFeatures :keyword volume_type: What type of volume is this. For destination volumes in Cross Region - Replication, set type to DataProtection. + Replication, set type to DataProtection. For creating clone volume, set type to ShortTermClone. :paramtype volume_type: str :keyword data_protection: DataProtection type volumes include an object containing details of the replication. :paramtype data_protection: ~azure.mgmt.netapp.models.VolumePropertiesDataProtection + :keyword accept_grow_capacity_pool_for_short_term_clone_split: While auto splitting the short + term clone volume, if the parent pool does not have enough space to accommodate the volume + after split, it will be automatically resized, which will lead to increased billing. To accept + capacity pool size auto grow and create a short term clone volume, set the property as + accepted. Known values are: "Accepted" and "Declined". + :paramtype accept_grow_capacity_pool_for_short_term_clone_split: str or + ~azure.mgmt.netapp.models.AcceptGrowCapacityPoolForShortTermCloneSplit :keyword is_restoring: Restoring. :paramtype is_restoring: bool :keyword snapshot_directory_visible: If enabled (true) the volume will contain a read-only @@ -4475,6 +5325,16 @@ def __init__( # pylint: disable=too-many-locals :paramtype enable_subvolumes: str or ~azure.mgmt.netapp.models.EnableSubvolumes :keyword is_large_volume: Specifies whether volume is a Large Volume or Regular Volume. :paramtype is_large_volume: bool + :keyword language: Language supported for volume. Known values are: "c.utf-8", "utf8mb4", "ar", + "ar.utf-8", "hr", "hr.utf-8", "cs", "cs.utf-8", "da", "da.utf-8", "nl", "nl.utf-8", "en", + "en.utf-8", "fi", "fi.utf-8", "fr", "fr.utf-8", "de", "de.utf-8", "he", "he.utf-8", "hu", + "hu.utf-8", "it", "it.utf-8", "ja", "ja.utf-8", "ja-v1", "ja-v1.utf-8", "ja-jp.pck", + "ja-jp.pck.utf-8", "ja-jp.932", "ja-jp.932.utf-8", "ja-jp.pck-v2", "ja-jp.pck-v2.utf-8", "ko", + "ko.utf-8", "no", "no.utf-8", "pl", "pl.utf-8", "pt", "pt.utf-8", "c", "ro", "ro.utf-8", "ru", + "ru.utf-8", "zh", "zh.utf-8", "zh.gbk", "zh.gbk.utf-8", "zh-tw.big5", "zh-tw.big5.utf-8", + "zh-tw", "zh-tw.utf-8", "sk", "sk.utf-8", "sl", "sl.utf-8", "es", "es.utf-8", "sv", "sv.utf-8", + "tr", "tr.utf-8", "en-us", and "en-us.utf-8". + :paramtype language: str or ~azure.mgmt.netapp.models.VolumeLanguage """ super().__init__(tags=tags, location=location, **kwargs) self.etag = None @@ -4497,6 +5357,7 @@ def __init__( # pylint: disable=too-many-locals self.mount_targets = None self.volume_type = volume_type self.data_protection = data_protection + self.accept_grow_capacity_pool_for_short_term_clone_split = accept_grow_capacity_pool_for_short_term_clone_split self.is_restoring = is_restoring self.snapshot_directory_visible = snapshot_directory_visible self.kerberos_enabled = kerberos_enabled @@ -4533,6 +5394,47 @@ def __init__( # pylint: disable=too-many-locals self.provisioned_availability_zone = None self.is_large_volume = is_large_volume self.originating_resource_id = None + self.inherited_size_in_bytes = None + self.language = language + + +class VolumeBackupProperties(_serialization.Model): + """Volume Backup Properties. + + :ivar backup_policy_id: Backup Policy Resource ID. + :vartype backup_policy_id: str + :ivar policy_enforced: Policy Enforced. + :vartype policy_enforced: bool + :ivar backup_vault_id: Backup Vault Resource ID. + :vartype backup_vault_id: str + """ + + _attribute_map = { + "backup_policy_id": {"key": "backupPolicyId", "type": "str"}, + "policy_enforced": {"key": "policyEnforced", "type": "bool"}, + "backup_vault_id": {"key": "backupVaultId", "type": "str"}, + } + + def __init__( + self, + *, + backup_policy_id: Optional[str] = None, + policy_enforced: Optional[bool] = None, + backup_vault_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword backup_policy_id: Backup Policy Resource ID. + :paramtype backup_policy_id: str + :keyword policy_enforced: Policy Enforced. + :paramtype policy_enforced: bool + :keyword backup_vault_id: Backup Vault Resource ID. + :paramtype backup_vault_id: str + """ + super().__init__(**kwargs) + self.backup_policy_id = backup_policy_id + self.policy_enforced = policy_enforced + self.backup_vault_id = backup_vault_id class VolumeBackups(_serialization.Model): @@ -4540,6 +5442,8 @@ class VolumeBackups(_serialization.Model): :ivar volume_name: Volume name. :vartype volume_name: str + :ivar volume_resource_id: ResourceId used to identify the Volume. + :vartype volume_resource_id: str :ivar backups_count: Total count of backups for volume. :vartype backups_count: int :ivar policy_enabled: Policy enabled. @@ -4548,6 +5452,7 @@ class VolumeBackups(_serialization.Model): _attribute_map = { "volume_name": {"key": "volumeName", "type": "str"}, + "volume_resource_id": {"key": "volumeResourceId", "type": "str"}, "backups_count": {"key": "backupsCount", "type": "int"}, "policy_enabled": {"key": "policyEnabled", "type": "bool"}, } @@ -4556,6 +5461,7 @@ def __init__( self, *, volume_name: Optional[str] = None, + volume_resource_id: Optional[str] = None, backups_count: Optional[int] = None, policy_enabled: Optional[bool] = None, **kwargs: Any @@ -4563,6 +5469,8 @@ def __init__( """ :keyword volume_name: Volume name. :paramtype volume_name: str + :keyword volume_resource_id: ResourceId used to identify the Volume. + :paramtype volume_resource_id: str :keyword backups_count: Total count of backups for volume. :paramtype backups_count: int :keyword policy_enabled: Policy enabled. @@ -4570,6 +5478,7 @@ def __init__( """ super().__init__(**kwargs) self.volume_name = volume_name + self.volume_resource_id = volume_resource_id self.backups_count = backups_count self.policy_enabled = policy_enabled @@ -4776,7 +5685,7 @@ class VolumeGroupVolumeProperties(_serialization.Model): # pylint: disable=too- Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Resource Id. :vartype id: str @@ -4806,12 +5715,12 @@ class VolumeGroupVolumeProperties(_serialization.Model): # pylint: disable=too- :vartype protocol_types: list[str] :ivar provisioning_state: Azure lifecycle management. :vartype provisioning_state: str - :ivar snapshot_id: UUID v4 or resource identifier used to identify the Snapshot. + :ivar snapshot_id: Resource identifier used to identify the Snapshot. :vartype snapshot_id: str :ivar delete_base_snapshot: If enabled (true) the snapshot the volume was created from will be automatically deleted after the volume create operation has finished. Defaults to false. :vartype delete_base_snapshot: bool - :ivar backup_id: UUID v4 or resource identifier used to identify the Backup. + :ivar backup_id: Resource identifier used to identify the Backup. :vartype backup_id: str :ivar baremetal_tenant_id: Unique Baremetal Tenant Identifier. :vartype baremetal_tenant_id: str @@ -4831,11 +5740,18 @@ class VolumeGroupVolumeProperties(_serialization.Model): # pylint: disable=too- :ivar mount_targets: List of mount targets. :vartype mount_targets: list[~azure.mgmt.netapp.models.MountTargetProperties] :ivar volume_type: What type of volume is this. For destination volumes in Cross Region - Replication, set type to DataProtection. + Replication, set type to DataProtection. For creating clone volume, set type to ShortTermClone. :vartype volume_type: str :ivar data_protection: DataProtection type volumes include an object containing details of the replication. :vartype data_protection: ~azure.mgmt.netapp.models.VolumePropertiesDataProtection + :ivar accept_grow_capacity_pool_for_short_term_clone_split: While auto splitting the short term + clone volume, if the parent pool does not have enough space to accommodate the volume after + split, it will be automatically resized, which will lead to increased billing. To accept + capacity pool size auto grow and create a short term clone volume, set the property as + accepted. Known values are: "Accepted" and "Declined". + :vartype accept_grow_capacity_pool_for_short_term_clone_split: str or + ~azure.mgmt.netapp.models.AcceptGrowCapacityPoolForShortTermCloneSplit :ivar is_restoring: Restoring. :vartype is_restoring: bool :ivar snapshot_directory_visible: If enabled (true) the volume will contain a read-only @@ -4953,6 +5869,19 @@ class VolumeGroupVolumeProperties(_serialization.Model): # pylint: disable=too- :vartype is_large_volume: bool :ivar originating_resource_id: Id of the snapshot or backup that the volume is restored from. :vartype originating_resource_id: str + :ivar inherited_size_in_bytes: Space shared by short term clone volume with parent volume in + bytes. + :vartype inherited_size_in_bytes: int + :ivar language: Language supported for volume. Known values are: "c.utf-8", "utf8mb4", "ar", + "ar.utf-8", "hr", "hr.utf-8", "cs", "cs.utf-8", "da", "da.utf-8", "nl", "nl.utf-8", "en", + "en.utf-8", "fi", "fi.utf-8", "fr", "fr.utf-8", "de", "de.utf-8", "he", "he.utf-8", "hu", + "hu.utf-8", "it", "it.utf-8", "ja", "ja.utf-8", "ja-v1", "ja-v1.utf-8", "ja-jp.pck", + "ja-jp.pck.utf-8", "ja-jp.932", "ja-jp.932.utf-8", "ja-jp.pck-v2", "ja-jp.pck-v2.utf-8", "ko", + "ko.utf-8", "no", "no.utf-8", "pl", "pl.utf-8", "pt", "pt.utf-8", "c", "ro", "ro.utf-8", "ru", + "ru.utf-8", "zh", "zh.utf-8", "zh.gbk", "zh.gbk.utf-8", "zh-tw.big5", "zh-tw.big5.utf-8", + "zh-tw", "zh-tw.utf-8", "sk", "sk.utf-8", "sl", "sl.utf-8", "es", "es.utf-8", "sv", "sv.utf-8", + "tr", "tr.utf-8", "en-us", and "en-us.utf-8". + :vartype language: str or ~azure.mgmt.netapp.models.VolumeLanguage """ _validation = { @@ -4983,7 +5912,7 @@ class VolumeGroupVolumeProperties(_serialization.Model): # pylint: disable=too- "storage_to_network_proximity": {"readonly": True}, "mount_targets": {"readonly": True}, "actual_throughput_mibps": {"readonly": True}, - "coolness_period": {"maximum": 183, "minimum": 7}, + "coolness_period": {"maximum": 183, "minimum": 2}, "unix_permissions": {"max_length": 4, "min_length": 4}, "clone_progress": {"readonly": True}, "file_access_logs": {"readonly": True}, @@ -4994,6 +5923,7 @@ class VolumeGroupVolumeProperties(_serialization.Model): # pylint: disable=too- "encrypted": {"readonly": True}, "provisioned_availability_zone": {"readonly": True}, "originating_resource_id": {"readonly": True}, + "inherited_size_in_bytes": {"readonly": True}, } _attribute_map = { @@ -5020,6 +5950,10 @@ class VolumeGroupVolumeProperties(_serialization.Model): # pylint: disable=too- "mount_targets": {"key": "properties.mountTargets", "type": "[MountTargetProperties]"}, "volume_type": {"key": "properties.volumeType", "type": "str"}, "data_protection": {"key": "properties.dataProtection", "type": "VolumePropertiesDataProtection"}, + "accept_grow_capacity_pool_for_short_term_clone_split": { + "key": "properties.acceptGrowCapacityPoolForShortTermCloneSplit", + "type": "str", + }, "is_restoring": {"key": "properties.isRestoring", "type": "bool"}, "snapshot_directory_visible": {"key": "properties.snapshotDirectoryVisible", "type": "bool"}, "kerberos_enabled": {"key": "properties.kerberosEnabled", "type": "bool"}, @@ -5059,6 +5993,8 @@ class VolumeGroupVolumeProperties(_serialization.Model): # pylint: disable=too- "provisioned_availability_zone": {"key": "properties.provisionedAvailabilityZone", "type": "str"}, "is_large_volume": {"key": "properties.isLargeVolume", "type": "bool"}, "originating_resource_id": {"key": "properties.originatingResourceId", "type": "str"}, + "inherited_size_in_bytes": {"key": "properties.inheritedSizeInBytes", "type": "int"}, + "language": {"key": "properties.language", "type": "str"}, } def __init__( # pylint: disable=too-many-locals @@ -5079,6 +6015,9 @@ def __init__( # pylint: disable=too-many-locals network_features: Union[str, "_models.NetworkFeatures"] = "Basic", volume_type: Optional[str] = None, data_protection: Optional["_models.VolumePropertiesDataProtection"] = None, + accept_grow_capacity_pool_for_short_term_clone_split: Optional[ + Union[str, "_models.AcceptGrowCapacityPoolForShortTermCloneSplit"] + ] = None, is_restoring: Optional[bool] = None, snapshot_directory_visible: bool = True, kerberos_enabled: bool = False, @@ -5105,6 +6044,7 @@ def __init__( # pylint: disable=too-many-locals placement_rules: Optional[List["_models.PlacementKeyValuePairs"]] = None, enable_subvolumes: Union[str, "_models.EnableSubvolumes"] = "Disabled", is_large_volume: bool = False, + language: Optional[Union[str, "_models.VolumeLanguage"]] = None, **kwargs: Any ) -> None: """ @@ -5128,12 +6068,12 @@ def __init__( # pylint: disable=too-many-locals :paramtype export_policy: ~azure.mgmt.netapp.models.VolumePropertiesExportPolicy :keyword protocol_types: Set of protocol types, default NFSv3, CIFS for SMB protocol. :paramtype protocol_types: list[str] - :keyword snapshot_id: UUID v4 or resource identifier used to identify the Snapshot. + :keyword snapshot_id: Resource identifier used to identify the Snapshot. :paramtype snapshot_id: str :keyword delete_base_snapshot: If enabled (true) the snapshot the volume was created from will be automatically deleted after the volume create operation has finished. Defaults to false. :paramtype delete_base_snapshot: bool - :keyword backup_id: UUID v4 or resource identifier used to identify the Backup. + :keyword backup_id: Resource identifier used to identify the Backup. :paramtype backup_id: str :keyword subnet_id: The Azure Resource URI for a delegated subnet. Must have the delegation Microsoft.NetApp/volumes. Required. @@ -5142,11 +6082,18 @@ def __init__( # pylint: disable=too-many-locals update. Known values are: "Basic", "Standard", "Basic_Standard", and "Standard_Basic". :paramtype network_features: str or ~azure.mgmt.netapp.models.NetworkFeatures :keyword volume_type: What type of volume is this. For destination volumes in Cross Region - Replication, set type to DataProtection. + Replication, set type to DataProtection. For creating clone volume, set type to ShortTermClone. :paramtype volume_type: str :keyword data_protection: DataProtection type volumes include an object containing details of the replication. :paramtype data_protection: ~azure.mgmt.netapp.models.VolumePropertiesDataProtection + :keyword accept_grow_capacity_pool_for_short_term_clone_split: While auto splitting the short + term clone volume, if the parent pool does not have enough space to accommodate the volume + after split, it will be automatically resized, which will lead to increased billing. To accept + capacity pool size auto grow and create a short term clone volume, set the property as + accepted. Known values are: "Accepted" and "Declined". + :paramtype accept_grow_capacity_pool_for_short_term_clone_split: str or + ~azure.mgmt.netapp.models.AcceptGrowCapacityPoolForShortTermCloneSplit :keyword is_restoring: Restoring. :paramtype is_restoring: bool :keyword snapshot_directory_visible: If enabled (true) the volume will contain a read-only @@ -5235,6 +6182,16 @@ def __init__( # pylint: disable=too-many-locals :paramtype enable_subvolumes: str or ~azure.mgmt.netapp.models.EnableSubvolumes :keyword is_large_volume: Specifies whether volume is a Large Volume or Regular Volume. :paramtype is_large_volume: bool + :keyword language: Language supported for volume. Known values are: "c.utf-8", "utf8mb4", "ar", + "ar.utf-8", "hr", "hr.utf-8", "cs", "cs.utf-8", "da", "da.utf-8", "nl", "nl.utf-8", "en", + "en.utf-8", "fi", "fi.utf-8", "fr", "fr.utf-8", "de", "de.utf-8", "he", "he.utf-8", "hu", + "hu.utf-8", "it", "it.utf-8", "ja", "ja.utf-8", "ja-v1", "ja-v1.utf-8", "ja-jp.pck", + "ja-jp.pck.utf-8", "ja-jp.932", "ja-jp.932.utf-8", "ja-jp.pck-v2", "ja-jp.pck-v2.utf-8", "ko", + "ko.utf-8", "no", "no.utf-8", "pl", "pl.utf-8", "pt", "pt.utf-8", "c", "ro", "ro.utf-8", "ru", + "ru.utf-8", "zh", "zh.utf-8", "zh.gbk", "zh.gbk.utf-8", "zh-tw.big5", "zh-tw.big5.utf-8", + "zh-tw", "zh-tw.utf-8", "sk", "sk.utf-8", "sl", "sl.utf-8", "es", "es.utf-8", "sv", "sv.utf-8", + "tr", "tr.utf-8", "en-us", and "en-us.utf-8". + :paramtype language: str or ~azure.mgmt.netapp.models.VolumeLanguage """ super().__init__(**kwargs) self.id = None @@ -5260,6 +6217,7 @@ def __init__( # pylint: disable=too-many-locals self.mount_targets = None self.volume_type = volume_type self.data_protection = data_protection + self.accept_grow_capacity_pool_for_short_term_clone_split = accept_grow_capacity_pool_for_short_term_clone_split self.is_restoring = is_restoring self.snapshot_directory_visible = snapshot_directory_visible self.kerberos_enabled = kerberos_enabled @@ -5296,6 +6254,8 @@ def __init__( # pylint: disable=too-many-locals self.provisioned_availability_zone = None self.is_large_volume = is_large_volume self.originating_resource_id = None + self.inherited_size_in_bytes = None + self.language = language class VolumeList(_serialization.Model): @@ -5406,7 +6366,7 @@ class VolumePatch(_serialization.Model): # pylint: disable=too-many-instance-at "type": {"readonly": True}, "usage_threshold": {"maximum": 2638827906662400, "minimum": 107374182400}, "unix_permissions": {"max_length": 4, "min_length": 4}, - "coolness_period": {"maximum": 183, "minimum": 7}, + "coolness_period": {"maximum": 183, "minimum": 2}, } _attribute_map = { @@ -5543,20 +6503,32 @@ def __init__( class VolumePatchPropertiesDataProtection(_serialization.Model): """DataProtection type volumes include an object containing details of the replication. + :ivar backup: Backup Properties. + :vartype backup: ~azure.mgmt.netapp.models.VolumeBackupProperties :ivar snapshot: Snapshot properties. :vartype snapshot: ~azure.mgmt.netapp.models.VolumeSnapshotProperties """ _attribute_map = { + "backup": {"key": "backup", "type": "VolumeBackupProperties"}, "snapshot": {"key": "snapshot", "type": "VolumeSnapshotProperties"}, } - def __init__(self, *, snapshot: Optional["_models.VolumeSnapshotProperties"] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + backup: Optional["_models.VolumeBackupProperties"] = None, + snapshot: Optional["_models.VolumeSnapshotProperties"] = None, + **kwargs: Any + ) -> None: """ + :keyword backup: Backup Properties. + :paramtype backup: ~azure.mgmt.netapp.models.VolumeBackupProperties :keyword snapshot: Snapshot properties. :paramtype snapshot: ~azure.mgmt.netapp.models.VolumeSnapshotProperties """ super().__init__(**kwargs) + self.backup = backup self.snapshot = snapshot @@ -5583,6 +6555,8 @@ def __init__(self, *, rules: Optional[List["_models.ExportPolicyRule"]] = None, class VolumePropertiesDataProtection(_serialization.Model): """DataProtection type volumes include an object containing details of the replication. + :ivar backup: Backup Properties. + :vartype backup: ~azure.mgmt.netapp.models.VolumeBackupProperties :ivar replication: Replication properties. :vartype replication: ~azure.mgmt.netapp.models.ReplicationObject :ivar snapshot: Snapshot properties. @@ -5592,6 +6566,7 @@ class VolumePropertiesDataProtection(_serialization.Model): """ _attribute_map = { + "backup": {"key": "backup", "type": "VolumeBackupProperties"}, "replication": {"key": "replication", "type": "ReplicationObject"}, "snapshot": {"key": "snapshot", "type": "VolumeSnapshotProperties"}, "volume_relocation": {"key": "volumeRelocation", "type": "VolumeRelocationProperties"}, @@ -5600,12 +6575,15 @@ class VolumePropertiesDataProtection(_serialization.Model): def __init__( self, *, + backup: Optional["_models.VolumeBackupProperties"] = None, replication: Optional["_models.ReplicationObject"] = None, snapshot: Optional["_models.VolumeSnapshotProperties"] = None, volume_relocation: Optional["_models.VolumeRelocationProperties"] = None, **kwargs: Any ) -> None: """ + :keyword backup: Backup Properties. + :paramtype backup: ~azure.mgmt.netapp.models.VolumeBackupProperties :keyword replication: Replication properties. :paramtype replication: ~azure.mgmt.netapp.models.ReplicationObject :keyword snapshot: Snapshot properties. @@ -5614,6 +6592,7 @@ def __init__( :paramtype volume_relocation: ~azure.mgmt.netapp.models.VolumeRelocationProperties """ super().__init__(**kwargs) + self.backup = backup self.replication = replication self.snapshot = snapshot self.volume_relocation = volume_relocation @@ -5644,10 +6623,10 @@ class VolumeQuotaRule(TrackedResource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/models/_net_app_management_client_enums.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/models/_net_app_management_client_enums.py index d64b7c1aa3a7..69e656693f2e 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/models/_net_app_management_client_enums.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/models/_net_app_management_client_enums.py @@ -10,6 +10,20 @@ from azure.core import CaseInsensitiveEnumMeta +class AcceptGrowCapacityPoolForShortTermCloneSplit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """While auto splitting the short term clone volume, if the parent pool does not have enough space + to accommodate the volume after split, it will be automatically resized, which will lead to + increased billing. To accept capacity pool size auto grow and create a short term clone volume, + set the property as accepted. + """ + + ACCEPTED = "Accepted" + """Auto grow capacity pool for short term clone split is accepted.""" + DECLINED = "Declined" + """Auto grow capacity pool for short term clone split is declined. Short term clone volume + creation will not be allowed, to create short term clone volume accept auto grow capacity pool.""" + + class ActiveDirectoryStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Status of the Active Directory.""" @@ -41,6 +55,15 @@ class AvsDataStore(str, Enum, metaclass=CaseInsensitiveEnumMeta): """avsDataStore is disabled""" +class BackupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of backup Manual or Scheduled.""" + + MANUAL = "Manual" + """Manual backup""" + SCHEDULED = "Scheduled" + """Scheduled backup""" + + class CheckNameResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Resource type used for verification.""" @@ -345,6 +368,149 @@ class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Individual group quota""" +class VolumeLanguage(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Language supported for volume.""" + + C_UTF8 = "c.utf-8" + """Posix with UTF-8""" + UTF8_MB4 = "utf8mb4" + """UTF-8 with 4 byte character support""" + AR = "ar" + """Arabic - Deprecated""" + AR_UTF8 = "ar.utf-8" + """Arabic with UTF-8""" + HR = "hr" + """Croatian - Deprecated""" + HR_UTF8 = "hr.utf-8" + """Croatian with UTF-8""" + CS = "cs" + """Czech - Deprecated""" + CS_UTF8 = "cs.utf-8" + """Czech with UTF-8""" + DA = "da" + """Danish - Deprecated""" + DA_UTF8 = "da.utf-8" + """Danish with UTF-8""" + NL = "nl" + """Dutch - Deprecated""" + NL_UTF8 = "nl.utf-8" + """Dutch with UTF-8""" + EN = "en" + """English - Deprecated""" + EN_UTF8 = "en.utf-8" + """English with UTF-8""" + FI = "fi" + """Finnish - Deprecated""" + FI_UTF8 = "fi.utf-8" + """Finnish with UTF-8""" + FR = "fr" + """French - Deprecated""" + FR_UTF8 = "fr.utf-8" + """French with UTF-8""" + DE = "de" + """German - Deprecated""" + DE_UTF8 = "de.utf-8" + """German with UTF-8""" + HE = "he" + """Hebrew - Deprecated""" + HE_UTF8 = "he.utf-8" + """Hebrew with UTF-8""" + HU = "hu" + """Hungarian - Deprecated""" + HU_UTF8 = "hu.utf-8" + """Hungarian with UTF-8""" + IT = "it" + """Italian - Deprecated""" + IT_UTF8 = "it.utf-8" + """Italian with UTF-8""" + JA = "ja" + """Japanese euc-j - Deprecated""" + JA_UTF8 = "ja.utf-8" + """Japanese euc-j with UTF-8""" + JA_V1 = "ja-v1" + """Japanese euc-j - Deprecated""" + JA_V1_UTF8 = "ja-v1.utf-8" + """Japanese euc-j with UTF-8""" + JA_JP_PCK = "ja-jp.pck" + """Japanese pck""" + JA_JP_PCK_UTF8 = "ja-jp.pck.utf-8" + """Japanese pck with UTF-8 - Deprecated""" + JA_JP932 = "ja-jp.932" + """Japanese cp932""" + JA_JP932_UTF8 = "ja-jp.932.utf-8" + """Japanes cp932 with UTF-8 - Deprecated""" + JA_JP_PCK_V2 = "ja-jp.pck-v2" + """Japanese pck - sjis""" + JA_JP_PCK_V2_UTF8 = "ja-jp.pck-v2.utf-8" + """Japanese pck - sjis with UTF-8 - Deprecated""" + KO = "ko" + """Korean - Deprecated""" + KO_UTF8 = "ko.utf-8" + """Korean with UTF-8""" + NO = "no" + """Norwegian - Deprecated""" + NO_UTF8 = "no.utf-8" + """Norwegian with UTF-8""" + PL = "pl" + """Polish - Deprecated""" + PL_UTF8 = "pl.utf-8" + """Polish with UTF-8""" + PT = "pt" + """Portuguese - Deprecated""" + PT_UTF8 = "pt.utf-8" + """Portuguese with UTF-8""" + C = "c" + """Posix - Deprecated""" + RO = "ro" + """Romanian - Deprecated""" + RO_UTF8 = "ro.utf-8" + """Romanian with UTF-8""" + RU = "ru" + """Russian - Deprecated""" + RU_UTF8 = "ru.utf-8" + """Russian with UTF-8""" + ZH = "zh" + """Simplified Chinese - Deprecated""" + ZH_UTF8 = "zh.utf-8" + """Simplified Chinese with UTF-8""" + ZH_GBK = "zh.gbk" + """Simplified gbk Chinese""" + ZH_GBK_UTF8 = "zh.gbk.utf-8" + """Simplified gbk Chinese with UTF-8 - Deprecated""" + ZH_TW_BIG5 = "zh-tw.big5" + """Traditional Chinese BIG 5""" + ZH_TW_BIG5_UTF8 = "zh-tw.big5.utf-8" + """Traditional Chinese BIG 5 with UTF-8 - Deprecated""" + ZH_TW = "zh-tw" + """Traditional Chinese EUC-TW""" + ZH_TW_UTF8 = "zh-tw.utf-8" + """Traditional Chinese EUC-TW with UTF-8 - Deprecated""" + SK = "sk" + """Slovak - Deprecated""" + SK_UTF8 = "sk.utf-8" + """Slovak with UTF-8""" + SL = "sl" + """Slovenian - Deprecated""" + SL_UTF8 = "sl.utf-8" + """Slovenian with UTF-8""" + ES = "es" + """Spanish - Deprecated""" + ES_UTF8 = "es.utf-8" + """Spanish with UTF-8""" + SV = "sv" + """Swedish - Deprecated""" + SV_UTF8 = "sv.utf-8" + """Swedish with UTF-8""" + TR = "tr" + """Turkish - Deprecated""" + TR_UTF8 = "tr.utf-8" + """Turkish with UTF-8""" + EN_US = "en-us" + """US English - Deprecated""" + EN_US_UTF8 = "en-us.utf-8" + """US English with UTF-8""" + + class VolumeStorageToNetworkProximity(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provides storage to network proximity information for the volume.""" diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/__init__.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/__init__.py index 207ff3039ab7..96d2b3958ac5 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/__init__.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/__init__.py @@ -9,16 +9,21 @@ from ._operations import Operations from ._net_app_resource_operations import NetAppResourceOperations from ._net_app_resource_quota_limits_operations import NetAppResourceQuotaLimitsOperations +from ._net_app_resource_region_infos_operations import NetAppResourceRegionInfosOperations from ._accounts_operations import AccountsOperations from ._pools_operations import PoolsOperations from ._volumes_operations import VolumesOperations from ._snapshots_operations import SnapshotsOperations from ._snapshot_policies_operations import SnapshotPoliciesOperations -from ._backups_operations import BackupsOperations from ._backup_policies_operations import BackupPoliciesOperations from ._volume_quota_rules_operations import VolumeQuotaRulesOperations from ._volume_groups_operations import VolumeGroupsOperations from ._subvolumes_operations import SubvolumesOperations +from ._backups_operations import BackupsOperations +from ._backup_vaults_operations import BackupVaultsOperations +from ._backups_under_backup_vault_operations import BackupsUnderBackupVaultOperations +from ._backups_under_volume_operations import BackupsUnderVolumeOperations +from ._backups_under_account_operations import BackupsUnderAccountOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -28,16 +33,21 @@ "Operations", "NetAppResourceOperations", "NetAppResourceQuotaLimitsOperations", + "NetAppResourceRegionInfosOperations", "AccountsOperations", "PoolsOperations", "VolumesOperations", "SnapshotsOperations", "SnapshotPoliciesOperations", - "BackupsOperations", "BackupPoliciesOperations", "VolumeQuotaRulesOperations", "VolumeGroupsOperations", "SubvolumesOperations", + "BackupsOperations", + "BackupVaultsOperations", + "BackupsUnderBackupVaultOperations", + "BackupsUnderVolumeOperations", + "BackupsUnderAccountOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_accounts_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_accounts_operations.py index 12e50163f0a1..f8780f32a02c 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_accounts_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_accounts_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, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -32,6 +33,10 @@ from .._serialization import Serializer from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +48,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +72,7 @@ def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +102,7 @@ def build_get_request(resource_group_name: str, account_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -132,7 +137,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -170,7 +175,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -205,7 +210,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -243,7 +248,7 @@ def build_renew_credentials_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -272,6 +277,117 @@ def build_renew_credentials_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) +def build_migrate_encryption_key_request( + resource_group_name: str, account_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-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/migrateEncryption", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_change_key_vault_information_request( # pylint: disable=name-too-long + resource_group_name: str, account_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-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/keyVaultStatus", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_change_key_vault_request( + resource_group_name: str, account_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-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/changeKeyVault", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + class AccountsOperations: """ .. warning:: @@ -297,7 +413,6 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.NetAppAccount List and describe all NetApp accounts in the subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either NetAppAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.netapp.models.NetAppAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -308,7 +423,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.NetAppAccount api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NetAppAccountList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -319,15 +434,14 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.NetAppAccount def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -339,13 +453,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("NetAppAccountList", pipeline_response) @@ -355,11 +469,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 @@ -372,8 +486,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/netAppAccounts"} - @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.NetAppAccount"]: """Describe all NetApp Accounts in a resource group. @@ -383,7 +495,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Net :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 NetAppAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.netapp.models.NetAppAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -394,7 +505,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Net api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NetAppAccountList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -405,16 +516,15 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Net def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -426,13 +536,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("NetAppAccountList", pipeline_response) @@ -442,11 +552,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 @@ -459,10 +569,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts" - } - @distributed_trace def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.NetAppAccount: """Describe a NetApp Account. @@ -474,12 +580,11 @@ def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _mo :type resource_group_name: str :param account_name: The name of the NetApp account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NetAppAccount or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.NetAppAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -493,21 +598,20 @@ def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _mo api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NetAppAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_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 = _convert_request(_request) + _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 @@ -520,18 +624,14 @@ def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _mo deserialized = self._deserialize("NetAppAccount", pipeline_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.NetApp/netAppAccounts/{accountName}" - } + return deserialized # type: ignore def _create_or_update_initial( - self, resource_group_name: str, account_name: str, body: Union[_models.NetAppAccount, IO], **kwargs: Any + self, resource_group_name: str, account_name: str, body: Union[_models.NetAppAccount, IO[bytes]], **kwargs: Any ) -> _models.NetAppAccount: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -554,7 +654,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(body, "NetAppAccount") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -562,16 +662,15 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -592,10 +691,6 @@ def _create_or_update_initial( return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}" - } - @overload def begin_create_or_update( self, @@ -620,14 +715,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either NetAppAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.NetAppAccount] @@ -639,7 +726,7 @@ def begin_create_or_update( self, resource_group_name: str, account_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -654,18 +741,10 @@ def begin_create_or_update( :param account_name: The name of the NetApp account. Required. :type account_name: str :param body: NetApp Account object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 NetAppAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.NetAppAccount] @@ -674,7 +753,7 @@ def begin_create_or_update( @distributed_trace def begin_create_or_update( - self, resource_group_name: str, account_name: str, body: Union[_models.NetAppAccount, IO], **kwargs: Any + self, resource_group_name: str, account_name: str, body: Union[_models.NetAppAccount, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.NetAppAccount]: """Create or update a NetApp account. @@ -686,19 +765,8 @@ def begin_create_or_update( :param account_name: The name of the NetApp account. Required. :type account_name: str :param body: NetApp Account object supplied in the body of the operation. Is either a - NetAppAccount type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.NetAppAccount 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. + NetAppAccount type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.NetAppAccount or IO[bytes] :return: An instance of LROPoller that returns either NetAppAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.NetAppAccount] @@ -730,7 +798,7 @@ def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("NetAppAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -742,22 +810,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.NetAppAccount].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.NetApp/netAppAccounts/{accountName}" - } + return LROPoller[_models.NetAppAccount]( + 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, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -771,21 +837,20 @@ def _delete_initial( # 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, account_name=account_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 = _convert_request(_request) + _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 @@ -796,11 +861,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -813,14 +874,6 @@ def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: An :type resource_group_name: str :param account_name: The name of the NetApp account. Required. :type account_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: @@ -847,7 +900,7 @@ def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: An 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( @@ -858,22 +911,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _update_initial( - self, resource_group_name: str, account_name: str, body: Union[_models.NetAppAccountPatch, IO], **kwargs: Any + self, + resource_group_name: str, + account_name: str, + body: Union[_models.NetAppAccountPatch, IO[bytes]], + **kwargs: Any ) -> _models.NetAppAccount: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -896,7 +949,7 @@ def _update_initial( else: _json = self._serialize.body(body, "NetAppAccountPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -904,16 +957,15 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -934,10 +986,6 @@ def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}" - } - @overload def begin_update( self, @@ -962,14 +1010,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either NetAppAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.NetAppAccount] @@ -981,7 +1021,7 @@ def begin_update( self, resource_group_name: str, account_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -996,18 +1036,10 @@ def begin_update( :param account_name: The name of the NetApp account. Required. :type account_name: str :param body: NetApp Account object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 NetAppAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.NetAppAccount] @@ -1016,7 +1048,11 @@ def begin_update( @distributed_trace def begin_update( - self, resource_group_name: str, account_name: str, body: Union[_models.NetAppAccountPatch, IO], **kwargs: Any + self, + resource_group_name: str, + account_name: str, + body: Union[_models.NetAppAccountPatch, IO[bytes]], + **kwargs: Any ) -> LROPoller[_models.NetAppAccount]: """Update a NetApp account. @@ -1028,19 +1064,8 @@ def begin_update( :param account_name: The name of the NetApp account. Required. :type account_name: str :param body: NetApp Account object supplied in the body of the operation. Is either a - NetAppAccountPatch type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.NetAppAccountPatch 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. + NetAppAccountPatch type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.NetAppAccountPatch or IO[bytes] :return: An instance of LROPoller that returns either NetAppAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.NetAppAccount] @@ -1072,7 +1097,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("NetAppAccount", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1084,22 +1109,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.NetAppAccount].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.NetApp/netAppAccounts/{accountName}" - } + return LROPoller[_models.NetAppAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _renew_credentials_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1113,21 +1136,20 @@ def _renew_credentials_initial( # pylint: disable=inconsistent-return-statement api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_renew_credentials_request( + _request = build_renew_credentials_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._renew_credentials_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -1138,11 +1160,7 @@ def _renew_credentials_initial( # pylint: disable=inconsistent-return-statement raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _renew_credentials_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/renewCredentials" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_renew_credentials(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1157,14 +1175,6 @@ def begin_renew_credentials(self, resource_group_name: str, account_name: str, * :type resource_group_name: str :param account_name: The name of the NetApp account. Required. :type account_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: @@ -1191,7 +1201,7 @@ def begin_renew_credentials(self, resource_group_name: str, account_name: str, * 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( @@ -1202,14 +1212,510 @@ 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_renew_credentials.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/renewCredentials" - } + def _migrate_encryption_key_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + body: Optional[Union[_models.EncryptionMigrationRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "EncryptionMigrationRequest") + else: + _json = None + + _request = build_migrate_encryption_key_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @overload + def begin_migrate_encryption_key( + self, + resource_group_name: str, + account_name: str, + body: Optional[_models.EncryptionMigrationRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Migrate volumes encryption key source. + + Migrates all volumes in a VNet to a different encryption key source (Microsoft-managed key or + Azure Key Vault). Operation fails if targeted volumes share encryption sibling set with volumes + from another account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: The required parameters to perform encryption migration. Default value is None. + :type body: ~azure.mgmt.netapp.models.EncryptionMigrationRequest + :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_migrate_encryption_key( + self, + resource_group_name: str, + account_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Migrate volumes encryption key source. + + Migrates all volumes in a VNet to a different encryption key source (Microsoft-managed key or + Azure Key Vault). Operation fails if targeted volumes share encryption sibling set with volumes + from another account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: The required parameters to perform encryption migration. Default value is None. + :type body: 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_migrate_encryption_key( + self, + resource_group_name: str, + account_name: str, + body: Optional[Union[_models.EncryptionMigrationRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Migrate volumes encryption key source. + + Migrates all volumes in a VNet to a different encryption key source (Microsoft-managed key or + Azure Key Vault). Operation fails if targeted volumes share encryption sibling set with volumes + from another account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: The required parameters to perform encryption migration. Is either a + EncryptionMigrationRequest type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.netapp.models.EncryptionMigrationRequest 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 = 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._migrate_encryption_key_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _get_change_key_vault_information_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Optional[_models.ChangeKeyVault]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Optional[_models.ChangeKeyVault]] = kwargs.pop("cls", None) + + _request = build_get_change_key_vault_information_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("ChangeKeyVault", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_get_change_key_vault_information( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> LROPoller[_models.ChangeKeyVault]: + """Get information about how volumes under NetApp account are encrypted. + + Contains data from encryption.keyVaultProperties as well as information about which private + endpoint is used by each encryption sibling set. Response from this endpoint can be modified + and used as request body for POST request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :return: An instance of LROPoller that returns either ChangeKeyVault or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.ChangeKeyVault] + :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.ChangeKeyVault] = 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._get_change_key_vault_information_initial( + resource_group_name=resource_group_name, + account_name=account_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ChangeKeyVault", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ChangeKeyVault].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ChangeKeyVault]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _change_key_vault_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + body: Optional[Union[_models.ChangeKeyVault, IO[bytes]]] = None, + **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "ChangeKeyVault") + else: + _json = None + + _request = build_change_key_vault_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def begin_change_key_vault( + self, + resource_group_name: str, + account_name: str, + body: Optional[_models.ChangeKeyVault] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Change Key Vault/Managed HSM that is used for encryption of volumes under NetApp account. + + Affects existing volumes that are encrypted with Key Vault/Managed HSM, and new volumes. + Supports MHSM to Key Vault, Key Vault to MHSM, MHSM to MHSM and Key Vault to Key Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: The required parameters to perform encryption migration. Default value is None. + :type body: ~azure.mgmt.netapp.models.ChangeKeyVault + :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_change_key_vault( + self, + resource_group_name: str, + account_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Change Key Vault/Managed HSM that is used for encryption of volumes under NetApp account. + + Affects existing volumes that are encrypted with Key Vault/Managed HSM, and new volumes. + Supports MHSM to Key Vault, Key Vault to MHSM, MHSM to MHSM and Key Vault to Key Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: The required parameters to perform encryption migration. Default value is None. + :type body: 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_change_key_vault( + self, + resource_group_name: str, + account_name: str, + body: Optional[Union[_models.ChangeKeyVault, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Change Key Vault/Managed HSM that is used for encryption of volumes under NetApp account. + + Affects existing volumes that are encrypted with Key Vault/Managed HSM, and new volumes. + Supports MHSM to Key Vault, Key Vault to MHSM, MHSM to MHSM and Key Vault to Key Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: The required parameters to perform encryption migration. Is either a + ChangeKeyVault type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.netapp.models.ChangeKeyVault 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 = 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._change_key_vault_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backup_policies_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backup_policies_operations.py index 4fc87c3b2326..46c7dd2a4a5e 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backup_policies_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/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, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -32,6 +33,10 @@ from .._serialization import Serializer from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +48,7 @@ def build_list_request(resource_group_name: str, account_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +83,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +119,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -153,7 +158,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -192,7 +197,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -252,7 +257,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It :type resource_group_name: str :param account_name: The name of the NetApp account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BackupPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.netapp.models.BackupPolicy] :raises ~azure.core.exceptions.HttpResponseError: @@ -263,7 +267,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackupPoliciesList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -274,17 +278,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -296,13 +299,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("BackupPoliciesList", pipeline_response) @@ -312,11 +315,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -329,10 +332,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupPolicies" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, backup_policy_name: str, **kwargs: Any @@ -348,12 +347,11 @@ def get( :type account_name: str :param backup_policy_name: Backup policy Name which uniquely identify backup policy. Required. :type backup_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BackupPolicy or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.BackupPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,22 +365,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BackupPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_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 = _convert_request(_request) + _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 @@ -395,23 +392,19 @@ def get( deserialized = self._deserialize("BackupPolicy", pipeline_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.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, backup_policy_name: str, - body: Union[_models.BackupPolicy, IO], + body: Union[_models.BackupPolicy, IO[bytes]], **kwargs: Any ) -> Optional[_models.BackupPolicy]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,7 +427,7 @@ def _create_initial( else: _json = self._serialize.body(body, "BackupPolicy") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, backup_policy_name=backup_policy_name, @@ -443,16 +436,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -470,13 +462,9 @@ def _create_initial( deserialized = self._deserialize("BackupPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -505,14 +493,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either BackupPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.BackupPolicy] @@ -525,7 +505,7 @@ def begin_create( resource_group_name: str, account_name: str, backup_policy_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -542,18 +522,10 @@ def begin_create( :param backup_policy_name: Backup policy Name which uniquely identify backup policy. Required. :type backup_policy_name: str :param body: Backup policy object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 BackupPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.BackupPolicy] @@ -566,7 +538,7 @@ def begin_create( resource_group_name: str, account_name: str, backup_policy_name: str, - body: Union[_models.BackupPolicy, IO], + body: Union[_models.BackupPolicy, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.BackupPolicy]: """Create a backup policy. @@ -581,19 +553,8 @@ def begin_create( :param backup_policy_name: Backup policy Name which uniquely identify backup policy. Required. :type backup_policy_name: str :param body: Backup policy object supplied in the body of the operation. Is either a - BackupPolicy type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.BackupPolicy 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. + BackupPolicy type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.BackupPolicy or IO[bytes] :return: An instance of LROPoller that returns either BackupPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.BackupPolicy] @@ -626,7 +587,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BackupPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -638,27 +599,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BackupPolicy].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}" - } + return LROPoller[_models.BackupPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, account_name: str, backup_policy_name: str, - body: Union[_models.BackupPolicyPatch, IO], + body: Union[_models.BackupPolicyPatch, IO[bytes]], **kwargs: Any ) -> _models.BackupPolicy: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -681,7 +640,7 @@ def _update_initial( else: _json = self._serialize.body(body, "BackupPolicyPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, backup_policy_name=backup_policy_name, @@ -690,16 +649,15 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -720,10 +678,6 @@ def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}" - } - @overload def begin_update( self, @@ -751,14 +705,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either BackupPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.BackupPolicy] @@ -771,7 +717,7 @@ def begin_update( resource_group_name: str, account_name: str, backup_policy_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -788,18 +734,10 @@ def begin_update( :param backup_policy_name: Backup policy Name which uniquely identify backup policy. Required. :type backup_policy_name: str :param body: Backup policy object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 BackupPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.BackupPolicy] @@ -812,7 +750,7 @@ def begin_update( resource_group_name: str, account_name: str, backup_policy_name: str, - body: Union[_models.BackupPolicyPatch, IO], + body: Union[_models.BackupPolicyPatch, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.BackupPolicy]: """Patch a backup policy. @@ -827,19 +765,8 @@ def begin_update( :param backup_policy_name: Backup policy Name which uniquely identify backup policy. Required. :type backup_policy_name: str :param body: Backup policy object supplied in the body of the operation. Is either a - BackupPolicyPatch type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.BackupPolicyPatch 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. + BackupPolicyPatch type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.BackupPolicyPatch or IO[bytes] :return: An instance of LROPoller that returns either BackupPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.BackupPolicy] @@ -872,7 +799,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("BackupPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -884,22 +811,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BackupPolicy].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.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}" - } + return LROPoller[_models.BackupPolicy]( + 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, account_name: str, backup_policy_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -913,22 +838,21 @@ def _delete_initial( # 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, account_name=account_name, backup_policy_name=backup_policy_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 = _convert_request(_request) + _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 @@ -939,11 +863,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_delete( @@ -960,14 +880,6 @@ def begin_delete( :type account_name: str :param backup_policy_name: Backup policy Name which uniquely identify backup policy. Required. :type backup_policy_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: @@ -995,7 +907,7 @@ def begin_delete( 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( @@ -1006,14 +918,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupPolicies/{backupPolicyName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backup_vaults_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backup_vaults_operations.py new file mode 100644 index 000000000000..3fb562bc97a5 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backup_vaults_operations.py @@ -0,0 +1,945 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +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.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request + +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_by_net_app_account_request( + resource_group_name: str, account_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-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupVaults", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, account_name: str, backup_vault_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-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupVaults/{backupVaultName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + "backupVaultName": _SERIALIZER.url( + "backup_vault_name", backup_vault_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, account_name: str, backup_vault_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-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupVaults/{backupVaultName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + "backupVaultName": _SERIALIZER.url( + "backup_vault_name", backup_vault_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, account_name: str, backup_vault_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-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupVaults/{backupVaultName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + "backupVaultName": _SERIALIZER.url( + "backup_vault_name", backup_vault_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, account_name: str, backup_vault_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-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupVaults/{backupVaultName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + "backupVaultName": _SERIALIZER.url( + "backup_vault_name", backup_vault_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$" + ), + } + + _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class BackupVaultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.netapp.NetAppManagementClient`'s + :attr:`backup_vaults` 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_by_net_app_account( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BackupVault"]: + """Describe all Backup Vaults. + + List and describe all Backup Vaults in the NetApp account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :return: An iterator like instance of either BackupVault or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.netapp.models.BackupVault] + :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.BackupVaultsList] = 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_by_net_app_account_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BackupVaultsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, backup_vault_name: str, **kwargs: Any + ) -> _models.BackupVault: + """Describe the Backup Vault. + + Get the Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :return: BackupVault or the result of cls(response) + :rtype: ~azure.mgmt.netapp.models.BackupVault + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BackupVault] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BackupVault", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + body: Union[_models.BackupVault, IO[bytes]], + **kwargs: Any + ) -> _models.BackupVault: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackupVault] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "BackupVault") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BackupVault", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BackupVault", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + body: _models.BackupVault, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupVault]: + """Create or Update a Backup Vault. + + Create or update the specified Backup Vault in the NetApp account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param body: BackupVault object supplied in the body of the operation. Required. + :type body: ~azure.mgmt.netapp.models.BackupVault + :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 BackupVault or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.BackupVault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupVault]: + """Create or Update a Backup Vault. + + Create or update the specified Backup Vault in the NetApp account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param body: BackupVault object supplied in the body of the operation. Required. + :type body: 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 BackupVault or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.BackupVault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + body: Union[_models.BackupVault, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.BackupVault]: + """Create or Update a Backup Vault. + + Create or update the specified Backup Vault in the NetApp account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param body: BackupVault object supplied in the body of the operation. Is either a BackupVault + type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.BackupVault or IO[bytes] + :return: An instance of LROPoller that returns either BackupVault or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.BackupVault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackupVault] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("BackupVault", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.BackupVault].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.BackupVault]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + body: Union[_models.BackupVaultPatch, IO[bytes]], + **kwargs: Any + ) -> _models.BackupVault: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackupVault] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "BackupVaultPatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("BackupVault", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("BackupVault", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + body: _models.BackupVaultPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupVault]: + """Update NetApp Backup Vault. + + Patch the specified NetApp Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param body: Backup Vault object supplied in the body of the operation. Required. + :type body: ~azure.mgmt.netapp.models.BackupVaultPatch + :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 BackupVault or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.BackupVault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupVault]: + """Update NetApp Backup Vault. + + Patch the specified NetApp Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param body: Backup Vault object supplied in the body of the operation. Required. + :type body: 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 BackupVault or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.BackupVault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + body: Union[_models.BackupVaultPatch, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.BackupVault]: + """Update NetApp Backup Vault. + + Patch the specified NetApp Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param body: Backup Vault object supplied in the body of the operation. Is either a + BackupVaultPatch type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.BackupVaultPatch or IO[bytes] + :return: An instance of LROPoller that returns either BackupVault or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.BackupVault] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.BackupVault] = 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._update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("BackupVault", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.BackupVault].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.BackupVault]( + 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, account_name: str, backup_vault_name: str, **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, backup_vault_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete NetApp Backup Vault. + + Delete the specified Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: 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: + """ + _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[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._delete_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backups_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backups_operations.py index 06981e940cf8..73d5c5924260 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backups_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backups_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,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,17 +19,24 @@ ResourceNotModifiedError, map_error, ) +from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models from .._serialization import Serializer from .._vendor import _convert_request +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]] @@ -34,19 +44,19 @@ _SERIALIZER.client_side_validation = False -def build_get_volume_restore_status_request( +def build_get_latest_status_request( resource_group_name: str, account_name: str, pool_name: str, volume_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/restoreStatus", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/latestBackupStatus/current", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -75,6 +85,283 @@ def build_get_volume_restore_status_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_get_volume_latest_restore_status_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, pool_name: str, volume_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-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/latestRestoreStatus/current", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + "poolName": _SERIALIZER.url( + "pool_name", pool_name, "str", max_length=64, min_length=1, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$" + ), + "volumeName": _SERIALIZER.url( + "volume_name", volume_name, "str", max_length=64, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_vault_request( + resource_group_name: str, + account_name: str, + backup_vault_name: str, + subscription_id: str, + *, + filter: 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-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupVaults/{backupVaultName}/backups", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + "backupVaultName": _SERIALIZER.url( + "backup_vault_name", backup_vault_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_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-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupVaults/{backupVaultName}/backups/{backupName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + "backupVaultName": _SERIALIZER.url( + "backup_vault_name", backup_vault_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$" + ), + "backupName": _SERIALIZER.url( + "backup_name", backup_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_.]{0,255}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_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-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupVaults/{backupVaultName}/backups/{backupName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + "backupVaultName": _SERIALIZER.url( + "backup_vault_name", backup_vault_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$" + ), + "backupName": _SERIALIZER.url( + "backup_name", backup_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_.]{0,255}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_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-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupVaults/{backupVaultName}/backups/{backupName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + "backupVaultName": _SERIALIZER.url( + "backup_vault_name", backup_vault_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$" + ), + "backupName": _SERIALIZER.url( + "backup_name", backup_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_.]{0,255}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_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-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupVaults/{backupVaultName}/backups/{backupName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + "backupVaultName": _SERIALIZER.url( + "backup_vault_name", backup_vault_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$" + ), + "backupName": _SERIALIZER.url( + "backup_name", backup_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_.]{0,255}$" + ), + } + + _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + class BackupsOperations: """ .. warning:: @@ -95,12 +382,79 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get_volume_restore_status( + def get_latest_status( + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any + ) -> _models.BackupStatus: + """Get the latest backup status of a volume. + + Get the latest status of the backup for a volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: str + :return: BackupStatus or the result of cls(response) + :rtype: ~azure.mgmt.netapp.models.BackupStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.BackupStatus] = kwargs.pop("cls", None) + + _request = build_get_latest_status_request( + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BackupStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_volume_latest_restore_status( self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any ) -> _models.RestoreStatus: - """Get volume's restore status. + """Get the latest restore status of a volume. - Get the status of the restore for a volume. + Get the latest status of the restore for a volume. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -111,12 +465,11 @@ def get_volume_restore_status( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RestoreStatus or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.RestoreStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -130,23 +483,22 @@ def get_volume_restore_status( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RestoreStatus] = kwargs.pop("cls", None) - request = build_get_volume_restore_status_request( + _request = build_get_volume_latest_restore_status_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_volume_restore_status.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -159,10 +511,734 @@ def get_volume_restore_status( deserialized = self._deserialize("RestoreStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - get_volume_restore_status.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/restoreStatus" - } + @distributed_trace + def list_by_vault( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.Backup"]: + """List Backups. + + List all backups Under a Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param filter: An option to specify the VolumeResourceId. If present, then only returns the + backups under the specified volume. Default value is None. + :type filter: str + :return: An iterator like instance of either Backup or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.netapp.models.Backup] + :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.BackupsList] = 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_by_vault_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BackupsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, backup_vault_name: str, backup_name: str, **kwargs: Any + ) -> _models.Backup: + """Describe the Backup under Backup Vault. + + Get the specified Backup under Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :return: Backup or the result of cls(response) + :rtype: ~azure.mgmt.netapp.models.Backup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Backup] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Backup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: Union[_models.Backup, IO[bytes]], + **kwargs: Any + ) -> _models.Backup: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Backup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "Backup") + + _request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Backup", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Backup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: _models.Backup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Backup]: + """Create a backup. + + Create a backup under the Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Backup object supplied in the body of the operation. Required. + :type body: ~azure.mgmt.netapp.models.Backup + :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 Backup or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.Backup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Backup]: + """Create a backup. + + Create a backup under the Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Backup object supplied in the body of the operation. Required. + :type body: 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 Backup or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.Backup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: Union[_models.Backup, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Backup]: + """Create a backup. + + Create a backup under the Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Backup object supplied in the body of the operation. Is either a Backup type or a + IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.Backup or IO[bytes] + :return: An instance of LROPoller that returns either Backup or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.Backup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Backup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Backup", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Backup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Backup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: Optional[Union[_models.BackupPatch, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.Backup: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Backup] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "BackupPatch") + else: + _json = None + + _request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("Backup", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("Backup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: Optional[_models.BackupPatch] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Backup]: + """Patch a backup. + + Patch a Backup under the Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Backup object supplied in the body of the operation. Default value is None. + :type body: ~azure.mgmt.netapp.models.BackupPatch + :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 Backup or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.Backup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Backup]: + """Patch a backup. + + Patch a Backup under the Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Backup object supplied in the body of the operation. Default value is None. + :type body: 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 Backup or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.Backup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: Optional[Union[_models.BackupPatch, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.Backup]: + """Patch a backup. + + Patch a Backup under the Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Backup object supplied in the body of the operation. Is either a BackupPatch type + or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.netapp.models.BackupPatch or IO[bytes] + :return: An instance of LROPoller that returns either Backup or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.Backup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Backup] = 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._update_initial( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Backup", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Backup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Backup]( + 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, account_name: str, backup_vault_name: str, backup_name: str, **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, account_name: str, backup_vault_name: str, backup_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete backup. + + Delete a Backup under the Backup Vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: 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: + """ + _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[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._delete_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backups_under_account_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backups_under_account_operations.py new file mode 100644 index 000000000000..908a308259c6 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backups_under_account_operations.py @@ -0,0 +1,290 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request + +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_migrate_backups_request( + resource_group_name: str, account_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-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/migrateBackups", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class BackupsUnderAccountOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.netapp.NetAppManagementClient`'s + :attr:`backups_under_account` 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") + + def _migrate_backups_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + body: Union[_models.BackupsMigrationRequest, IO[bytes]], + **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "BackupsMigrationRequest") + + _request = build_migrate_backups_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @overload + def begin_migrate_backups( + self, + resource_group_name: str, + account_name: str, + body: _models.BackupsMigrationRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create a new migrate request for backups under account. + + Migrate the backups under a NetApp account to backup vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: Migrate backups under an account payload supplied in the body of the operation. + Required. + :type body: ~azure.mgmt.netapp.models.BackupsMigrationRequest + :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_migrate_backups( + self, + resource_group_name: str, + account_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create a new migrate request for backups under account. + + Migrate the backups under a NetApp account to backup vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: Migrate backups under an account payload supplied in the body of the operation. + Required. + :type body: 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_migrate_backups( + self, + resource_group_name: str, + account_name: str, + body: Union[_models.BackupsMigrationRequest, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Create a new migrate request for backups under account. + + Migrate the backups under a NetApp account to backup vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param body: Migrate backups under an account payload supplied in the body of the operation. Is + either a BackupsMigrationRequest type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.BackupsMigrationRequest 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 = 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._migrate_backups_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backups_under_backup_vault_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backups_under_backup_vault_operations.py new file mode 100644 index 000000000000..352207f2c319 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backups_under_backup_vault_operations.py @@ -0,0 +1,323 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request + +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_restore_files_request( + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_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-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/backupVaults/{backupVaultName}/backups/{backupName}/restoreFiles", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + "backupVaultName": _SERIALIZER.url( + "backup_vault_name", backup_vault_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$" + ), + "backupName": _SERIALIZER.url( + "backup_name", backup_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_.]{0,255}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class BackupsUnderBackupVaultOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.netapp.NetAppManagementClient`'s + :attr:`backups_under_backup_vault` 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") + + def _restore_files_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: Union[_models.BackupRestoreFiles, IO[bytes]], + **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "BackupRestoreFiles") + + _request = build_restore_files_request( + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @overload + def begin_restore_files( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: _models.BackupRestoreFiles, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create a new Backup Restore Files request. + + Restore the specified files from the specified backup to the active filesystem. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Restore payload supplied in the body of the operation. Required. + :type body: ~azure.mgmt.netapp.models.BackupRestoreFiles + :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_restore_files( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create a new Backup Restore Files request. + + Restore the specified files from the specified backup to the active filesystem. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Restore payload supplied in the body of the operation. Required. + :type body: 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_restore_files( + self, + resource_group_name: str, + account_name: str, + backup_vault_name: str, + backup_name: str, + body: Union[_models.BackupRestoreFiles, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Create a new Backup Restore Files request. + + Restore the specified files from the specified backup to the active filesystem. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param backup_vault_name: The name of the Backup Vault. Required. + :type backup_vault_name: str + :param backup_name: The name of the backup. Required. + :type backup_name: str + :param body: Restore payload supplied in the body of the operation. Is either a + BackupRestoreFiles type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.BackupRestoreFiles 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 = 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._restore_files_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + backup_vault_name=backup_vault_name, + backup_name=backup_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backups_under_volume_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backups_under_volume_operations.py new file mode 100644 index 000000000000..e691cff094f0 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_backups_under_volume_operations.py @@ -0,0 +1,320 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request + +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_migrate_backups_request( + resource_group_name: str, account_name: str, pool_name: str, volume_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-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/migrateBackups", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + "poolName": _SERIALIZER.url( + "pool_name", pool_name, "str", max_length=64, min_length=1, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$" + ), + "volumeName": _SERIALIZER.url( + "volume_name", volume_name, "str", max_length=64, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class BackupsUnderVolumeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.netapp.NetAppManagementClient`'s + :attr:`backups_under_volume` 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") + + def _migrate_backups_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: Union[_models.BackupsMigrationRequest, IO[bytes]], + **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "BackupsMigrationRequest") + + _request = build_migrate_backups_request( + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @overload + def begin_migrate_backups( + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: _models.BackupsMigrationRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create a new migrate request for backups under volume. + + Migrate the backups under volume to backup vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: str + :param body: Migrate backups under volume payload supplied in the body of the operation. + Required. + :type body: ~azure.mgmt.netapp.models.BackupsMigrationRequest + :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_migrate_backups( + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Create a new migrate request for backups under volume. + + Migrate the backups under volume to backup vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: str + :param body: Migrate backups under volume payload supplied in the body of the operation. + Required. + :type body: 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_migrate_backups( + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: Union[_models.BackupsMigrationRequest, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Create a new migrate request for backups under volume. + + Migrate the backups under volume to backup vault. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: str + :param body: Migrate backups under volume payload supplied in the body of the operation. Is + either a BackupsMigrationRequest type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.BackupsMigrationRequest 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 = 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._migrate_backups_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_net_app_resource_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_net_app_resource_operations.py index 4ef24c9e831c..d55fd8a6d71e 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_net_app_resource_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_net_app_resource_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, Optional, Type, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ 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 +45,7 @@ def build_check_name_availability_request(location: str, subscription_id: str, * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -67,11 +72,13 @@ def build_check_name_availability_request(location: str, subscription_id: str, * return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_file_path_availability_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_check_file_path_availability_request( # pylint: disable=name-too-long + 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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -102,7 +109,7 @@ def build_check_quota_availability_request(location: str, subscription_id: str, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -133,7 +140,7 @@ def build_query_region_info_request(location: str, subscription_id: str, **kwarg _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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -160,7 +167,7 @@ def build_query_network_sibling_set_request(location: str, subscription_id: str, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -191,7 +198,7 @@ def build_update_network_sibling_set_request(location: str, subscription_id: str _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -261,12 +268,11 @@ def check_name_availability( :type type: str or ~azure.mgmt.netapp.models.CheckNameResourceTypes :param resource_group: Resource group name. Required. :type resource_group: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckAvailabilityResponse or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.CheckAvailabilityResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -284,22 +290,21 @@ def check_name_availability( _body = _models.ResourceNameAvailabilityRequest(name=name, resource_group=resource_group, type=type) _json = self._serialize.body(_body, "ResourceNameAvailabilityRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - 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 = _convert_request(_request) + _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,17 +317,13 @@ def check_name_availability( deserialized = self._deserialize("CheckAvailabilityResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace def check_file_path_availability( - self, location: str, name: str, subnet_id: str, **kwargs: Any + self, location: str, name: str, subnet_id: str, availability_zone: Optional[str] = None, **kwargs: Any ) -> _models.CheckAvailabilityResponse: """Check file path availability. @@ -335,12 +336,15 @@ def check_file_path_availability( :param subnet_id: The Azure Resource URI for a delegated subnet. Must have the delegation Microsoft.NetApp/volumes. Required. :type subnet_id: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param availability_zone: The Azure Resource logical availability zone which is used within + zone mapping lookup for the subscription and region. The lookup will retrieve the physical zone + where volume is placed. Default value is None. + :type availability_zone: str :return: CheckAvailabilityResponse or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.CheckAvailabilityResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -355,25 +359,24 @@ def check_file_path_availability( content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) cls: ClsType[_models.CheckAvailabilityResponse] = kwargs.pop("cls", None) - _body = _models.FilePathAvailabilityRequest(name=name, subnet_id=subnet_id) + _body = _models.FilePathAvailabilityRequest(availability_zone=availability_zone, name=name, subnet_id=subnet_id) _json = self._serialize.body(_body, "FilePathAvailabilityRequest") - request = build_check_file_path_availability_request( + _request = build_check_file_path_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_file_path_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -386,13 +389,9 @@ def check_file_path_availability( deserialized = self._deserialize("CheckAvailabilityResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - check_file_path_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/checkFilePathAvailability" - } + return deserialized # type: ignore @distributed_trace def check_quota_availability( @@ -418,12 +417,11 @@ def check_quota_availability( :type type: str or ~azure.mgmt.netapp.models.CheckQuotaNameResourceTypes :param resource_group: Resource group name. Required. :type resource_group: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckAvailabilityResponse or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.CheckAvailabilityResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -441,22 +439,21 @@ def check_quota_availability( _body = _models.QuotaAvailabilityRequest(name=name, resource_group=resource_group, type=type) _json = self._serialize.body(_body, "QuotaAvailabilityRequest") - request = build_check_quota_availability_request( + _request = build_check_quota_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_quota_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -469,13 +466,9 @@ def check_quota_availability( deserialized = self._deserialize("CheckAvailabilityResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - check_quota_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/checkQuotaAvailability" - } + return deserialized # type: ignore @distributed_trace def query_region_info(self, location: str, **kwargs: Any) -> _models.RegionInfo: @@ -485,12 +478,11 @@ def query_region_info(self, location: str, **kwargs: Any) -> _models.RegionInfo: :param location: The name of the Azure region. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RegionInfo or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.RegionInfo :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -504,20 +496,19 @@ def query_region_info(self, location: str, **kwargs: Any) -> _models.RegionInfo: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RegionInfo] = kwargs.pop("cls", None) - request = build_query_region_info_request( + _request = build_query_region_info_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.query_region_info.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -530,13 +521,9 @@ def query_region_info(self, location: str, **kwargs: Any) -> _models.RegionInfo: deserialized = self._deserialize("RegionInfo", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - query_region_info.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/regionInfo" - } + return deserialized # type: ignore @distributed_trace def query_network_sibling_set( @@ -556,12 +543,11 @@ def query_network_sibling_set( /subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/{mySubnet}. Required. :type subnet_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NetworkSiblingSet or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.NetworkSiblingSet :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -581,22 +567,21 @@ def query_network_sibling_set( ) _json = self._serialize.body(_body, "QueryNetworkSiblingSetRequest") - request = build_query_network_sibling_set_request( + _request = build_query_network_sibling_set_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.query_network_sibling_set.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -609,13 +594,9 @@ def query_network_sibling_set( deserialized = self._deserialize("NetworkSiblingSet", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - query_network_sibling_set.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/queryNetworkSiblingSet" - } + return deserialized # type: ignore def _update_network_sibling_set_initial( self, @@ -626,7 +607,7 @@ def _update_network_sibling_set_initial( network_features: Union[str, _models.NetworkFeatures] = "Basic", **kwargs: Any ) -> Optional[_models.NetworkSiblingSet]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -649,22 +630,21 @@ def _update_network_sibling_set_initial( ) _json = self._serialize.body(_body, "UpdateNetworkSiblingSetRequest") - request = build_update_network_sibling_set_request( + _request = build_update_network_sibling_set_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_network_sibling_set_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -683,13 +663,9 @@ def _update_network_sibling_set_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _update_network_sibling_set_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/updateNetworkSiblingSet" - } + return deserialized # type: ignore @distributed_trace def begin_update_network_sibling_set( @@ -718,17 +694,9 @@ def begin_update_network_sibling_set( :param network_sibling_set_state_id: Network sibling set state Id identifying the current state of the sibling set. Required. :type network_sibling_set_state_id: str - :param network_features: Network features available to the volume, some such. Known values are: - "Basic", "Standard", "Basic_Standard", and "Standard_Basic". Default value is "Basic". + :param network_features: Network features available to the volume. Known values are: "Basic", + "Standard", "Basic_Standard", and "Standard_Basic". Default value is "Basic". :type network_features: str or ~azure.mgmt.netapp.models.NetworkFeatures - :keyword callable cls: A custom type or function that will be passed the direct response - :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 NetworkSiblingSet or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.NetworkSiblingSet] @@ -762,7 +730,7 @@ def begin_update_network_sibling_set( def get_long_running_output(pipeline_response): deserialized = self._deserialize("NetworkSiblingSet", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -774,14 +742,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.NetworkSiblingSet].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_network_sibling_set.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/updateNetworkSiblingSet" - } + return LROPoller[_models.NetworkSiblingSet]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_net_app_resource_quota_limits_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_net_app_resource_quota_limits_operations.py index c83c3064376d..45863df50c4a 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_net_app_resource_quota_limits_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_net_app_resource_quota_limits_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 ( @@ -29,6 +30,10 @@ 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 +45,7 @@ def build_list_request(location: str, subscription_id: str, **kwargs: Any) -> Ht _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +72,7 @@ def build_get_request(location: str, quota_limit_name: 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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,7 +124,6 @@ def list(self, location: str, **kwargs: Any) -> Iterable["_models.SubscriptionQu :param location: The name of the Azure region. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SubscriptionQuotaItem or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.netapp.models.SubscriptionQuotaItem] @@ -131,7 +135,7 @@ def list(self, location: str, **kwargs: Any) -> Iterable["_models.SubscriptionQu api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubscriptionQuotaItemList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -142,16 +146,15 @@ def list(self, location: str, **kwargs: Any) -> Iterable["_models.SubscriptionQu def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -163,13 +166,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SubscriptionQuotaItemList", pipeline_response) @@ -179,11 +182,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -196,10 +199,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/quotaLimits" - } - @distributed_trace def get(self, location: str, quota_limit_name: str, **kwargs: Any) -> _models.SubscriptionQuotaItem: """Get quota limits. @@ -210,12 +209,11 @@ def get(self, location: str, quota_limit_name: str, **kwargs: Any) -> _models.Su :type location: str :param quota_limit_name: The name of the Quota Limit. Required. :type quota_limit_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionQuotaItem or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.SubscriptionQuotaItem :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -229,21 +227,20 @@ def get(self, location: str, quota_limit_name: str, **kwargs: Any) -> _models.Su api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubscriptionQuotaItem] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( location=location, quota_limit_name=quota_limit_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 = _convert_request(_request) + _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 @@ -256,10 +253,6 @@ def get(self, location: str, quota_limit_name: str, **kwargs: Any) -> _models.Su deserialized = self._deserialize("SubscriptionQuotaItem", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/quotaLimits/{quotaLimitName}" - } + return deserialized # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_net_app_resource_region_infos_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_net_app_resource_region_infos_operations.py new file mode 100644 index 000000000000..4c5c7a4dc9a1 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_net_app_resource_region_infos_operations.py @@ -0,0 +1,253 @@ +# 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.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request + +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(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-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/regionInfos" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(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-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.NetApp/locations/{location}/regionInfos/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + } + + _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 NetAppResourceRegionInfosOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.netapp.NetAppManagementClient`'s + :attr:`net_app_resource_region_infos` 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, location: str, **kwargs: Any) -> Iterable["_models.RegionInfoResource"]: + """Describes region specific information. + + Provides region specific information. + + :param location: The name of the Azure region. Required. + :type location: str + :return: An iterator like instance of either RegionInfoResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.netapp.models.RegionInfoResource] + :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.RegionInfosList] = 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( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RegionInfosList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, location: str, **kwargs: Any) -> _models.RegionInfoResource: + """Describes region specific information. + + Provides storage to network proximity and logical zone mapping information. + + :param location: The name of the Azure region. Required. + :type location: str + :return: RegionInfoResource or the result of cls(response) + :rtype: ~azure.mgmt.netapp.models.RegionInfoResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.RegionInfoResource] = kwargs.pop("cls", None) + + _request = build_get_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("RegionInfoResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_operations.py index f6dce2460aeb..9b811a4dca90 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/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 ( @@ -29,6 +30,10 @@ 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 +45,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,7 +85,6 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: Lists all of the available Microsoft.NetApp Rest API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.netapp.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -91,7 +95,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -102,14 +106,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -121,13 +124,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -137,11 +140,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -153,5 +156,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.NetApp/operations"} diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_pools_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_pools_operations.py index 07ed18f396c9..d1296acd7d8c 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_pools_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_pools_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, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -32,6 +33,10 @@ from .._serialization import Serializer from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +48,7 @@ def build_list_request(resource_group_name: str, account_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +83,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -116,7 +121,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -157,7 +162,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -198,7 +203,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -260,7 +265,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It :type resource_group_name: str :param account_name: The name of the NetApp account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CapacityPool or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.netapp.models.CapacityPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -271,7 +275,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CapacityPoolList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -282,17 +286,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -304,13 +307,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("CapacityPoolList", pipeline_response) @@ -320,11 +323,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 @@ -337,10 +340,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools" - } - @distributed_trace def get(self, resource_group_name: str, account_name: str, pool_name: str, **kwargs: Any) -> _models.CapacityPool: """Describe a Capacity Pool. @@ -354,12 +353,11 @@ def get(self, resource_group_name: str, account_name: str, pool_name: str, **kwa :type account_name: str :param pool_name: The name of the capacity pool. Required. :type pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CapacityPool or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.CapacityPool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -373,22 +371,21 @@ def get(self, resource_group_name: str, account_name: str, pool_name: str, **kwa api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CapacityPool] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_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 = _convert_request(_request) + _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 @@ -401,23 +398,19 @@ def get(self, resource_group_name: str, account_name: str, pool_name: str, **kwa deserialized = self._deserialize("CapacityPool", pipeline_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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, account_name: str, pool_name: str, - body: Union[_models.CapacityPool, IO], + body: Union[_models.CapacityPool, IO[bytes]], **kwargs: Any ) -> _models.CapacityPool: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -440,7 +433,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(body, "CapacityPool") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -449,16 +442,15 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -479,10 +471,6 @@ def _create_or_update_initial( return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}" - } - @overload def begin_create_or_update( self, @@ -510,14 +498,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either CapacityPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.CapacityPool] @@ -530,7 +510,7 @@ def begin_create_or_update( resource_group_name: str, account_name: str, pool_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -547,18 +527,10 @@ def begin_create_or_update( :param pool_name: The name of the capacity pool. Required. :type pool_name: str :param body: Capacity pool object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 CapacityPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.CapacityPool] @@ -571,7 +543,7 @@ def begin_create_or_update( resource_group_name: str, account_name: str, pool_name: str, - body: Union[_models.CapacityPool, IO], + body: Union[_models.CapacityPool, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.CapacityPool]: """Create or Update the specified capacity pool within the resource group. @@ -586,19 +558,8 @@ def begin_create_or_update( :param pool_name: The name of the capacity pool. Required. :type pool_name: str :param body: Capacity pool object supplied in the body of the operation. Is either a - CapacityPool type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.CapacityPool 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. + CapacityPool type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.CapacityPool or IO[bytes] :return: An instance of LROPoller that returns either CapacityPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.CapacityPool] @@ -631,7 +592,7 @@ def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("CapacityPool", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -643,27 +604,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.CapacityPool].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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}" - } + return LROPoller[_models.CapacityPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, account_name: str, pool_name: str, - body: Union[_models.CapacityPoolPatch, IO], + body: Union[_models.CapacityPoolPatch, IO[bytes]], **kwargs: Any ) -> Optional[_models.CapacityPool]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -686,7 +645,7 @@ def _update_initial( else: _json = self._serialize.body(body, "CapacityPoolPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -695,16 +654,15 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -719,13 +677,9 @@ def _update_initial( deserialized = self._deserialize("CapacityPool", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -754,14 +708,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either CapacityPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.CapacityPool] @@ -774,7 +720,7 @@ def begin_update( resource_group_name: str, account_name: str, pool_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -791,18 +737,10 @@ def begin_update( :param pool_name: The name of the capacity pool. Required. :type pool_name: str :param body: Capacity pool object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 CapacityPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.CapacityPool] @@ -815,7 +753,7 @@ def begin_update( resource_group_name: str, account_name: str, pool_name: str, - body: Union[_models.CapacityPoolPatch, IO], + body: Union[_models.CapacityPoolPatch, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.CapacityPool]: """Update a capacity pool. @@ -830,19 +768,8 @@ def begin_update( :param pool_name: The name of the capacity pool. Required. :type pool_name: str :param body: Capacity pool object supplied in the body of the operation. Is either a - CapacityPoolPatch type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.CapacityPoolPatch 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. + CapacityPoolPatch type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.CapacityPoolPatch or IO[bytes] :return: An instance of LROPoller that returns either CapacityPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.CapacityPool] @@ -875,7 +802,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("CapacityPool", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -887,22 +814,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.CapacityPool].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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}" - } + return LROPoller[_models.CapacityPool]( + 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, account_name: str, pool_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -916,22 +841,21 @@ def _delete_initial( # 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, account_name=account_name, pool_name=pool_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 = _convert_request(_request) + _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 @@ -942,11 +866,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_delete( @@ -963,14 +883,6 @@ def begin_delete( :type account_name: str :param pool_name: The name of the capacity pool. Required. :type pool_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: @@ -998,7 +910,7 @@ def begin_delete( 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( @@ -1009,14 +921,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_snapshot_policies_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_snapshot_policies_operations.py index 23695c38be34..45896718e813 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_snapshot_policies_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_snapshot_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, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -32,6 +33,10 @@ from .._serialization import Serializer from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +48,7 @@ def build_list_request(resource_group_name: str, account_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +83,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +119,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -153,7 +158,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -192,7 +197,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -228,7 +233,7 @@ def build_list_volumes_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -286,7 +291,6 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It :type resource_group_name: str :param account_name: The name of the NetApp account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SnapshotPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.netapp.models.SnapshotPolicy] :raises ~azure.core.exceptions.HttpResponseError: @@ -297,7 +301,7 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SnapshotPoliciesList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -308,17 +312,16 @@ def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -330,13 +333,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SnapshotPoliciesList", pipeline_response) @@ -346,11 +349,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -363,10 +366,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, snapshot_policy_name: str, **kwargs: Any @@ -380,12 +379,11 @@ def get( :type account_name: str :param snapshot_policy_name: The name of the snapshot policy. Required. :type snapshot_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SnapshotPolicy or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.SnapshotPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,22 +397,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SnapshotPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, snapshot_policy_name=snapshot_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 = _convert_request(_request) + _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 @@ -427,13 +424,9 @@ def get( deserialized = self._deserialize("SnapshotPolicy", pipeline_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.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}" - } + return deserialized # type: ignore @overload def create( @@ -460,7 +453,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SnapshotPolicy or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.SnapshotPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -472,7 +464,7 @@ def create( resource_group_name: str, account_name: str, snapshot_policy_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -487,11 +479,10 @@ def create( :param snapshot_policy_name: The name of the snapshot policy. Required. :type snapshot_policy_name: str :param body: Snapshot policy object supplied in the body of the operation. Required. - :type body: IO + :type body: 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: SnapshotPolicy or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.SnapshotPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -503,7 +494,7 @@ def create( resource_group_name: str, account_name: str, snapshot_policy_name: str, - body: Union[_models.SnapshotPolicy, IO], + body: Union[_models.SnapshotPolicy, IO[bytes]], **kwargs: Any ) -> _models.SnapshotPolicy: """Create a snapshot policy. @@ -516,17 +507,13 @@ def create( :param snapshot_policy_name: The name of the snapshot policy. Required. :type snapshot_policy_name: str :param body: Snapshot policy object supplied in the body of the operation. Is either a - SnapshotPolicy type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.SnapshotPolicy 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 + SnapshotPolicy type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.SnapshotPolicy or IO[bytes] :return: SnapshotPolicy or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.SnapshotPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -549,7 +536,7 @@ def create( else: _json = self._serialize.body(body, "SnapshotPolicy") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, snapshot_policy_name=snapshot_policy_name, @@ -558,16 +545,15 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -588,19 +574,15 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}" - } - def _update_initial( self, resource_group_name: str, account_name: str, snapshot_policy_name: str, - body: Union[_models.SnapshotPolicyPatch, IO], + body: Union[_models.SnapshotPolicyPatch, IO[bytes]], **kwargs: Any ) -> _models.SnapshotPolicy: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -623,7 +605,7 @@ def _update_initial( else: _json = self._serialize.body(body, "SnapshotPolicyPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, snapshot_policy_name=snapshot_policy_name, @@ -632,16 +614,15 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -662,10 +643,6 @@ def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}" - } - @overload def begin_update( self, @@ -691,14 +668,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either SnapshotPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.SnapshotPolicy] @@ -711,7 +680,7 @@ def begin_update( resource_group_name: str, account_name: str, snapshot_policy_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -726,18 +695,10 @@ def begin_update( :param snapshot_policy_name: The name of the snapshot policy. Required. :type snapshot_policy_name: str :param body: Snapshot policy object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 SnapshotPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.SnapshotPolicy] @@ -750,7 +711,7 @@ def begin_update( resource_group_name: str, account_name: str, snapshot_policy_name: str, - body: Union[_models.SnapshotPolicyPatch, IO], + body: Union[_models.SnapshotPolicyPatch, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SnapshotPolicy]: """Patch a snapshot policy. @@ -763,19 +724,8 @@ def begin_update( :param snapshot_policy_name: The name of the snapshot policy. Required. :type snapshot_policy_name: str :param body: Snapshot policy object supplied in the body of the operation. Is either a - SnapshotPolicyPatch type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.SnapshotPolicyPatch 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. + SnapshotPolicyPatch type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.SnapshotPolicyPatch or IO[bytes] :return: An instance of LROPoller that returns either SnapshotPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.SnapshotPolicy] @@ -808,7 +758,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("SnapshotPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -820,22 +770,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SnapshotPolicy].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.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}" - } + return LROPoller[_models.SnapshotPolicy]( + 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, account_name: str, snapshot_policy_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -849,22 +797,21 @@ def _delete_initial( # 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, account_name=account_name, snapshot_policy_name=snapshot_policy_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 = _convert_request(_request) + _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 @@ -875,11 +822,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_delete( @@ -894,14 +837,6 @@ def begin_delete( :type account_name: str :param snapshot_policy_name: The name of the snapshot policy. Required. :type snapshot_policy_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: @@ -929,7 +864,7 @@ def begin_delete( 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( @@ -940,17 +875,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_volumes( @@ -967,12 +898,11 @@ def list_volumes( :type account_name: str :param snapshot_policy_name: The name of the snapshot policy. Required. :type snapshot_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SnapshotPolicyVolumeList or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.SnapshotPolicyVolumeList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -986,22 +916,21 @@ def list_volumes( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SnapshotPolicyVolumeList] = kwargs.pop("cls", None) - request = build_list_volumes_request( + _request = build_list_volumes_request( resource_group_name=resource_group_name, account_name=account_name, snapshot_policy_name=snapshot_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_volumes.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -1014,10 +943,6 @@ def list_volumes( deserialized = self._deserialize("SnapshotPolicyVolumeList", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_volumes.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/snapshotPolicies/{snapshotPolicyName}/volumes" - } + return deserialized # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_snapshots_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_snapshots_operations.py index 94c210816ea4..fd59485ca690 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_snapshots_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_snapshots_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -51,7 +51,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,7 +98,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -146,7 +146,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -199,7 +199,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -250,7 +250,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -298,7 +298,7 @@ def build_restore_files_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -373,7 +373,6 @@ def list( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Snapshot or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.netapp.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: @@ -384,7 +383,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SnapshotsList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -395,19 +394,18 @@ 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, account_name=account_name, pool_name=pool_name, volume_name=volume_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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -419,13 +417,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SnapshotsList", pipeline_response) @@ -435,11 +433,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -452,10 +450,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots" - } - @distributed_trace def get( self, @@ -481,12 +475,11 @@ def get( :type volume_name: str :param snapshot_name: The name of the snapshot. Required. :type snapshot_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Snapshot or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.Snapshot :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +493,7 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -508,16 +501,15 @@ def get( snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -530,13 +522,9 @@ def get( deserialized = self._deserialize("Snapshot", pipeline_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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}" - } + return deserialized # type: ignore def _create_initial( self, @@ -545,10 +533,10 @@ def _create_initial( pool_name: str, volume_name: str, snapshot_name: str, - body: Union[_models.Snapshot, IO], + body: Union[_models.Snapshot, IO[bytes]], **kwargs: Any ) -> Optional[_models.Snapshot]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -571,7 +559,7 @@ def _create_initial( else: _json = self._serialize.body(body, "Snapshot") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -582,16 +570,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -606,13 +593,9 @@ def _create_initial( deserialized = self._deserialize("Snapshot", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -647,14 +630,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: @@ -668,7 +643,7 @@ def begin_create( pool_name: str, volume_name: str, snapshot_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -689,18 +664,10 @@ def begin_create( :param snapshot_name: The name of the snapshot. Required. :type snapshot_name: str :param body: Snapshot object supplied in the body of the operation. Required. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: @@ -714,7 +681,7 @@ def begin_create( pool_name: str, volume_name: str, snapshot_name: str, - body: Union[_models.Snapshot, IO], + body: Union[_models.Snapshot, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Snapshot]: """Create a snapshot. @@ -733,19 +700,8 @@ def begin_create( :param snapshot_name: The name of the snapshot. Required. :type snapshot_name: str :param body: Snapshot object supplied in the body of the operation. Is either a Snapshot type - or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.Snapshot or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.Snapshot or IO[bytes] :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: @@ -779,7 +735,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Snapshot", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -791,17 +747,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Snapshot].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}" - } + return LROPoller[_models.Snapshot]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, @@ -813,7 +767,7 @@ def _update_initial( body: JSON, **kwargs: Any ) -> Optional[_models.Snapshot]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -830,7 +784,7 @@ def _update_initial( _json = self._serialize.body(body, "object") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -840,16 +794,15 @@ def _update_initial( api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -864,13 +817,9 @@ def _update_initial( deserialized = self._deserialize("Snapshot", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}" - } + return deserialized # type: ignore @distributed_trace def begin_update( @@ -900,14 +849,6 @@ def begin_update( :type snapshot_name: str :param body: Snapshot object supplied in the body of the operation. Required. :type body: JSON - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Snapshot or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.Snapshot] :raises ~azure.core.exceptions.HttpResponseError: @@ -941,7 +882,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Snapshot", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -953,17 +894,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Snapshot].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}" - } + return LROPoller[_models.Snapshot]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -974,7 +913,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -988,7 +927,7 @@ def _delete_initial( # 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, account_name=account_name, pool_name=pool_name, @@ -996,16 +935,15 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -1016,11 +954,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_delete( @@ -1047,14 +981,6 @@ def begin_delete( :type volume_name: str :param snapshot_name: The name of the snapshot. Required. :type snapshot_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1084,7 +1010,7 @@ def begin_delete( 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( @@ -1095,17 +1021,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _restore_files_initial( # pylint: disable=inconsistent-return-statements self, @@ -1114,10 +1036,10 @@ def _restore_files_initial( # pylint: disable=inconsistent-return-statements pool_name: str, volume_name: str, snapshot_name: str, - body: Union[_models.SnapshotRestoreFiles, IO], + body: Union[_models.SnapshotRestoreFiles, IO[bytes]], **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1140,7 +1062,7 @@ def _restore_files_initial( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(body, "SnapshotRestoreFiles") - request = build_restore_files_request( + _request = build_restore_files_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -1151,16 +1073,15 @@ def _restore_files_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self._restore_files_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -1171,11 +1092,7 @@ def _restore_files_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _restore_files_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}/restoreFiles" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def begin_restore_files( @@ -1210,14 +1127,6 @@ def begin_restore_files( :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: @@ -1231,7 +1140,7 @@ def begin_restore_files( pool_name: str, volume_name: str, snapshot_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1252,18 +1161,10 @@ def begin_restore_files( :param snapshot_name: The name of the snapshot. Required. :type snapshot_name: str :param body: Restore payload supplied in the body of the operation. Required. - :type body: IO + :type body: 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: @@ -1277,7 +1178,7 @@ def begin_restore_files( pool_name: str, volume_name: str, snapshot_name: str, - body: Union[_models.SnapshotRestoreFiles, IO], + body: Union[_models.SnapshotRestoreFiles, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Create a new Snapshot Restore Files request. @@ -1296,19 +1197,8 @@ def begin_restore_files( :param snapshot_name: The name of the snapshot. Required. :type snapshot_name: str :param body: Restore payload supplied in the body of the operation. Is either a - SnapshotRestoreFiles type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.SnapshotRestoreFiles 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. + SnapshotRestoreFiles type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.SnapshotRestoreFiles 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: @@ -1341,7 +1231,7 @@ def begin_restore_files( 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( @@ -1352,14 +1242,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_restore_files.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/snapshots/{snapshotName}/restoreFiles" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_subvolumes_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_subvolumes_operations.py index f063e552bbaa..00ed570db2d6 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_subvolumes_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_subvolumes_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, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -32,6 +33,10 @@ from .._serialization import Serializer from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_list_by_volume_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,7 +97,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -147,7 +152,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -205,7 +210,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -263,7 +268,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -318,7 +323,7 @@ def build_get_metadata_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -397,7 +402,6 @@ def list_by_volume( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SubvolumeInfo or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.netapp.models.SubvolumeInfo] :raises ~azure.core.exceptions.HttpResponseError: @@ -408,7 +412,7 @@ def list_by_volume( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubvolumesList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -419,19 +423,18 @@ def list_by_volume( def prepare_request(next_link=None): if not next_link: - request = build_list_by_volume_request( + _request = build_list_by_volume_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_volume.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -443,13 +446,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SubvolumesList", pipeline_response) @@ -459,11 +462,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 @@ -476,10 +479,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_volume.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes" - } - @distributed_trace def get( self, @@ -505,12 +504,11 @@ def get( :type volume_name: str :param subvolume_name: The name of the subvolume. Required. :type subvolume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SubvolumeInfo or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.SubvolumeInfo :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -524,7 +522,7 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SubvolumeInfo] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -532,16 +530,15 @@ def get( subvolume_name=subvolume_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 = _convert_request(_request) + _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 @@ -554,13 +551,9 @@ def get( deserialized = self._deserialize("SubvolumeInfo", pipeline_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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}" - } + return deserialized # type: ignore def _create_initial( self, @@ -569,10 +562,10 @@ def _create_initial( pool_name: str, volume_name: str, subvolume_name: str, - body: Union[_models.SubvolumeInfo, IO], + body: Union[_models.SubvolumeInfo, IO[bytes]], **kwargs: Any ) -> Optional[_models.SubvolumeInfo]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -595,7 +588,7 @@ def _create_initial( else: _json = self._serialize.body(body, "SubvolumeInfo") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -606,16 +599,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -633,13 +625,9 @@ def _create_initial( deserialized = self._deserialize("SubvolumeInfo", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -674,14 +662,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either SubvolumeInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.SubvolumeInfo] @@ -696,7 +676,7 @@ def begin_create( pool_name: str, volume_name: str, subvolume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -717,18 +697,10 @@ def begin_create( :param subvolume_name: The name of the subvolume. Required. :type subvolume_name: str :param body: Subvolume object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 SubvolumeInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.SubvolumeInfo] @@ -743,7 +715,7 @@ def begin_create( pool_name: str, volume_name: str, subvolume_name: str, - body: Union[_models.SubvolumeInfo, IO], + body: Union[_models.SubvolumeInfo, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SubvolumeInfo]: """Create or clone a new subvolume. @@ -762,19 +734,8 @@ def begin_create( :param subvolume_name: The name of the subvolume. Required. :type subvolume_name: str :param body: Subvolume object supplied in the body of the operation. Is either a SubvolumeInfo - type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.SubvolumeInfo or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.SubvolumeInfo or IO[bytes] :return: An instance of LROPoller that returns either SubvolumeInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.SubvolumeInfo] @@ -809,7 +770,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("SubvolumeInfo", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -821,17 +782,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SubvolumeInfo].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}" - } + return LROPoller[_models.SubvolumeInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, @@ -840,10 +799,10 @@ def _update_initial( pool_name: str, volume_name: str, subvolume_name: str, - body: Union[_models.SubvolumePatchRequest, IO], + body: Union[_models.SubvolumePatchRequest, IO[bytes]], **kwargs: Any ) -> Optional[_models.SubvolumeInfo]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -866,7 +825,7 @@ def _update_initial( else: _json = self._serialize.body(body, "SubvolumePatchRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -877,16 +836,15 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -901,13 +859,9 @@ def _update_initial( deserialized = self._deserialize("SubvolumeInfo", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -942,14 +896,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either SubvolumeInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.SubvolumeInfo] @@ -964,7 +910,7 @@ def begin_update( pool_name: str, volume_name: str, subvolume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -985,18 +931,10 @@ def begin_update( :param subvolume_name: The name of the subvolume. Required. :type subvolume_name: str :param body: Subvolume object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 SubvolumeInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.SubvolumeInfo] @@ -1011,7 +949,7 @@ def begin_update( pool_name: str, volume_name: str, subvolume_name: str, - body: Union[_models.SubvolumePatchRequest, IO], + body: Union[_models.SubvolumePatchRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SubvolumeInfo]: """Update a subvolume. @@ -1030,19 +968,8 @@ def begin_update( :param subvolume_name: The name of the subvolume. Required. :type subvolume_name: str :param body: Subvolume object supplied in the body of the operation. Is either a - SubvolumePatchRequest type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.SubvolumePatchRequest 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. + SubvolumePatchRequest type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.SubvolumePatchRequest or IO[bytes] :return: An instance of LROPoller that returns either SubvolumeInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.SubvolumeInfo] @@ -1077,7 +1004,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("SubvolumeInfo", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1089,17 +1016,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SubvolumeInfo].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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}" - } + return LROPoller[_models.SubvolumeInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -1110,7 +1035,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subvolume_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1124,7 +1049,7 @@ def _delete_initial( # 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, account_name=account_name, pool_name=pool_name, @@ -1132,16 +1057,15 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subvolume_name=subvolume_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 = _convert_request(_request) + _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 @@ -1152,11 +1076,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_delete( @@ -1183,14 +1103,6 @@ def begin_delete( :type volume_name: str :param subvolume_name: The name of the subvolume. Required. :type subvolume_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: @@ -1220,7 +1132,7 @@ def begin_delete( 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( @@ -1231,17 +1143,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _get_metadata_initial( self, @@ -1252,7 +1160,7 @@ def _get_metadata_initial( subvolume_name: str, **kwargs: Any ) -> Optional[_models.SubvolumeModel]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1266,7 +1174,7 @@ def _get_metadata_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.SubvolumeModel]] = kwargs.pop("cls", None) - request = build_get_metadata_request( + _request = build_get_metadata_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -1274,16 +1182,15 @@ def _get_metadata_initial( subvolume_name=subvolume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._get_metadata_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -1298,13 +1205,9 @@ def _get_metadata_initial( deserialized = self._deserialize("SubvolumeModel", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _get_metadata_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}/getMetadata" - } + return deserialized # type: ignore @distributed_trace def begin_get_metadata( @@ -1331,14 +1234,6 @@ def begin_get_metadata( :type volume_name: str :param subvolume_name: The name of the subvolume. Required. :type subvolume_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 SubvolumeModel or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.SubvolumeModel] @@ -1370,7 +1265,7 @@ def begin_get_metadata( def get_long_running_output(pipeline_response): deserialized = self._deserialize("SubvolumeModel", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1382,14 +1277,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SubvolumeModel].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_get_metadata.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/subvolumes/{subvolumeName}/getMetadata" - } + return LROPoller[_models.SubvolumeModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_volume_groups_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_volume_groups_operations.py index 05c83bcc8e97..9fa423dd755f 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_volume_groups_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_volume_groups_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -32,6 +33,10 @@ from .._serialization import Serializer from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_list_by_net_app_account_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,7 +85,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -123,7 +128,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -169,7 +174,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -238,7 +243,6 @@ def list_by_net_app_account( :type resource_group_name: str :param account_name: The name of the NetApp account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VolumeGroup or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.netapp.models.VolumeGroup] :raises ~azure.core.exceptions.HttpResponseError: @@ -249,7 +253,7 @@ def list_by_net_app_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VolumeGroupList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -260,17 +264,16 @@ def list_by_net_app_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_net_app_account_request( + _request = build_list_by_net_app_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_net_app_account.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -282,13 +285,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("VolumeGroupList", pipeline_response) @@ -298,11 +301,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -315,10 +318,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_net_app_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/volumeGroups" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, volume_group_name: str, **kwargs: Any @@ -334,12 +333,11 @@ def get( :type account_name: str :param volume_group_name: The name of the volumeGroup. Required. :type volume_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VolumeGroupDetails or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.VolumeGroupDetails :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -353,22 +351,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VolumeGroupDetails] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, volume_group_name=volume_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -381,23 +378,19 @@ def get( deserialized = self._deserialize("VolumeGroupDetails", pipeline_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.NetApp/netAppAccounts/{accountName}/volumeGroups/{volumeGroupName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, volume_group_name: str, - body: Union[_models.VolumeGroupDetails, IO], + body: Union[_models.VolumeGroupDetails, IO[bytes]], **kwargs: Any ) -> _models.VolumeGroupDetails: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -420,7 +413,7 @@ def _create_initial( else: _json = self._serialize.body(body, "VolumeGroupDetails") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, volume_group_name=volume_group_name, @@ -429,16 +422,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -451,13 +443,9 @@ def _create_initial( deserialized = self._deserialize("VolumeGroupDetails", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/volumeGroups/{volumeGroupName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -488,14 +476,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either VolumeGroupDetails or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.VolumeGroupDetails] @@ -508,7 +488,7 @@ def begin_create( resource_group_name: str, account_name: str, volume_group_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -527,18 +507,10 @@ def begin_create( :param volume_group_name: The name of the volumeGroup. Required. :type volume_group_name: str :param body: Volume Group object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 VolumeGroupDetails or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.VolumeGroupDetails] @@ -551,7 +523,7 @@ def begin_create( resource_group_name: str, account_name: str, volume_group_name: str, - body: Union[_models.VolumeGroupDetails, IO], + body: Union[_models.VolumeGroupDetails, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VolumeGroupDetails]: """Create the specified volume group and volumes. Creating volume group will create all the @@ -568,19 +540,8 @@ def begin_create( :param volume_group_name: The name of the volumeGroup. Required. :type volume_group_name: str :param body: Volume Group object supplied in the body of the operation. Is either a - VolumeGroupDetails type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.VolumeGroupDetails 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. + VolumeGroupDetails type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.VolumeGroupDetails or IO[bytes] :return: An instance of LROPoller that returns either VolumeGroupDetails or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.VolumeGroupDetails] @@ -613,7 +574,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("VolumeGroupDetails", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -623,22 +584,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VolumeGroupDetails].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/volumeGroups/{volumeGroupName}" - } + return LROPoller[_models.VolumeGroupDetails]( + 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, account_name: str, volume_group_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -652,22 +611,21 @@ def _delete_initial( # 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, account_name=account_name, volume_group_name=volume_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -678,11 +636,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/volumeGroups/{volumeGroupName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_delete( @@ -699,14 +653,6 @@ def begin_delete( :type account_name: str :param volume_group_name: The name of the volumeGroup. Required. :type volume_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -734,7 +680,7 @@ def begin_delete( 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)) @@ -743,14 +689,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/volumeGroups/{volumeGroupName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_volume_quota_rules_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_volume_quota_rules_operations.py index 0f58c81d7b5d..e6c694342af3 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_volume_quota_rules_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_volume_quota_rules_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, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -32,6 +33,10 @@ from .._serialization import Serializer from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_list_by_volume_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,7 +97,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -140,7 +145,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -191,7 +196,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -242,7 +247,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -314,7 +319,6 @@ def list_by_volume( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VolumeQuotaRule or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.netapp.models.VolumeQuotaRule] :raises ~azure.core.exceptions.HttpResponseError: @@ -325,7 +329,7 @@ def list_by_volume( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VolumeQuotaRulesList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -336,19 +340,18 @@ def list_by_volume( def prepare_request(next_link=None): if not next_link: - request = build_list_by_volume_request( + _request = build_list_by_volume_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_volume.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -360,13 +363,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("VolumeQuotaRulesList", pipeline_response) @@ -376,11 +379,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -393,10 +396,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_volume.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/volumeQuotaRules" - } - @distributed_trace def get( self, @@ -422,12 +421,11 @@ def get( :type volume_name: str :param volume_quota_rule_name: The name of volume quota rule. Required. :type volume_quota_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VolumeQuotaRule or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.VolumeQuotaRule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -441,7 +439,7 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VolumeQuotaRule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -449,16 +447,15 @@ def get( volume_quota_rule_name=volume_quota_rule_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 = _convert_request(_request) + _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 @@ -471,13 +468,9 @@ def get( deserialized = self._deserialize("VolumeQuotaRule", pipeline_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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/volumeQuotaRules/{volumeQuotaRuleName}" - } + return deserialized # type: ignore def _create_initial( self, @@ -486,10 +479,10 @@ def _create_initial( pool_name: str, volume_name: str, volume_quota_rule_name: str, - body: Union[_models.VolumeQuotaRule, IO], + body: Union[_models.VolumeQuotaRule, IO[bytes]], **kwargs: Any ) -> _models.VolumeQuotaRule: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -512,7 +505,7 @@ def _create_initial( else: _json = self._serialize.body(body, "VolumeQuotaRule") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -523,16 +516,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -553,10 +545,6 @@ def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/volumeQuotaRules/{volumeQuotaRuleName}" - } - @overload def begin_create( self, @@ -590,14 +578,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either VolumeQuotaRule or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.VolumeQuotaRule] @@ -612,7 +592,7 @@ def begin_create( pool_name: str, volume_name: str, volume_quota_rule_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -633,18 +613,10 @@ def begin_create( :param volume_quota_rule_name: The name of volume quota rule. Required. :type volume_quota_rule_name: str :param body: Quota rule object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 VolumeQuotaRule or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.VolumeQuotaRule] @@ -659,7 +631,7 @@ def begin_create( pool_name: str, volume_name: str, volume_quota_rule_name: str, - body: Union[_models.VolumeQuotaRule, IO], + body: Union[_models.VolumeQuotaRule, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VolumeQuotaRule]: """Create a quota rule. @@ -678,19 +650,8 @@ def begin_create( :param volume_quota_rule_name: The name of volume quota rule. Required. :type volume_quota_rule_name: str :param body: Quota rule object supplied in the body of the operation. Is either a - VolumeQuotaRule type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.VolumeQuotaRule 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. + VolumeQuotaRule type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.VolumeQuotaRule or IO[bytes] :return: An instance of LROPoller that returns either VolumeQuotaRule or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.VolumeQuotaRule] @@ -725,7 +686,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("VolumeQuotaRule", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -737,17 +698,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VolumeQuotaRule].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/volumeQuotaRules/{volumeQuotaRuleName}" - } + return LROPoller[_models.VolumeQuotaRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, @@ -756,10 +715,10 @@ def _update_initial( pool_name: str, volume_name: str, volume_quota_rule_name: str, - body: Union[_models.VolumeQuotaRulePatch, IO], + body: Union[_models.VolumeQuotaRulePatch, IO[bytes]], **kwargs: Any ) -> Optional[_models.VolumeQuotaRule]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -782,7 +741,7 @@ def _update_initial( else: _json = self._serialize.body(body, "VolumeQuotaRulePatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -793,16 +752,15 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -817,13 +775,9 @@ def _update_initial( deserialized = self._deserialize("VolumeQuotaRule", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/volumeQuotaRules/{volumeQuotaRuleName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -858,14 +812,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either VolumeQuotaRule or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.VolumeQuotaRule] @@ -880,7 +826,7 @@ def begin_update( pool_name: str, volume_name: str, volume_quota_rule_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -901,18 +847,10 @@ def begin_update( :param volume_quota_rule_name: The name of volume quota rule. Required. :type volume_quota_rule_name: str :param body: Quota rule object supplied in the body of the operation. Required. - :type body: IO + :type body: 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 VolumeQuotaRule or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.VolumeQuotaRule] @@ -927,7 +865,7 @@ def begin_update( pool_name: str, volume_name: str, volume_quota_rule_name: str, - body: Union[_models.VolumeQuotaRulePatch, IO], + body: Union[_models.VolumeQuotaRulePatch, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VolumeQuotaRule]: """Update a quota rule. @@ -946,19 +884,8 @@ def begin_update( :param volume_quota_rule_name: The name of volume quota rule. Required. :type volume_quota_rule_name: str :param body: Quota rule object supplied in the body of the operation. Is either a - VolumeQuotaRulePatch type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.VolumeQuotaRulePatch 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. + VolumeQuotaRulePatch type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.VolumeQuotaRulePatch or IO[bytes] :return: An instance of LROPoller that returns either VolumeQuotaRule or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.VolumeQuotaRule] @@ -993,7 +920,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("VolumeQuotaRule", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1005,17 +932,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VolumeQuotaRule].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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/volumeQuotaRules/{volumeQuotaRuleName}" - } + return LROPoller[_models.VolumeQuotaRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -1026,7 +951,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements volume_quota_rule_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1040,7 +965,7 @@ def _delete_initial( # 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, account_name=account_name, pool_name=pool_name, @@ -1048,16 +973,15 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements volume_quota_rule_name=volume_quota_rule_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 = _convert_request(_request) + _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 @@ -1068,11 +992,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/volumeQuotaRules/{volumeQuotaRuleName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_delete( @@ -1099,14 +1019,6 @@ def begin_delete( :type volume_name: str :param volume_quota_rule_name: The name of volume quota rule. Required. :type volume_quota_rule_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: @@ -1136,7 +1048,7 @@ def begin_delete( 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( @@ -1147,14 +1059,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/volumeQuotaRules/{volumeQuotaRuleName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_volumes_operations.py b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_volumes_operations.py index 9b6075a6a413..235e17c05932 100644 --- a/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_volumes_operations.py +++ b/sdk/netapp/azure-mgmt-netapp/azure/mgmt/netapp/operations/_volumes_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -32,6 +33,10 @@ from .._serialization import Serializer from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -83,7 +88,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +129,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -168,7 +173,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -219,7 +224,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -262,7 +267,7 @@ def build_populate_availability_zone_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -303,7 +308,7 @@ def build_revert_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -347,7 +352,7 @@ def build_reset_cifs_password_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -382,13 +387,54 @@ def build_reset_cifs_password_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) +def build_split_clone_from_parent_request( + resource_group_name: str, account_name: str, pool_name: str, volume_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-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/splitCloneFromParent", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + "poolName": _SERIALIZER.url( + "pool_name", pool_name, "str", max_length=64, min_length=1, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$" + ), + "volumeName": _SERIALIZER.url( + "volume_name", volume_name, "str", max_length=64, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$" + ), + } + + _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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + def build_break_file_locks_request( resource_group_name: str, account_name: str, pool_name: str, volume_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -426,13 +472,13 @@ def build_break_file_locks_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_get_group_id_list_for_ldap_user_request( +def build_list_get_group_id_list_for_ldap_user_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, pool_name: str, volume_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -476,7 +522,7 @@ def build_break_replication_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -520,7 +566,7 @@ def build_reestablish_replication_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -564,7 +610,7 @@ def build_replication_status_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -605,7 +651,7 @@ def build_list_replications_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -646,7 +692,7 @@ def build_resync_replication_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -687,7 +733,7 @@ def build_delete_replication_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -728,7 +774,7 @@ def build_authorize_replication_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -772,7 +818,7 @@ def build_re_initialize_replication_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -807,13 +853,180 @@ def build_re_initialize_replication_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) +def build_peer_cluster_for_on_prem_migration_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, pool_name: str, volume_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-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/peerClusterForOnPremMigration", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + "poolName": _SERIALIZER.url( + "pool_name", pool_name, "str", max_length=64, min_length=1, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$" + ), + "volumeName": _SERIALIZER.url( + "volume_name", volume_name, "str", max_length=64, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_on_prem_migration_replication_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, pool_name: str, volume_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-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/createOnPremMigrationReplication", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + "poolName": _SERIALIZER.url( + "pool_name", pool_name, "str", max_length=64, min_length=1, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$" + ), + "volumeName": _SERIALIZER.url( + "volume_name", volume_name, "str", max_length=64, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$" + ), + } + + _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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_finalize_on_prem_migration_request( + resource_group_name: str, account_name: str, pool_name: str, volume_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-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/finalizeOnPremMigration", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + "poolName": _SERIALIZER.url( + "pool_name", pool_name, "str", max_length=64, min_length=1, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$" + ), + "volumeName": _SERIALIZER.url( + "volume_name", volume_name, "str", max_length=64, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$" + ), + } + + _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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_perform_replication_transfer_request( # pylint: disable=name-too-long + resource_group_name: str, account_name: str, pool_name: str, volume_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-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/performReplicationTransfer", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,127}$" + ), + "poolName": _SERIALIZER.url( + "pool_name", pool_name, "str", max_length=64, min_length=1, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9\-_]{0,63}$" + ), + "volumeName": _SERIALIZER.url( + "volume_name", volume_name, "str", max_length=64, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9\-_]{0,63}$" + ), + } + + _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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + def build_pool_change_request( resource_group_name: str, account_name: str, pool_name: str, volume_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -857,7 +1070,7 @@ def build_relocate_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -901,7 +1114,7 @@ def build_finalize_relocation_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -942,7 +1155,7 @@ def build_revert_relocation_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1011,7 +1224,6 @@ def list( :type account_name: str :param pool_name: The name of the capacity pool. Required. :type pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Volume or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.netapp.models.Volume] :raises ~azure.core.exceptions.HttpResponseError: @@ -1022,7 +1234,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VolumeList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1033,18 +1245,17 @@ 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, account_name=account_name, pool_name=pool_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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1056,13 +1267,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("VolumeList", pipeline_response) @@ -1072,11 +1283,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 @@ -1089,10 +1300,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any @@ -1110,12 +1317,11 @@ def get( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Volume or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.Volume :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1129,23 +1335,22 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Volume] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -1158,13 +1363,9 @@ def get( deserialized = self._deserialize("Volume", pipeline_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.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, @@ -1172,10 +1373,10 @@ def _create_or_update_initial( account_name: str, pool_name: str, volume_name: str, - body: Union[_models.Volume, IO], + body: Union[_models.Volume, IO[bytes]], **kwargs: Any ) -> Optional[_models.Volume]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1198,7 +1399,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(body, "Volume") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -1208,16 +1409,15 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -1235,13 +1435,9 @@ def _create_or_update_initial( deserialized = self._deserialize("Volume", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -1273,14 +1469,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.Volume] :raises ~azure.core.exceptions.HttpResponseError: @@ -1293,7 +1481,7 @@ def begin_create_or_update( account_name: str, pool_name: str, volume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1312,18 +1500,10 @@ def begin_create_or_update( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Volume object supplied in the body of the operation. Required. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.Volume] :raises ~azure.core.exceptions.HttpResponseError: @@ -1336,7 +1516,7 @@ def begin_create_or_update( account_name: str, pool_name: str, volume_name: str, - body: Union[_models.Volume, IO], + body: Union[_models.Volume, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Volume]: """Create or Update a volume. @@ -1353,19 +1533,8 @@ def begin_create_or_update( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Volume object supplied in the body of the operation. Is either a Volume type or a - IO type. Required. - :type body: ~azure.mgmt.netapp.models.Volume or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.Volume or IO[bytes] :return: An instance of LROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.Volume] :raises ~azure.core.exceptions.HttpResponseError: @@ -1398,7 +1567,7 @@ def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Volume", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1410,17 +1579,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Volume].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}" - } + return LROPoller[_models.Volume]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, @@ -1428,10 +1595,10 @@ def _update_initial( account_name: str, pool_name: str, volume_name: str, - body: Union[_models.VolumePatch, IO], + body: Union[_models.VolumePatch, IO[bytes]], **kwargs: Any ) -> Optional[_models.Volume]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1454,7 +1621,7 @@ def _update_initial( else: _json = self._serialize.body(body, "VolumePatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -1464,16 +1631,15 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -1488,13 +1654,9 @@ def _update_initial( deserialized = self._deserialize("Volume", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -1526,14 +1688,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.Volume] :raises ~azure.core.exceptions.HttpResponseError: @@ -1546,7 +1700,7 @@ def begin_update( account_name: str, pool_name: str, volume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1565,18 +1719,10 @@ def begin_update( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Volume object supplied in the body of the operation. Required. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.Volume] :raises ~azure.core.exceptions.HttpResponseError: @@ -1589,7 +1735,7 @@ def begin_update( account_name: str, pool_name: str, volume_name: str, - body: Union[_models.VolumePatch, IO], + body: Union[_models.VolumePatch, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Volume]: """Update a volume. @@ -1606,19 +1752,8 @@ def begin_update( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Volume object supplied in the body of the operation. Is either a VolumePatch type - or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.VolumePatch 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 body: ~azure.mgmt.netapp.models.VolumePatch or IO[bytes] :return: An instance of LROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.Volume] :raises ~azure.core.exceptions.HttpResponseError: @@ -1651,7 +1786,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Volume", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1663,17 +1798,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Volume].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}" - } + return LROPoller[_models.Volume]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -1684,7 +1817,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_delete: Optional[bool] = None, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1698,7 +1831,7 @@ def _delete_initial( # 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, account_name=account_name, pool_name=pool_name, @@ -1706,16 +1839,15 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, force_delete=force_delete, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -1726,11 +1858,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_delete( @@ -1758,14 +1886,6 @@ def begin_delete( :param force_delete: An option to force delete the volume. Will cleanup resources connected to the particular volume. Default value is None. :type force_delete: bool - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -1795,7 +1915,7 @@ def begin_delete( 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( @@ -1806,22 +1926,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _populate_availability_zone_initial( self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any ) -> Optional[_models.Volume]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1835,23 +1951,22 @@ def _populate_availability_zone_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.Volume]] = kwargs.pop("cls", None) - request = build_populate_availability_zone_request( + _request = build_populate_availability_zone_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._populate_availability_zone_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -1870,13 +1985,9 @@ def _populate_availability_zone_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _populate_availability_zone_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/populateAvailabilityZone" - } + return deserialized # type: ignore @distributed_trace def begin_populate_availability_zone( @@ -1895,14 +2006,6 @@ def begin_populate_availability_zone( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either Volume or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.Volume] :raises ~azure.core.exceptions.HttpResponseError: @@ -1932,7 +2035,7 @@ def begin_populate_availability_zone( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Volume", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1944,17 +2047,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Volume].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_populate_availability_zone.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/populateAvailabilityZone" - } + return LROPoller[_models.Volume]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _revert_initial( # pylint: disable=inconsistent-return-statements self, @@ -1962,10 +2063,10 @@ def _revert_initial( # pylint: disable=inconsistent-return-statements account_name: str, pool_name: str, volume_name: str, - body: Union[_models.VolumeRevert, IO], + body: Union[_models.VolumeRevert, IO[bytes]], **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1988,7 +2089,7 @@ def _revert_initial( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(body, "VolumeRevert") - request = build_revert_request( + _request = build_revert_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -1998,16 +2099,15 @@ def _revert_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self._revert_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -2018,11 +2118,7 @@ def _revert_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _revert_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/revert" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def begin_revert( @@ -2054,14 +2150,6 @@ def begin_revert( :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: @@ -2074,7 +2162,7 @@ def begin_revert( account_name: str, pool_name: str, volume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2093,18 +2181,10 @@ def begin_revert( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Object for snapshot to revert supplied in the body of the operation. Required. - :type body: IO + :type body: 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: @@ -2117,7 +2197,7 @@ def begin_revert( account_name: str, pool_name: str, volume_name: str, - body: Union[_models.VolumeRevert, IO], + body: Union[_models.VolumeRevert, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Revert a volume to one of its snapshots. @@ -2134,19 +2214,8 @@ def begin_revert( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Object for snapshot to revert supplied in the body of the operation. Is either a - VolumeRevert type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.VolumeRevert 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. + VolumeRevert type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.VolumeRevert 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: @@ -2178,7 +2247,7 @@ def begin_revert( 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( @@ -2189,22 +2258,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_revert.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/revert" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _reset_cifs_password_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2218,23 +2283,22 @@ def _reset_cifs_password_initial( # pylint: disable=inconsistent-return-stateme api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_reset_cifs_password_request( + _request = build_reset_cifs_password_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._reset_cifs_password_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -2248,11 +2312,7 @@ def _reset_cifs_password_initial( # pylint: disable=inconsistent-return-stateme response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, None, response_headers) - - _reset_cifs_password_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/resetCifsPassword" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_reset_cifs_password( @@ -2271,14 +2331,6 @@ def begin_reset_cifs_password( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -2307,7 +2359,7 @@ def begin_reset_cifs_password( 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)) @@ -2316,28 +2368,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_reset_cifs_password.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/resetCifsPassword" - } - - def _break_file_locks_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - pool_name: str, - volume_name: str, - body: Optional[Union[_models.BreakFileLocksRequest, IO]] = None, - **kwargs: Any + def _split_clone_from_parent_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2345,49 +2387,166 @@ def _break_file_locks_initial( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "BreakFileLocksRequest") - else: - _json = None - - request = build_break_file_locks_request( + _request = build_split_clone_from_parent_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._break_file_locks_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 - if response.status_code not in [200, 202]: + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def begin_split_clone_from_parent( + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Split clone from parent volume. + + Split operation to convert clone volume to an independent volume. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: 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: + """ + _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[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._split_clone_from_parent_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _break_file_locks_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: Optional[Union[_models.BreakFileLocksRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "BreakFileLocksRequest") + else: + _json = None + + _request = build_break_file_locks_request( + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: 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) @@ -2397,11 +2556,7 @@ def _break_file_locks_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, None, response_headers) - - _break_file_locks_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/breakFileLocks" - } + return cls(pipeline_response, None, response_headers) # type: ignore @overload def begin_break_file_locks( @@ -2434,14 +2589,6 @@ def begin_break_file_locks( :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: @@ -2454,7 +2601,7 @@ def begin_break_file_locks( account_name: str, pool_name: str, volume_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2474,18 +2621,10 @@ def begin_break_file_locks( :type volume_name: str :param body: Optional body to provide the ability to clear file locks with selected options. Default value is None. - :type body: IO + :type body: 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: @@ -2498,7 +2637,7 @@ def begin_break_file_locks( account_name: str, pool_name: str, volume_name: str, - body: Optional[Union[_models.BreakFileLocksRequest, IO]] = None, + body: Optional[Union[_models.BreakFileLocksRequest, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[None]: """Break file locks. @@ -2515,19 +2654,8 @@ def begin_break_file_locks( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Optional body to provide the ability to clear file locks with selected options. Is - either a BreakFileLocksRequest type or a IO type. Default value is None. - :type body: ~azure.mgmt.netapp.models.BreakFileLocksRequest 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. + either a BreakFileLocksRequest type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.netapp.models.BreakFileLocksRequest 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: @@ -2559,7 +2687,7 @@ def begin_break_file_locks( 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( @@ -2570,28 +2698,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_break_file_locks.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/breakFileLocks" - } - - def _list_get_group_id_list_for_ldap_user_initial( + def _list_get_group_id_list_for_ldap_user_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, - body: Union[_models.GetGroupIdListForLDAPUserRequest, IO], + body: Union[_models.GetGroupIdListForLDAPUserRequest, IO[bytes]], **kwargs: Any ) -> Optional[_models.GetGroupIdListForLDAPUserResponse]: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2614,7 +2738,7 @@ def _list_get_group_id_list_for_ldap_user_initial( else: _json = self._serialize.body(body, "GetGroupIdListForLDAPUserRequest") - request = build_list_get_group_id_list_for_ldap_user_request( + _request = build_list_get_group_id_list_for_ldap_user_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -2624,16 +2748,15 @@ def _list_get_group_id_list_for_ldap_user_initial( content_type=content_type, json=_json, content=_content, - template_url=self._list_get_group_id_list_for_ldap_user_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -2652,16 +2775,12 @@ def _list_get_group_id_list_for_ldap_user_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _list_get_group_id_list_for_ldap_user_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/getGroupIdListForLdapUser" - } + return deserialized # type: ignore @overload - def begin_list_get_group_id_list_for_ldap_user( + def begin_list_get_group_id_list_for_ldap_user( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, @@ -2690,14 +2809,6 @@ def begin_list_get_group_id_list_for_ldap_user( :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 GetGroupIdListForLDAPUserResponse or the result of cls(response) :rtype: @@ -2706,13 +2817,13 @@ def begin_list_get_group_id_list_for_ldap_user( """ @overload - def begin_list_get_group_id_list_for_ldap_user( + def begin_list_get_group_id_list_for_ldap_user( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2731,18 +2842,10 @@ def begin_list_get_group_id_list_for_ldap_user( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Returns group Id list for a specific LDAP user. Required. - :type body: IO + :type body: 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 GetGroupIdListForLDAPUserResponse or the result of cls(response) :rtype: @@ -2751,13 +2854,13 @@ def begin_list_get_group_id_list_for_ldap_user( """ @distributed_trace - def begin_list_get_group_id_list_for_ldap_user( + def begin_list_get_group_id_list_for_ldap_user( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, - body: Union[_models.GetGroupIdListForLDAPUserRequest, IO], + body: Union[_models.GetGroupIdListForLDAPUserRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.GetGroupIdListForLDAPUserResponse]: """Get Group Id List for LDAP User. @@ -2774,19 +2877,8 @@ def begin_list_get_group_id_list_for_ldap_user( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Returns group Id list for a specific LDAP user. Is either a - GetGroupIdListForLDAPUserRequest type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.GetGroupIdListForLDAPUserRequest 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. + GetGroupIdListForLDAPUserRequest type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.GetGroupIdListForLDAPUserRequest or IO[bytes] :return: An instance of LROPoller that returns either GetGroupIdListForLDAPUserResponse or the result of cls(response) :rtype: @@ -2821,7 +2913,7 @@ def begin_list_get_group_id_list_for_ldap_user( def get_long_running_output(pipeline_response): deserialized = self._deserialize("GetGroupIdListForLDAPUserResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2833,17 +2925,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.GetGroupIdListForLDAPUserResponse].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_list_get_group_id_list_for_ldap_user.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/getGroupIdListForLdapUser" - } + return LROPoller[_models.GetGroupIdListForLDAPUserResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _break_replication_initial( # pylint: disable=inconsistent-return-statements self, @@ -2851,10 +2941,10 @@ def _break_replication_initial( # pylint: disable=inconsistent-return-statement account_name: str, pool_name: str, volume_name: str, - body: Optional[Union[_models.BreakReplicationRequest, IO]] = None, + body: Optional[Union[_models.BreakReplicationRequest, IO[bytes]]] = None, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2880,7 +2970,7 @@ def _break_replication_initial( # pylint: disable=inconsistent-return-statement else: _json = None - request = build_break_replication_request( + _request = build_break_replication_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -2890,16 +2980,15 @@ def _break_replication_initial( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, content=_content, - template_url=self._break_replication_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -2910,11 +2999,7 @@ def _break_replication_initial( # pylint: disable=inconsistent-return-statement raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _break_replication_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/breakReplication" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def begin_break_replication( @@ -2946,14 +3031,6 @@ def begin_break_replication( :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: @@ -2966,7 +3043,7 @@ def begin_break_replication( account_name: str, pool_name: str, volume_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -2985,18 +3062,10 @@ def begin_break_replication( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Optional body to force break the replication. Default value is None. - :type body: IO + :type body: 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: @@ -3009,7 +3078,7 @@ def begin_break_replication( account_name: str, pool_name: str, volume_name: str, - body: Optional[Union[_models.BreakReplicationRequest, IO]] = None, + body: Optional[Union[_models.BreakReplicationRequest, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[None]: """Break volume replication. @@ -3026,19 +3095,8 @@ def begin_break_replication( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Optional body to force break the replication. Is either a BreakReplicationRequest - type or a IO type. Default value is None. - :type body: ~azure.mgmt.netapp.models.BreakReplicationRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + type or a IO[bytes] type. Default value is None. + :type body: ~azure.mgmt.netapp.models.BreakReplicationRequest 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: @@ -3070,7 +3128,7 @@ def begin_break_replication( 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( @@ -3081,17 +3139,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_break_replication.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/breakReplication" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _reestablish_replication_initial( # pylint: disable=inconsistent-return-statements self, @@ -3099,10 +3153,10 @@ def _reestablish_replication_initial( # pylint: disable=inconsistent-return-sta account_name: str, pool_name: str, volume_name: str, - body: Union[_models.ReestablishReplicationRequest, IO], + body: Union[_models.ReestablishReplicationRequest, IO[bytes]], **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3125,7 +3179,7 @@ def _reestablish_replication_initial( # pylint: disable=inconsistent-return-sta else: _json = self._serialize.body(body, "ReestablishReplicationRequest") - request = build_reestablish_replication_request( + _request = build_reestablish_replication_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -3135,16 +3189,15 @@ def _reestablish_replication_initial( # pylint: disable=inconsistent-return-sta content_type=content_type, json=_json, content=_content, - template_url=self._reestablish_replication_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -3155,11 +3208,7 @@ def _reestablish_replication_initial( # pylint: disable=inconsistent-return-sta raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _reestablish_replication_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/reestablishReplication" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def begin_reestablish_replication( @@ -3192,14 +3241,6 @@ def begin_reestablish_replication( :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: @@ -3212,7 +3253,7 @@ def begin_reestablish_replication( account_name: str, pool_name: str, volume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -3232,18 +3273,10 @@ def begin_reestablish_replication( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: body for the id of the source volume. Required. - :type body: IO + :type body: 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: @@ -3256,7 +3289,7 @@ def begin_reestablish_replication( account_name: str, pool_name: str, volume_name: str, - body: Union[_models.ReestablishReplicationRequest, IO], + body: Union[_models.ReestablishReplicationRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Re-establish volume replication. @@ -3274,19 +3307,8 @@ def begin_reestablish_replication( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: body for the id of the source volume. Is either a ReestablishReplicationRequest - type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.ReestablishReplicationRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.ReestablishReplicationRequest 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: @@ -3318,7 +3340,7 @@ def begin_reestablish_replication( 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( @@ -3329,17 +3351,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_reestablish_replication.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/reestablishReplication" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def replication_status( @@ -3358,12 +3376,11 @@ def replication_status( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ReplicationStatus or the result of cls(response) :rtype: ~azure.mgmt.netapp.models.ReplicationStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3377,23 +3394,22 @@ def replication_status( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ReplicationStatus] = kwargs.pop("cls", None) - request = build_replication_status_request( + _request = build_replication_status_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.replication_status.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -3406,13 +3422,9 @@ def replication_status( deserialized = self._deserialize("ReplicationStatus", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - replication_status.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/replicationStatus" - } + return deserialized # type: ignore @distributed_trace def list_replications( @@ -3431,7 +3443,6 @@ def list_replications( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Replication or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.netapp.models.Replication] :raises ~azure.core.exceptions.HttpResponseError: @@ -3442,7 +3453,7 @@ def list_replications( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListReplications] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3453,19 +3464,18 @@ def list_replications( def prepare_request(next_link=None): if not next_link: - request = build_list_replications_request( + _request = build_list_replications_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_replications.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -3477,13 +3487,13 @@ 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListReplications", pipeline_response) @@ -3493,11 +3503,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3510,14 +3520,10 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_replications.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/listReplications" - } - def _resync_replication_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3531,23 +3537,22 @@ def _resync_replication_initial( # pylint: disable=inconsistent-return-statemen api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_resync_replication_request( + _request = build_resync_replication_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._resync_replication_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -3558,11 +3563,7 @@ def _resync_replication_initial( # pylint: disable=inconsistent-return-statemen raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _resync_replication_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/resyncReplication" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_resync_replication( @@ -3582,14 +3583,6 @@ def begin_resync_replication( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -3618,7 +3611,7 @@ def begin_resync_replication( 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( @@ -3629,22 +3622,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_resync_replication.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/resyncReplication" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _delete_replication_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3658,23 +3647,22 @@ def _delete_replication_initial( # pylint: disable=inconsistent-return-statemen 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_replication_request( + _request = build_delete_replication_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_replication_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -3685,11 +3673,7 @@ def _delete_replication_initial( # pylint: disable=inconsistent-return-statemen raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_replication_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/deleteReplication" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_delete_replication( @@ -3709,14 +3693,6 @@ def begin_delete_replication( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -3745,7 +3721,7 @@ def begin_delete_replication( 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( @@ -3756,17 +3732,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete_replication.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/deleteReplication" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _authorize_replication_initial( # pylint: disable=inconsistent-return-statements self, @@ -3774,10 +3746,10 @@ def _authorize_replication_initial( # pylint: disable=inconsistent-return-state account_name: str, pool_name: str, volume_name: str, - body: Union[_models.AuthorizeRequest, IO], + body: Union[_models.AuthorizeRequest, IO[bytes]], **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3800,7 +3772,7 @@ def _authorize_replication_initial( # pylint: disable=inconsistent-return-state else: _json = self._serialize.body(body, "AuthorizeRequest") - request = build_authorize_replication_request( + _request = build_authorize_replication_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -3810,16 +3782,15 @@ def _authorize_replication_initial( # pylint: disable=inconsistent-return-state content_type=content_type, json=_json, content=_content, - template_url=self._authorize_replication_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -3830,11 +3801,7 @@ def _authorize_replication_initial( # pylint: disable=inconsistent-return-state raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _authorize_replication_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/authorizeReplication" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def begin_authorize_replication( @@ -3866,14 +3833,6 @@ def begin_authorize_replication( :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: @@ -3886,7 +3845,7 @@ def begin_authorize_replication( account_name: str, pool_name: str, volume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -3905,18 +3864,10 @@ def begin_authorize_replication( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Authorize request object supplied in the body of the operation. Required. - :type body: IO + :type body: 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: @@ -3929,7 +3880,7 @@ def begin_authorize_replication( account_name: str, pool_name: str, volume_name: str, - body: Union[_models.AuthorizeRequest, IO], + body: Union[_models.AuthorizeRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Authorize source volume replication. @@ -3946,19 +3897,8 @@ def begin_authorize_replication( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Authorize request object supplied in the body of the operation. Is either a - AuthorizeRequest type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.AuthorizeRequest 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. + AuthorizeRequest type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.AuthorizeRequest 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: @@ -3990,7 +3930,7 @@ def begin_authorize_replication( 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( @@ -4001,22 +3941,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_authorize_replication.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/authorizeReplication" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _re_initialize_replication_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -4030,23 +3966,22 @@ def _re_initialize_replication_initial( # pylint: disable=inconsistent-return-s api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_re_initialize_replication_request( + _request = build_re_initialize_replication_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._re_initialize_replication_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -4057,11 +3992,7 @@ def _re_initialize_replication_initial( # pylint: disable=inconsistent-return-s raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _re_initialize_replication_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/reinitializeReplication" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_re_initialize_replication( @@ -4080,14 +4011,6 @@ def begin_re_initialize_replication( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -4116,7 +4039,7 @@ def begin_re_initialize_replication( 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( @@ -4127,28 +4050,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_re_initialize_replication.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/reinitializeReplication" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _pool_change_initial( # pylint: disable=inconsistent-return-statements + def _peer_cluster_for_on_prem_migration_initial( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, - body: Union[_models.PoolChangeRequest, IO], + body: Union[_models.PeerClusterForVolumeMigrationRequest, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> Optional[_models.ClusterPeerCommandResponse]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -4161,7 +4080,7 @@ def _pool_change_initial( # pylint: disable=inconsistent-return-statements 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[Optional[_models.ClusterPeerCommandResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -4169,9 +4088,9 @@ def _pool_change_initial( # pylint: disable=inconsistent-return-statements if isinstance(body, (IOBase, bytes)): _content = body else: - _json = self._serialize.body(body, "PoolChangeRequest") + _json = self._serialize.body(body, "PeerClusterForVolumeMigrationRequest") - request = build_pool_change_request( + _request = build_peer_cluster_for_on_prem_migration_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -4181,16 +4100,15 @@ def _pool_change_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self._pool_change_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -4200,28 +4118,34 @@ def _pool_change_initial( # pylint: disable=inconsistent-return-statements 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("ClusterPeerCommandResponse", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _pool_change_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/poolChange" - } + return deserialized # type: ignore @overload - def begin_pool_change( + def begin_peer_cluster_for_on_prem_migration( self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, - body: _models.PoolChangeRequest, + body: _models.PeerClusterForVolumeMigrationRequest, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Change pool for volume. + ) -> LROPoller[_models.ClusterPeerCommandResponse]: + """Start Cluster peering. - Moves volume to another pool. + Starts peering the cluster for this migration volume. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4232,39 +4156,32 @@ def begin_pool_change( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :param body: Move volume to the pool supplied in the body of the operation. Required. - :type body: ~azure.mgmt.netapp.models.PoolChangeRequest + :param body: Cluster peer request object supplied in the body of the operation. Required. + :type body: ~azure.mgmt.netapp.models.PeerClusterForVolumeMigrationRequest :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] + :return: An instance of LROPoller that returns either ClusterPeerCommandResponse or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.ClusterPeerCommandResponse] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def begin_pool_change( + def begin_peer_cluster_for_on_prem_migration( self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, - body: IO, + body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[None]: - """Change pool for volume. + ) -> LROPoller[_models.ClusterPeerCommandResponse]: + """Start Cluster peering. - Moves volume to another pool. + Starts peering the cluster for this migration volume. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4275,37 +4192,30 @@ def begin_pool_change( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :param body: Move volume to the pool supplied in the body of the operation. Required. - :type body: IO + :param body: Cluster peer request object supplied in the body of the operation. Required. + :type body: 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] + :return: An instance of LROPoller that returns either ClusterPeerCommandResponse or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.ClusterPeerCommandResponse] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def begin_pool_change( + def begin_peer_cluster_for_on_prem_migration( self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, - body: Union[_models.PoolChangeRequest, IO], + body: Union[_models.PeerClusterForVolumeMigrationRequest, IO[bytes]], **kwargs: Any - ) -> LROPoller[None]: - """Change pool for volume. + ) -> LROPoller[_models.ClusterPeerCommandResponse]: + """Start Cluster peering. - Moves volume to another pool. + Starts peering the cluster for this migration volume. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. @@ -4316,22 +4226,12 @@ def begin_pool_change( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :param body: Move volume to the pool supplied in the body of the operation. Is either a - PoolChangeRequest type or a IO type. Required. - :type body: ~azure.mgmt.netapp.models.PoolChangeRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :param body: Cluster peer request object supplied in the body of the operation. Is either a + PeerClusterForVolumeMigrationRequest type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.PeerClusterForVolumeMigrationRequest or IO[bytes] + :return: An instance of LROPoller that returns either ClusterPeerCommandResponse or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.ClusterPeerCommandResponse] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -4339,12 +4239,12 @@ def begin_pool_change( 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[_models.ClusterPeerCommandResponse] = 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._pool_change_initial( # type: ignore + raw_result = self._peer_cluster_for_on_prem_migration_initial( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -4359,9 +4259,11 @@ def begin_pool_change( ) kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ClusterPeerCommandResponse", pipeline_response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized if polling is True: polling_method: PollingMethod = cast( @@ -4372,28 +4274,20 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ClusterPeerCommandResponse].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_pool_change.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/poolChange" - } + return LROPoller[_models.ClusterPeerCommandResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _relocate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - pool_name: str, - volume_name: str, - body: Optional[Union[_models.RelocateVolumeRequest, IO]] = None, - **kwargs: Any - ) -> None: - error_map = { + def _create_on_prem_migration_replication_initial( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any + ) -> Optional[_models.SvmPeerCommandResponse]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -4401,44 +4295,28 @@ def _relocate_initial( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - if body is not None: - _json = self._serialize.body(body, "RelocateVolumeRequest") - else: - _json = None + cls: ClsType[Optional[_models.SvmPeerCommandResponse]] = kwargs.pop("cls", None) - request = build_relocate_request( + _request = build_create_on_prem_migration_replication_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self._relocate_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -4448,22 +4326,598 @@ def _relocate_initial( # pylint: disable=inconsistent-return-statements 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("SvmPeerCommandResponse", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _relocate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/relocate" - } + return deserialized # type: ignore - @overload - def begin_relocate( - self, - resource_group_name: str, - account_name: str, - pool_name: str, - volume_name: str, - body: Optional[_models.RelocateVolumeRequest] = None, - *, + @distributed_trace + def begin_create_on_prem_migration_replication( # pylint: disable=name-too-long + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any + ) -> LROPoller[_models.SvmPeerCommandResponse]: + """Start migration process. + + Starts SVM peering and returns a command to be run on the external ONTAP to accept it. Once + the SVMs have been peered a SnapMirror will be created. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: str + :return: An instance of LROPoller that returns either SvmPeerCommandResponse or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.netapp.models.SvmPeerCommandResponse] + :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.SvmPeerCommandResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_on_prem_migration_replication_initial( + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SvmPeerCommandResponse", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SvmPeerCommandResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SvmPeerCommandResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _finalize_on_prem_migration_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_finalize_on_prem_migration_request( + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def begin_finalize_on_prem_migration( + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Finalize migration process. + + Finalizes the migration of a volume by performing a final sync on the replication, breaking and + releasing the replication, and breaking the cluster peering if no other migration is active. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: 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: + """ + _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[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._finalize_on_prem_migration_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _perform_replication_transfer_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_perform_replication_transfer_request( + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def begin_perform_replication_transfer( + self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Perform a replication transfer. + + Performs an adhoc replication transfer on a volume with volumeType Migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: 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: + """ + _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[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._perform_replication_transfer_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _pool_change_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: Union[_models.PoolChangeRequest, IO[bytes]], + **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = self._serialize.body(body, "PoolChangeRequest") + + _request = build_pool_change_request( + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def begin_pool_change( + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: _models.PoolChangeRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Change pool for volume. + + Moves volume to another pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: str + :param body: Move volume to the pool supplied in the body of the operation. Required. + :type body: ~azure.mgmt.netapp.models.PoolChangeRequest + :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_pool_change( + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Change pool for volume. + + Moves volume to another pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: str + :param body: Move volume to the pool supplied in the body of the operation. Required. + :type body: 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_pool_change( + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: Union[_models.PoolChangeRequest, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Change pool for volume. + + Moves volume to another pool. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: The name of the NetApp account. Required. + :type account_name: str + :param pool_name: The name of the capacity pool. Required. + :type pool_name: str + :param volume_name: The name of the volume. Required. + :type volume_name: str + :param body: Move volume to the pool supplied in the body of the operation. Is either a + PoolChangeRequest type or a IO[bytes] type. Required. + :type body: ~azure.mgmt.netapp.models.PoolChangeRequest 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 = 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._pool_change_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_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[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _relocate_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: Optional[Union[_models.RelocateVolumeRequest, IO[bytes]]] = None, + **kwargs: Any + ) -> None: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "RelocateVolumeRequest") + else: + _json = None + + _request = build_relocate_request( + resource_group_name=resource_group_name, + account_name=account_name, + pool_name=pool_name, + volume_name=volume_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def begin_relocate( + self, + resource_group_name: str, + account_name: str, + pool_name: str, + volume_name: str, + body: Optional[_models.RelocateVolumeRequest] = None, + *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: @@ -4485,14 +4939,6 @@ def begin_relocate( :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: @@ -4505,7 +4951,7 @@ def begin_relocate( account_name: str, pool_name: str, volume_name: str, - body: Optional[IO] = None, + body: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -4524,18 +4970,10 @@ def begin_relocate( :param volume_name: The name of the volume. Required. :type volume_name: str :param body: Relocate volume request. Default value is None. - :type body: IO + :type body: 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: @@ -4548,7 +4986,7 @@ def begin_relocate( account_name: str, pool_name: str, volume_name: str, - body: Optional[Union[_models.RelocateVolumeRequest, IO]] = None, + body: Optional[Union[_models.RelocateVolumeRequest, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[None]: """Relocate volume. @@ -4564,20 +5002,9 @@ def begin_relocate( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :param body: Relocate volume request. Is either a RelocateVolumeRequest type or a IO type. - Default value is None. - :type body: ~azure.mgmt.netapp.models.RelocateVolumeRequest 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 body: Relocate volume request. Is either a RelocateVolumeRequest type or a IO[bytes] + type. Default value is None. + :type body: ~azure.mgmt.netapp.models.RelocateVolumeRequest 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: @@ -4609,7 +5036,7 @@ def begin_relocate( 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)) @@ -4618,22 +5045,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_relocate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/relocate" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _finalize_relocation_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -4647,23 +5070,22 @@ def _finalize_relocation_initial( # pylint: disable=inconsistent-return-stateme api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_finalize_relocation_request( + _request = build_finalize_relocation_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._finalize_relocation_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -4674,11 +5096,7 @@ def _finalize_relocation_initial( # pylint: disable=inconsistent-return-stateme raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _finalize_relocation_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/finalizeRelocation" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_finalize_relocation( @@ -4697,14 +5115,6 @@ def begin_finalize_relocation( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -4733,7 +5143,7 @@ def begin_finalize_relocation( 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)) @@ -4742,22 +5152,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_finalize_relocation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/finalizeRelocation" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _revert_relocation_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, pool_name: str, volume_name: str, **kwargs: Any ) -> None: - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -4771,23 +5177,22 @@ def _revert_relocation_initial( # pylint: disable=inconsistent-return-statement api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_revert_relocation_request( + _request = build_revert_relocation_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, volume_name=volume_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._revert_relocation_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _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 @@ -4798,11 +5203,7 @@ def _revert_relocation_initial( # pylint: disable=inconsistent-return-statement raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _revert_relocation_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/revertRelocation" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_revert_relocation( @@ -4822,14 +5223,6 @@ def begin_revert_relocation( :type pool_name: str :param volume_name: The name of the volume. Required. :type volume_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -4858,7 +5251,7 @@ def begin_revert_relocation( 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)) @@ -4867,14 +5260,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_revert_relocation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetApp/netAppAccounts/{accountName}/capacityPools/{poolName}/volumes/{volumeName}/revertRelocation" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_change_key_vault.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_change_key_vault.py new file mode 100644 index 000000000000..2b4e50f9d3dd --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_change_key_vault.py @@ -0,0 +1,41 @@ +# 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.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python accounts_change_key_vault.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 = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + client.accounts.begin_change_key_vault( + resource_group_name="myRG", + account_name="account1", + ).result() + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Accounts_ChangeKeyVault.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_create_or_update.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_create_or_update.py index 27e8f7bbd937..b7ad0afe34cf 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_create_or_update.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_create_or_update.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.netapp import NetAppManagementClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Accounts_CreateOrUpdate.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Accounts_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_create_or_update_ad.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_create_or_update_ad.py index 7a21d0a3d0a3..afc1ba7129db 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_create_or_update_ad.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_create_or_update_ad.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.netapp import NetAppManagementClient """ @@ -55,6 +58,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Accounts_CreateOrUpdateAD.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Accounts_CreateOrUpdateAD.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_delete.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_delete.py index 62abd44647dd..2c9035497a7d 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_delete.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Accounts_Delete.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Accounts_Delete.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_get.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_get.py index c3db01294c85..f2ce737969b4 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_get.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Accounts_Get.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Accounts_Get.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_get_change_key_vault_information.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_get_change_key_vault_information.py new file mode 100644 index 000000000000..41deb53de973 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_get_change_key_vault_information.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.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python accounts_get_change_key_vault_information.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 = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + response = client.accounts.begin_get_change_key_vault_information( + resource_group_name="myRG", + account_name="account1", + ).result() + print(response) + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Accounts_GetChangeKeyVaultInformation.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_list.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_list.py index 02b550812abc..3adb6ac7eb69 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_list.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Accounts_List.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Accounts_List.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_migrate_encryption_key.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_migrate_encryption_key.py new file mode 100644 index 000000000000..489e650c7bb1 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_migrate_encryption_key.py @@ -0,0 +1,41 @@ +# 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.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python accounts_migrate_encryption_key.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 = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + client.accounts.begin_migrate_encryption_key( + resource_group_name="myRG", + account_name="account1", + ).result() + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Accounts_MigrateEncryptionKey.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_renew_credentials.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_renew_credentials.py index e9dc945e7d35..1bef9bf906cf 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_renew_credentials.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_renew_credentials.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Accounts_RenewCredentials.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Accounts_RenewCredentials.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_update.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_update.py index 43c6b4e10557..fb196fc541f1 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_update.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/accounts_update.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.netapp import NetAppManagementClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Accounts_Update.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Accounts_Update.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_create.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_create.py index 936124a09c17..04b4f4d052ab 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_create.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_create.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.netapp import NetAppManagementClient """ @@ -46,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/BackupPolicies_Create.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupPolicies_Create.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_delete.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_delete.py index aff675116042..370d6c18851b 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_delete.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/BackupPolicies_Delete.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupPolicies_Delete.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_get.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_get.py index daacd8fbb84f..f93a557d8fe2 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_get.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/BackupPolicies_Get.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupPolicies_Get.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_list.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_list.py index 31b4e2a56f5e..cb1557746a00 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_list.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/BackupPolicies_List.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupPolicies_List.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_update.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_update.py index cf0da815a26c..2f166be4ede6 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_update.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_policies_update.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.netapp import NetAppManagementClient """ @@ -46,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/BackupPolicies_Update.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupPolicies_Update.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_vaults_create.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_vaults_create.py new file mode 100644 index 000000000000..fe96106a8df9 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_vaults_create.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. +# -------------------------------------------------------------------------- + +from typing import Any, IO, Union + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python backup_vaults_create.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 = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + response = client.backup_vaults.begin_create_or_update( + resource_group_name="myRG", + account_name="account1", + backup_vault_name="backupVault1", + body={"location": "eastus"}, + ).result() + print(response) + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupVaults_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_vaults_delete.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_vaults_delete.py new file mode 100644 index 000000000000..be6bae816c28 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_vaults_delete.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.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python backup_vaults_delete.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 = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + client.backup_vaults.begin_delete( + resource_group_name="resourceGroup", + account_name="account1", + backup_vault_name="backupVault1", + ).result() + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupVaults_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_vaults_get.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_vaults_get.py new file mode 100644 index 000000000000..acb8cd4215b0 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_vaults_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python backup_vaults_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + response = client.backup_vaults.get( + resource_group_name="myRG", + account_name="account1", + backup_vault_name="backupVault1", + ) + print(response) + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupVaults_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_vaults_list.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_vaults_list.py new file mode 100644 index 000000000000..8e0788937666 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_vaults_list.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python backup_vaults_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + response = client.backup_vaults.list_by_net_app_account( + resource_group_name="myRG", + account_name="account1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupVaults_List.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_vaults_update.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_vaults_update.py new file mode 100644 index 000000000000..7727909fe275 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backup_vaults_update.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. +# -------------------------------------------------------------------------- + +from typing import Any, IO, Union + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python backup_vaults_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + response = client.backup_vaults.begin_update( + resource_group_name="myRG", + account_name="account1", + backup_vault_name="backupVault1", + body={"tags": {"Tag1": "Value1"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupVaults_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_account_migrate.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_account_migrate.py new file mode 100644 index 000000000000..69b828ac1259 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_account_migrate.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. +# -------------------------------------------------------------------------- + +from typing import Any, IO, Union + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python backups_under_account_migrate.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 = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + client.backups_under_account.begin_migrate_backups( + resource_group_name="myRG", + account_name="account1", + body={ + "backupVaultId": "/subscriptions/D633CC2E-722B-4AE1-B636-BBD9E4C60ED9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/backupVaults/backupVault1" + }, + ).result() + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupsUnderAccount_Migrate.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_create.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_create.py new file mode 100644 index 000000000000..e1a810b03660 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_create.py @@ -0,0 +1,52 @@ +# 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.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python backups_under_backup_vault_create.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 = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + response = client.backups.begin_create( + resource_group_name="myRG", + account_name="account1", + backup_vault_name="backupVault1", + backup_name="backup1", + body={ + "properties": { + "label": "myLabel", + "volumeResourceId": "/subscriptions/D633CC2E-722B-4AE1-B636-BBD9E4C60ED9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPool/pool1/volumes/volume1", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupsUnderBackupVault_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_delete.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_delete.py new file mode 100644 index 000000000000..7678d73b57b7 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_delete.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python backups_under_backup_vault_delete.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 = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + client.backups.begin_delete( + resource_group_name="resourceGroup", + account_name="account1", + backup_vault_name="backupVault1", + backup_name="backup1", + ).result() + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupsUnderBackupVault_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_get.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_get.py new file mode 100644 index 000000000000..faffeb5ed584 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_get.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python backups_under_backup_vault_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + response = client.backups.get( + resource_group_name="myRG", + account_name="account1", + backup_vault_name="backupVault1", + backup_name="backup1", + ) + print(response) + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupsUnderBackupVault_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_list.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_list.py new file mode 100644 index 000000000000..9e8af34572ff --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_list.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python backups_under_backup_vault_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + response = client.backups.list_by_vault( + resource_group_name="myRG", + account_name="account1", + backup_vault_name="backupVault1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupsUnderBackupVault_List.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_single_file_restore.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_single_file_restore.py new file mode 100644 index 000000000000..340e3cd409e8 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_single_file_restore.py @@ -0,0 +1,49 @@ +# 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.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python backups_under_backup_vault_single_file_restore.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 = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + client.backups_under_backup_vault.begin_restore_files( + resource_group_name="myRG", + account_name="account1", + backup_vault_name="backupVault1", + backup_name="backup1", + body={ + "destinationVolumeId": "/subscriptions/D633CC2E-722B-4AE1-B636-BBD9E4C60ED9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1/volumes/volume1", + "fileList": ["/dir1/customer1.db", "/dir1/customer2.db"], + }, + ).result() + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupsUnderBackupVault_SingleFileRestore.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_update.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_update.py new file mode 100644 index 000000000000..680072d8187f --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_backup_vault_update.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python backups_under_backup_vault_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + response = client.backups.begin_update( + resource_group_name="myRG", + account_name="account1", + backup_vault_name="backupVault1", + backup_name="backup1", + ).result() + print(response) + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupsUnderBackupVault_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_volume_migrate.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_volume_migrate.py new file mode 100644 index 000000000000..a00c7107213e --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/backups_under_volume_migrate.py @@ -0,0 +1,48 @@ +# 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.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python backups_under_volume_migrate.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 = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + client.backups_under_volume.begin_migrate_backups( + resource_group_name="myRG", + account_name="account1", + pool_name="pool1", + volume_name="volume1", + body={ + "backupVaultId": "/subscriptions/D633CC2E-722B-4AE1-B636-BBD9E4C60ED9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/backupVaults/backupVault1" + }, + ).result() + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/BackupsUnderVolume_Migrate.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/group_id_list_for_ldap_user.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/group_id_list_for_ldap_user.py index b9149e232f97..18da7a29bb70 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/group_id_list_for_ldap_user.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/group_id_list_for_ldap_user.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.netapp import NetAppManagementClient """ @@ -39,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/GroupIdListForLDAPUser.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/GroupIdListForLDAPUser.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/operation_list.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/operation_list.py index 1f0fa1db5371..6df4b78f1289 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/operation_list.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/operation_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/OperationList.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/OperationList.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/pools_create_or_update.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/pools_create_or_update.py index 9c40c13dc58d..1b1b7049fbc6 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/pools_create_or_update.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/pools_create_or_update.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.netapp import NetAppManagementClient """ @@ -41,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Pools_CreateOrUpdate.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Pools_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/pools_delete.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/pools_delete.py index dbe2036967df..9f084974457b 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/pools_delete.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/pools_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Pools_Delete.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Pools_Delete.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/pools_get.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/pools_get.py index 7b2adb2d983b..48c3aaf0b220 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/pools_get.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/pools_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Pools_Get.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Pools_Get.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/pools_list.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/pools_list.py index e427cffeb9f6..d6f6b4b4cc8b 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/pools_list.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/pools_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Pools_List.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Pools_List.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/quota_limits_get.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/quota_limits_get.py index dae89db67328..546fa437a0b4 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/quota_limits_get.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/quota_limits_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/QuotaLimits_Get.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/QuotaLimits_Get.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/quota_limits_list.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/quota_limits_list.py index 4d73eb830f36..6fa8a5a00283 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/quota_limits_list.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/quota_limits_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/QuotaLimits_List.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/QuotaLimits_List.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/region_info.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/region_info.py index 12d77f645fee..d42e4618ac8a 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/region_info.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/region_info.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/RegionInfo.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/RegionInfo.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/region_infos_get.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/region_infos_get.py new file mode 100644 index 000000000000..38e4beecc6e7 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/region_infos_get.py @@ -0,0 +1,41 @@ +# 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.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python region_infos_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + response = client.net_app_resource_region_infos.get( + location="eastus", + ) + print(response) + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/RegionInfos_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/region_infos_list.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/region_infos_list.py new file mode 100644 index 000000000000..39867da55cee --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/region_infos_list.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.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python region_infos_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + response = client.net_app_resource_region_infos.list( + location="eastus", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/RegionInfos_List.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_create.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_create.py index 1678eccd1256..d6eb44951dd8 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_create.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_create.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.netapp import NetAppManagementClient """ @@ -47,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/SnapshotPolicies_Create.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/SnapshotPolicies_Create.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_delete.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_delete.py index 5f5da914dc6f..68da6bfde590 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_delete.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/SnapshotPolicies_Delete.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/SnapshotPolicies_Delete.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_get.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_get.py index b9908ed057b3..1c2c8b115ccb 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_get.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/SnapshotPolicies_Get.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/SnapshotPolicies_Get.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_list.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_list.py index 26d2e831e491..a53b7806f719 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_list.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/SnapshotPolicies_List.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/SnapshotPolicies_List.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_list_volumes.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_list_volumes.py index 398e6bb7826a..063efd1a4036 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_list_volumes.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_list_volumes.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/SnapshotPolicies_ListVolumes.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/SnapshotPolicies_ListVolumes.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_update.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_update.py index 4217a0d088f6..f9109e86b48c 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_update.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshot_policies_update.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.netapp import NetAppManagementClient """ @@ -47,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/SnapshotPolicies_Update.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/SnapshotPolicies_Update.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_create.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_create.py index b50002385e1f..ef073d0fc595 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_create.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_create.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.netapp import NetAppManagementClient """ @@ -40,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Snapshots_Create.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Snapshots_Create.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_delete.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_delete.py index c5a67c350c1a..14e1abde8db8 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_delete.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -38,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Snapshots_Delete.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Snapshots_Delete.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_get.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_get.py index ea2eb78ed212..0f3ee7ad9a30 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_get.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Snapshots_Get.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Snapshots_Get.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_list.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_list.py index 0af89ecdf611..870fe74b8180 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_list.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Snapshots_List.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Snapshots_List.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_single_file_restore.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_single_file_restore.py index 59c418f41c36..221294c5c0f2 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_single_file_restore.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/snapshots_single_file_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.netapp import NetAppManagementClient """ @@ -39,6 +42,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Snapshots_SingleFileRestore.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Snapshots_SingleFileRestore.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_create.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_create.py index 37abe0c9d7d6..1d0fd3221f3a 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_create.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_create.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.netapp import NetAppManagementClient """ @@ -40,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Subvolumes_Create.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Subvolumes_Create.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_delete.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_delete.py index 64bfac5d0189..7f8038915dfb 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_delete.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -38,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Subvolumes_Delete.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Subvolumes_Delete.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_get.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_get.py index 57f136c38eb7..2ca23526323f 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_get.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Subvolumes_Get.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Subvolumes_Get.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_list.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_list.py index 9df386c06520..5a4d454b308f 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_list.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Subvolumes_List.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Subvolumes_List.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_metadata.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_metadata.py index 50c0d6f5c4a9..b150c5a0fdcf 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_metadata.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_metadata.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Subvolumes_Metadata.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Subvolumes_Metadata.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_update.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_update.py index 95376be6cd9b..abb2c1484abd 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_update.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/subvolumes_update.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.netapp import NetAppManagementClient """ @@ -40,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Subvolumes_Update.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Subvolumes_Update.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_create_oracle.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_create_oracle.py index f1fb452e6e6a..a3abe778d2bc 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_create_oracle.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_create_oracle.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.netapp import NetAppManagementClient """ @@ -457,6 +460,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/VolumeGroups_Create_Oracle.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/VolumeGroups_Create_Oracle.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_create_sap_hana.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_create_sap_hana.py index 824a61fc7a35..7e4c3178fc33 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_create_sap_hana.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_create_sap_hana.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.netapp import NetAppManagementClient """ @@ -219,6 +222,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/VolumeGroups_Create_SapHana.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/VolumeGroups_Create_SapHana.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_delete.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_delete.py index 12e8ab348540..2300bb5fd76b 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_delete.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/VolumeGroups_Delete.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/VolumeGroups_Delete.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_get_oracle.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_get_oracle.py index baa614bdca9d..30838bcc307f 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_get_oracle.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_get_oracle.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/VolumeGroups_Get_Oracle.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/VolumeGroups_Get_Oracle.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_get_sap_hana.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_get_sap_hana.py index ef2059400251..0b9548e28ce7 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_get_sap_hana.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_get_sap_hana.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/VolumeGroups_Get_SapHana.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/VolumeGroups_Get_SapHana.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_list_oracle.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_list_oracle.py index 69b0a5d045f4..3acd150a1a08 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_list_oracle.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_list_oracle.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/VolumeGroups_List_Oracle.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/VolumeGroups_List_Oracle.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_list_sap_hana.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_list_sap_hana.py index fc1cdc77a5eb..72762949092d 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_list_sap_hana.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_groups_list_sap_hana.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/VolumeGroups_List_SapHana.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/VolumeGroups_List_SapHana.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_create.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_create.py index 67074e67139e..00462efbb5c3 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_create.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_create.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.netapp import NetAppManagementClient """ @@ -43,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/VolumeQuotaRules_Create.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/VolumeQuotaRules_Create.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_delete.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_delete.py index 010edda7b6cd..0ad73313dc07 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_delete.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -38,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/VolumeQuotaRules_Delete.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/VolumeQuotaRules_Delete.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_get.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_get.py index 9771e78c8c47..003a4621d3e3 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_get.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/VolumeQuotaRules_Get.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/VolumeQuotaRules_Get.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_list.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_list.py index c4c0d4ed26f0..ecacf25d9d49 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_list.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/VolumeQuotaRules_List.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/VolumeQuotaRules_List.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_update.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_update.py index 189b0c835711..5c65b3cff21e 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_update.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volume_quota_rules_update.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.netapp import NetAppManagementClient """ @@ -40,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/VolumeQuotaRules_Update.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/VolumeQuotaRules_Update.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_authorize_replication.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_authorize_replication.py index 4f852f81f668..ef0bb4f8d275 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_authorize_replication.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_authorize_replication.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.netapp import NetAppManagementClient """ @@ -40,6 +43,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_AuthorizeReplication.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_AuthorizeReplication.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_break_file_locks.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_break_file_locks.py index 7e5439618406..cb4eb46168ed 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_break_file_locks.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_break_file_locks.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_BreakFileLocks.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_BreakFileLocks.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_break_replication.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_break_replication.py index 23cd8818f856..6bed27559078 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_break_replication.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_break_replication.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_BreakReplication.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_BreakReplication.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_create_on_prem_migration_replication.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_create_on_prem_migration_replication.py new file mode 100644 index 000000000000..7051613bfc17 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_create_on_prem_migration_replication.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python volumes_create_on_prem_migration_replication.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 = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + response = client.volumes.begin_create_on_prem_migration_replication( + resource_group_name="myRG", + account_name="account1", + pool_name="pool1", + volume_name="volume1", + ).result() + print(response) + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_CreateOnPremMigrationReplication.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_create_or_update.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_create_or_update.py index 5f3516148720..7831544ade47 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_create_or_update.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_create_or_update.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.netapp import NetAppManagementClient """ @@ -47,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_CreateOrUpdate.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_delete.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_delete.py index 76f8e37ee014..7cf2eb201985 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_delete.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_Delete.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_Delete.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_delete_replication.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_delete_replication.py index 45fc8c7f7c23..57c46e2513b2 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_delete_replication.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_delete_replication.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_DeleteReplication.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_DeleteReplication.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_finalize_on_prem_migration.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_finalize_on_prem_migration.py new file mode 100644 index 000000000000..93b447c29de5 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_finalize_on_prem_migration.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python volumes_finalize_on_prem_migration.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 = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + client.volumes.begin_finalize_on_prem_migration( + resource_group_name="myRG", + account_name="account1", + pool_name="pool1", + volume_name="volume1", + ).result() + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_FinalizeOnPremMigration.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_finalize_relocation.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_finalize_relocation.py index 786ce6788ced..f6eb40fda2af 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_finalize_relocation.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_finalize_relocation.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_FinalizeRelocation.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_FinalizeRelocation.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_get.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_get.py index 9ffa59303d86..aed1f2485b8a 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_get.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_Get.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_Get.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_restore_status.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_latest_backup_status.py similarity index 89% rename from sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_restore_status.py rename to sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_latest_backup_status.py index 6a3e74bddf74..688403a596f0 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_restore_status.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_latest_backup_status.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -14,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-netapp # USAGE - python volumes_restore_status.py + python volumes_latest_backup_status.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, @@ -29,7 +30,7 @@ def main(): subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", ) - response = client.backups.get_volume_restore_status( + response = client.backups.get_latest_status( resource_group_name="myRG", account_name="account1", pool_name="pool1", @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_RestoreStatus.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_LatestBackupStatus.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_latest_restore_status.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_latest_restore_status.py new file mode 100644 index 000000000000..a961789898e0 --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_latest_restore_status.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python volumes_latest_restore_status.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 = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + response = client.backups.get_volume_latest_restore_status( + resource_group_name="myRG", + account_name="account1", + pool_name="pool1", + volume_name="volume1", + ) + print(response) + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_LatestRestoreStatus.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_list.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_list.py index 83562618ee82..8ad76e2df068 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_list.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_List.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_List.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_list_replications.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_list_replications.py index d7d96768e37c..ad5d7d888180 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_list_replications.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_list_replications.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -39,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_ListReplications.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_ListReplications.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_peer_cluster_for_on_prem_migration.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_peer_cluster_for_on_prem_migration.py new file mode 100644 index 000000000000..6ef1de7ef3ed --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_peer_cluster_for_on_prem_migration.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. +# -------------------------------------------------------------------------- + +from typing import Any, IO, Union + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python volumes_peer_cluster_for_on_prem_migration.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 = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + response = client.volumes.begin_peer_cluster_for_on_prem_migration( + resource_group_name="myRG", + account_name="account1", + pool_name="pool1", + volume_name="volume1", + body={"peerAddresses": ["0.0.0.1", "0.0.0.2", "0.0.0.3", "0.0.0.4", "0.0.0.5", "0.0.0.6"]}, + ).result() + print(response) + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_PeerClusterForOnPremMigration.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_perform_replication_transfer.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_perform_replication_transfer.py new file mode 100644 index 000000000000..57ee39cca0da --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_perform_replication_transfer.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python volumes_perform_replication_transfer.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 = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + client.volumes.begin_perform_replication_transfer( + resource_group_name="myRG", + account_name="account1", + pool_name="pool1", + volume_name="volume1", + ).result() + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_PerformReplicationTransfer.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_pool_change.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_pool_change.py index fc27614fc481..45f680822d4a 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_pool_change.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_pool_change.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.netapp import NetAppManagementClient """ @@ -40,6 +43,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_PoolChange.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_PoolChange.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_populate_availability_zones.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_populate_availability_zones.py index e5ae02bbf23a..a474f9fecb8b 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_populate_availability_zones.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_populate_availability_zones.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_PopulateAvailabilityZones.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_PopulateAvailabilityZones.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_re_initialize_replication.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_re_initialize_replication.py index ad83039ea9c0..97992ef4fd03 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_re_initialize_replication.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_re_initialize_replication.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_ReInitializeReplication.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_ReInitializeReplication.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_reestablish_replication.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_reestablish_replication.py index d3759b3d1ec2..d98ae0eb1b97 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_reestablish_replication.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_reestablish_replication.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.netapp import NetAppManagementClient """ @@ -40,6 +43,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_ReestablishReplication.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_ReestablishReplication.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_relocate.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_relocate.py index b8c9d5b5de08..d8ede1d11513 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_relocate.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_relocate.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_Relocate.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_Relocate.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_replication_status.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_replication_status.py index ec2847cf5032..5b91af2838bb 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_replication_status.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_replication_status.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_ReplicationStatus.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_ReplicationStatus.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_reset_cifs_password.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_reset_cifs_password.py index d63bb8a1a0ba..e7b88e6b1705 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_reset_cifs_password.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_reset_cifs_password.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_ResetCifsPassword.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_ResetCifsPassword.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_resync_replication.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_resync_replication.py index c9ee756d04d0..0c5b117216e9 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_resync_replication.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_resync_replication.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_ResyncReplication.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_ResyncReplication.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_revert.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_revert.py index cfc14e9af712..6424ac207def 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_revert.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_revert.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.netapp import NetAppManagementClient """ @@ -40,6 +43,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_Revert.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_Revert.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_revert_relocation.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_revert_relocation.py index 0b93145ed8d7..fd35dfbd55f1 100644 --- a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_revert_relocation.py +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_revert_relocation.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.netapp import NetAppManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/stable/2023-07-01/examples/Volumes_RevertRelocation.json +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_RevertRelocation.json if __name__ == "__main__": main() diff --git a/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_split_clone.py b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_split_clone.py new file mode 100644 index 000000000000..dd5c518645ef --- /dev/null +++ b/sdk/netapp/azure-mgmt-netapp/generated_samples/volumes_split_clone.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.netapp import NetAppManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-netapp +# USAGE + python volumes_split_clone.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 = NetAppManagementClient( + credential=DefaultAzureCredential(), + subscription_id="D633CC2E-722B-4AE1-B636-BBD9E4C60ED9", + ) + + client.volumes.begin_split_clone_from_parent( + resource_group_name="myRG", + account_name="account1", + pool_name="pool1", + volume_name="volume1", + ).result() + + +# x-ms-original-file: specification/netapp/resource-manager/Microsoft.NetApp/preview/2023-11-01-preview/examples/Volumes_SplitClone.json +if __name__ == "__main__": + main() diff --git a/sdk/netapp/azure-mgmt-netapp/setup.py b/sdk/netapp/azure-mgmt-netapp/setup.py index 9f0bcddb9144..8d51a7d7b726 100644 --- a/sdk/netapp/azure-mgmt-netapp/setup.py +++ b/sdk/netapp/azure-mgmt-netapp/setup.py @@ -74,9 +74,9 @@ "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", + "isodate>=0.6.1", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], python_requires=">=3.8", )