Skip to content

Commit be0e42b

Browse files
reverted undelete container changes (#13377)
1 parent 7812a88 commit be0e42b

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,10 @@ def list_containers(
383383
:param bool include_metadata:
384384
Specifies that container metadata to be returned in the response.
385385
The default value is `False`.
386+
:keyword bool include_deleted:
387+
Specifies that deleted containers to be returned in the response. This is for container restore enabled
388+
account. The default value is `False`.
389+
.. versionadded:: 12.4.0
386390
:keyword int results_per_page:
387391
The maximum number of container names to retrieve per API
388392
call. If the request does not specify the server will return up to 5,000 items.
@@ -401,6 +405,9 @@ def list_containers(
401405
:caption: Listing the containers in the blob service.
402406
"""
403407
include = ['metadata'] if include_metadata else []
408+
include_deleted = kwargs.pop('include_deleted', None)
409+
if include_deleted:
410+
include.append("deleted")
404411

405412
timeout = kwargs.pop('timeout', None)
406413
results_per_page = kwargs.pop('results_per_page', None)
@@ -557,7 +564,7 @@ def delete_container(
557564
**kwargs)
558565

559566
@distributed_trace
560-
def _undelete_container(self, deleted_container_name, deleted_container_version, new_name=None, **kwargs):
567+
def undelete_container(self, deleted_container_name, deleted_container_version, new_name=None, **kwargs):
561568
# type: (str, str, str, **Any) -> ContainerClient
562569
"""Restores soft-deleted container.
563570

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ def list_containers(
337337
:param bool include_metadata:
338338
Specifies that container metadata to be returned in the response.
339339
The default value is `False`.
340+
:keyword bool include_deleted:
341+
Specifies that deleted containers to be returned in the response. This is for container restore enabled
342+
account. The default value is `False`.
343+
.. versionadded:: 12.4.0
340344
:keyword int results_per_page:
341345
The maximum number of container names to retrieve per API
342346
call. If the request does not specify the server will return up to 5,000 items.
@@ -355,6 +359,9 @@ def list_containers(
355359
:caption: Listing the containers in the blob service.
356360
"""
357361
include = ['metadata'] if include_metadata else []
362+
include_deleted = kwargs.pop('include_deleted', None)
363+
if include_deleted:
364+
include.append("deleted")
358365
timeout = kwargs.pop('timeout', None)
359366
results_per_page = kwargs.pop('results_per_page', None)
360367
command = functools.partial(
@@ -510,7 +517,7 @@ async def delete_container(
510517
**kwargs)
511518

512519
@distributed_trace_async
513-
async def _undelete_container(self, deleted_container_name, deleted_container_version, new_name=None, **kwargs):
520+
async def undelete_container(self, deleted_container_name, deleted_container_version, new_name=None, **kwargs):
514521
# type: (str, str, str, **Any) -> ContainerClient
515522
"""Restores soft-deleted container.
516523

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ def test_undelete_container(self, resource_group, location, storage_account, sto
742742
for container in container_list:
743743
# find the deleted container and restore it
744744
if container.deleted and container.name == container_client.container_name:
745-
restored_ctn_client = bsc._undelete_container(container.name, container.version,
745+
restored_ctn_client = bsc.undelete_container(container.name, container.version,
746746
new_name="restored" + str(restored_version))
747747
restored_version += 1
748748

@@ -774,7 +774,7 @@ def test_restore_to_existing_container(self, resource_group, location, storage_a
774774
# find the deleted container and restore it
775775
if container.deleted and container.name == container_client.container_name:
776776
with self.assertRaises(HttpResponseError):
777-
bsc._undelete_container(container.name, container.version,
777+
bsc.undelete_container(container.name, container.version,
778778
new_name=existing_container_client.container_name)
779779

780780
@pytest.mark.live_test_only # sas token is dynamically generated
@@ -804,7 +804,7 @@ def test_restore_with_sas(self, resource_group, location, storage_account, stora
804804
for container in container_list:
805805
# find the deleted container and restore it
806806
if container.deleted and container.name == container_client.container_name:
807-
restored_ctn_client = bsc._undelete_container(container.name, container.version,
807+
restored_ctn_client = bsc.undelete_container(container.name, container.version,
808808
new_name="restored" + str(restored_version))
809809
restored_version += 1
810810

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ async def test_undelete_container(self, resource_group, location, storage_accoun
806806
for container in container_list:
807807
# find the deleted container and restore it
808808
if container.deleted and container.name == container_client.container_name:
809-
restored_ctn_client = await bsc._undelete_container(container.name, container.version,
809+
restored_ctn_client = await bsc.undelete_container(container.name, container.version,
810810
new_name="restoredctn" + str(restored_version))
811811
restored_version += 1
812812

@@ -841,7 +841,7 @@ async def test_restore_to_existing_container(self, resource_group, location, sto
841841
# find the deleted container and restore it
842842
if container.deleted and container.name == container_client.container_name:
843843
with self.assertRaises(HttpResponseError):
844-
await bsc._undelete_container(container.name, container.version,
844+
await bsc.undelete_container(container.name, container.version,
845845
new_name=existing_container_client.container_name)
846846

847847
@GlobalStorageAccountPreparer()

0 commit comments

Comments
 (0)