Skip to content

Commit 1fadc7e

Browse files
Deprecated new_name in Undelete (#18690)
* Deprecated new_name in Undelete * added additional TODO comments on soft delete enabled tests * removed it from DSC * removed line
1 parent ecdd736 commit 1fadc7e

16 files changed

+372
-2688
lines changed

sdk/storage/azure-storage-blob/azure/storage/blob/_blob_service_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# --------------------------------------------------------------------------
66

77
import functools
8+
import warnings
89
from typing import ( # pylint: disable=unused-import
910
Union, Optional, Any, Iterable, Dict, List,
1011
TYPE_CHECKING
@@ -624,14 +625,13 @@ def undelete_container(self, deleted_container_name, deleted_container_version,
624625
Specifies the name of the deleted container to restore.
625626
:param str deleted_container_version:
626627
Specifies the version of the deleted container to restore.
627-
:keyword str new_name:
628-
The new name for the deleted container to be restored to.
629-
If not specified deleted_container_name will be used as the restored container name.
630628
:keyword int timeout:
631629
The timeout parameter is expressed in seconds.
632630
:rtype: ~azure.storage.blob.ContainerClient
633631
"""
634632
new_name = kwargs.pop('new_name', None)
633+
if new_name:
634+
warnings.warn("`new_name` is no longer supported.", DeprecationWarning)
635635
container = self.get_container_client(new_name or deleted_container_name)
636636
try:
637637
container._client.container.restore(deleted_container_name=deleted_container_name, # pylint: disable = protected-access

sdk/storage/azure-storage-blob/azure/storage/blob/aio/_blob_service_client_async.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# --------------------------------------------------------------------------
66
# pylint: disable=invalid-overridden-method
77
import functools
8+
import warnings
89
from typing import ( # pylint: disable=unused-import
910
Union, Optional, Any, Iterable, Dict, List,
1011
TYPE_CHECKING
@@ -567,14 +568,13 @@ async def undelete_container(self, deleted_container_name, deleted_container_ver
567568
Specifies the name of the deleted container to restore.
568569
:param str deleted_container_version:
569570
Specifies the version of the deleted container to restore.
570-
:keyword str new_name:
571-
The new name for the deleted container to be restored to.
572-
If not specified deleted_container_name will be used as the restored container name.
573571
:keyword int timeout:
574572
The timeout parameter is expressed in seconds.
575573
:rtype: ~azure.storage.blob.aio.ContainerClient
576574
"""
577575
new_name = kwargs.pop('new_name', None)
576+
if new_name:
577+
warnings.warn("`new_name` is no longer supported.", DeprecationWarning)
578578
container = self.get_container_client(new_name or deleted_container_name)
579579
try:
580580
await container._client.container.restore(deleted_container_name=deleted_container_name, # pylint: disable = protected-access

sdk/storage/azure-storage-blob/tests/recordings/test_container.test_restore_to_existing_container.yaml

Lines changed: 0 additions & 262 deletions
This file was deleted.

sdk/storage/azure-storage-blob/tests/recordings/test_container.test_undelete_container.yaml

Lines changed: 63 additions & 431 deletions
Large diffs are not rendered by default.

sdk/storage/azure-storage-blob/tests/recordings/test_container_async.test_restore_to_existing_container.yaml

Lines changed: 0 additions & 260 deletions
This file was deleted.

sdk/storage/azure-storage-blob/tests/recordings/test_container_async.test_undelete_container.yaml

Lines changed: 74 additions & 411 deletions
Large diffs are not rendered by default.

sdk/storage/azure-storage-blob/tests/test_container.py

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# --------------------------------------------------------------------------
88

99
import sys
10+
import time
1011
from datetime import datetime, timedelta
1112
from time import sleep
1213

@@ -797,8 +798,7 @@ def test_delete_container_with_lease_id(self, resource_group, location, storage_
797798
@pytest.mark.playback_test_only
798799
@GlobalStorageAccountPreparer()
799800
def test_undelete_container(self, resource_group, location, storage_account, storage_account_key):
800-
# container soft delete should enabled by SRP call or use armclient, so make this test as playback only.
801-
801+
# TODO: container soft delete should enabled by SRP call or use ARM, so make this test as playback only.
802802
bsc = BlobServiceClient(self.account_url(storage_account, "blob"), storage_account_key)
803803
container_client = self._create_container(bsc)
804804

@@ -811,49 +811,20 @@ def test_undelete_container(self, resource_group, location, storage_account, sto
811811
container_list = list(bsc.list_containers(include_deleted=True))
812812
self.assertTrue(len(container_list) >= 1)
813813

814-
restored_version = 0
815814
for container in container_list:
816815
# find the deleted container and restore it
817816
if container.deleted and container.name == container_client.container_name:
818-
restored_ctn_client = bsc.undelete_container(container.name, container.version,
819-
new_name="restored" + str(restored_version))
820-
restored_version += 1
817+
restored_ctn_client = bsc.undelete_container(container.name, container.version)
821818

822819
# to make sure the deleted container is restored
823820
props = restored_ctn_client.get_container_properties()
824821
self.assertIsNotNone(props)
825822

826-
@pytest.mark.playback_test_only
827-
@GlobalStorageAccountPreparer()
828-
def test_restore_to_existing_container(self, resource_group, location, storage_account, storage_account_key):
829-
# container soft delete should enabled by SRP call or use armclient, so make this test as playback only.
830-
831-
bsc = BlobServiceClient(self.account_url(storage_account, "blob"), storage_account_key)
832-
# get an existing container
833-
existing_container_client = self._create_container(bsc, prefix="existing")
834-
container_client = self._create_container(bsc)
835-
836-
# Act
837-
container_client.delete_container()
838-
# to make sure the container deleted
839-
with self.assertRaises(ResourceNotFoundError):
840-
container_client.get_container_properties()
841-
842-
container_list = list(bsc.list_containers(include_deleted=True))
843-
self.assertTrue(len(container_list) >= 1)
844-
845-
for container in container_list:
846-
# find the deleted container and restore it
847-
if container.deleted and container.name == container_client.container_name:
848-
with self.assertRaises(HttpResponseError):
849-
bsc.undelete_container(container.name, container.version,
850-
new_name=existing_container_client.container_name)
851-
852823
@pytest.mark.live_test_only # sas token is dynamically generated
853824
@pytest.mark.playback_test_only # we need container soft delete enabled account
854825
@GlobalStorageAccountPreparer()
855826
def test_restore_with_sas(self, resource_group, location, storage_account, storage_account_key):
856-
# container soft delete should enabled by SRP call or use armclient, so make this test as playback only.
827+
# TODO: container soft delete should enabled by SRP call or use ARM, so make this test as playback only.
857828
token = generate_account_sas(
858829
storage_account.name,
859830
storage_account_key,
@@ -875,9 +846,7 @@ def test_restore_with_sas(self, resource_group, location, storage_account, stora
875846
for container in container_list:
876847
# find the deleted container and restore it
877848
if container.deleted and container.name == container_client.container_name:
878-
restored_ctn_client = bsc.undelete_container(container.name, container.version,
879-
new_name="restored" + str(restored_version))
880-
restored_version += 1
849+
restored_ctn_client = bsc.undelete_container(container.name, container.version)
881850

882851
# to make sure the deleted container is restored
883852
props = restored_ctn_client.get_container_properties()

sdk/storage/azure-storage-blob/tests/test_container_async.py

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# Licensed under the MIT License. See License.txt in the project root for
66
# license information.
77
# --------------------------------------------------------------------------
8+
import time
89
from time import sleep
910

1011
import pytest
@@ -890,8 +891,7 @@ async def test_delete_container_with_lease_id(self, resource_group, location, st
890891
@GlobalStorageAccountPreparer()
891892
@AsyncStorageTestCase.await_prepared_test
892893
async def test_undelete_container(self, resource_group, location, storage_account, storage_account_key):
893-
# container soft delete should enabled by SRP call or use armclient, so make this test as playback only.
894-
pytest.skip('This will be added back along with STG74 features')
894+
# TODO: container soft delete should enabled by SRP call or use ARM, so make this test as playback only.
895895
bsc = BlobServiceClient(self.account_url(storage_account, "blob"), storage_account_key)
896896
container_client = await self._create_container(bsc)
897897

@@ -906,48 +906,15 @@ async def test_undelete_container(self, resource_group, location, storage_accoun
906906
container_list.append(c)
907907
self.assertTrue(len(container_list) >= 1)
908908

909-
restored_version = 0
910909
for container in container_list:
911910
# find the deleted container and restore it
912911
if container.deleted and container.name == container_client.container_name:
913-
restored_ctn_client = await bsc.undelete_container(container.name, container.version,
914-
new_name="restoredctn" + str(restored_version))
915-
restored_version += 1
912+
restored_ctn_client = await bsc.undelete_container(container.name, container.version)
916913

917914
# to make sure the deleted container is restored
918915
props = await restored_ctn_client.get_container_properties()
919916
self.assertIsNotNone(props)
920917

921-
@pytest.mark.playback_test_only
922-
@GlobalStorageAccountPreparer()
923-
@AsyncStorageTestCase.await_prepared_test
924-
async def test_restore_to_existing_container(self, resource_group, location, storage_account, storage_account_key):
925-
pytest.skip('This will be added back along with STG74 features')
926-
# container soft delete should enabled by SRP call or use armclient, so make this test as playback only.
927-
928-
bsc = BlobServiceClient(self.account_url(storage_account, "blob"), storage_account_key)
929-
# get an existing container
930-
existing_container_client = await self._create_container(bsc, prefix="existing")
931-
container_client = await self._create_container(bsc)
932-
933-
# Act
934-
await container_client.delete_container()
935-
# to make sure the container deleted
936-
with self.assertRaises(ResourceNotFoundError):
937-
await container_client.get_container_properties()
938-
939-
container_list = list()
940-
async for c in bsc.list_containers(include_deleted=True):
941-
container_list.append(c)
942-
self.assertTrue(len(container_list) >= 1)
943-
944-
for container in container_list:
945-
# find the deleted container and restore it
946-
if container.deleted and container.name == container_client.container_name:
947-
with self.assertRaises(HttpResponseError):
948-
await bsc.undelete_container(container.name, container.version,
949-
new_name=existing_container_client.container_name)
950-
951918
@GlobalStorageAccountPreparer()
952919
@AsyncStorageTestCase.await_prepared_test
953920
async def test_list_names(self, resource_group, location, storage_account, storage_account_key):

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_service_client.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,6 @@ def undelete_file_system(self, name, deleted_version, **kwargs):
294294
Specifies the name of the deleted filesystem to restore.
295295
:param str deleted_version:
296296
Specifies the version of the deleted filesystem to restore.
297-
:keyword str new_name:
298-
The new name for the deleted filesystem to be restored to.
299-
If not specified "name" will be used as the restored filesystem name.
300297
:keyword int timeout:
301298
The timeout parameter is expressed in seconds.
302299
:rtype: ~azure.storage.filedatalake.FileSystemClient

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_service_client_async.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,6 @@ async def undelete_file_system(self, name, deleted_version, **kwargs):
244244
Specifies the name of the deleted filesystem to restore.
245245
:param str deleted_version:
246246
Specifies the version of the deleted filesystem to restore.
247-
:keyword str new_name:
248-
The new name for the deleted filesystem to be restored to.
249-
If not specified "name" will be used as the restored filesystem name.
250247
:keyword int timeout:
251248
The timeout parameter is expressed in seconds.
252249
:rtype: ~azure.storage.filedatalake.FileSystemClient

0 commit comments

Comments
 (0)