Skip to content

Commit

Permalink
reverted undelete container changes (#13377)
Browse files Browse the repository at this point in the history
  • Loading branch information
tasherif-msft committed Aug 28, 2020
1 parent 7812a88 commit be0e42b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,10 @@ def list_containers(
:param bool include_metadata:
Specifies that container metadata to be returned in the response.
The default value is `False`.
:keyword bool include_deleted:
Specifies that deleted containers to be returned in the response. This is for container restore enabled
account. The default value is `False`.
.. versionadded:: 12.4.0
:keyword int results_per_page:
The maximum number of container names to retrieve per API
call. If the request does not specify the server will return up to 5,000 items.
Expand All @@ -401,6 +405,9 @@ def list_containers(
:caption: Listing the containers in the blob service.
"""
include = ['metadata'] if include_metadata else []
include_deleted = kwargs.pop('include_deleted', None)
if include_deleted:
include.append("deleted")

timeout = kwargs.pop('timeout', None)
results_per_page = kwargs.pop('results_per_page', None)
Expand Down Expand Up @@ -557,7 +564,7 @@ def delete_container(
**kwargs)

@distributed_trace
def _undelete_container(self, deleted_container_name, deleted_container_version, new_name=None, **kwargs):
def undelete_container(self, deleted_container_name, deleted_container_version, new_name=None, **kwargs):
# type: (str, str, str, **Any) -> ContainerClient
"""Restores soft-deleted container.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ def list_containers(
:param bool include_metadata:
Specifies that container metadata to be returned in the response.
The default value is `False`.
:keyword bool include_deleted:
Specifies that deleted containers to be returned in the response. This is for container restore enabled
account. The default value is `False`.
.. versionadded:: 12.4.0
:keyword int results_per_page:
The maximum number of container names to retrieve per API
call. If the request does not specify the server will return up to 5,000 items.
Expand All @@ -355,6 +359,9 @@ def list_containers(
:caption: Listing the containers in the blob service.
"""
include = ['metadata'] if include_metadata else []
include_deleted = kwargs.pop('include_deleted', None)
if include_deleted:
include.append("deleted")
timeout = kwargs.pop('timeout', None)
results_per_page = kwargs.pop('results_per_page', None)
command = functools.partial(
Expand Down Expand Up @@ -510,7 +517,7 @@ async def delete_container(
**kwargs)

@distributed_trace_async
async def _undelete_container(self, deleted_container_name, deleted_container_version, new_name=None, **kwargs):
async def undelete_container(self, deleted_container_name, deleted_container_version, new_name=None, **kwargs):
# type: (str, str, str, **Any) -> ContainerClient
"""Restores soft-deleted container.
Expand Down
6 changes: 3 additions & 3 deletions sdk/storage/azure-storage-blob/tests/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ def test_undelete_container(self, resource_group, location, storage_account, sto
for container in container_list:
# find the deleted container and restore it
if container.deleted and container.name == container_client.container_name:
restored_ctn_client = bsc._undelete_container(container.name, container.version,
restored_ctn_client = bsc.undelete_container(container.name, container.version,
new_name="restored" + str(restored_version))
restored_version += 1

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

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

Expand Down
4 changes: 2 additions & 2 deletions sdk/storage/azure-storage-blob/tests/test_container_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ async def test_undelete_container(self, resource_group, location, storage_accoun
for container in container_list:
# find the deleted container and restore it
if container.deleted and container.name == container_client.container_name:
restored_ctn_client = await bsc._undelete_container(container.name, container.version,
restored_ctn_client = await bsc.undelete_container(container.name, container.version,
new_name="restoredctn" + str(restored_version))
restored_version += 1

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

@GlobalStorageAccountPreparer()
Expand Down

0 comments on commit be0e42b

Please sign in to comment.