From 50d2cb34815c8aa62dc90e2d91586fff0c335bd0 Mon Sep 17 00:00:00 2001 From: Tamer Sherif Date: Thu, 27 Aug 2020 12:15:33 -0700 Subject: [PATCH] reverted undelete container changes --- .../azure/storage/blob/_blob_service_client.py | 9 ++++++++- .../azure/storage/blob/aio/_blob_service_client_async.py | 9 ++++++++- sdk/storage/azure-storage-blob/tests/test_container.py | 6 +++--- .../azure-storage-blob/tests/test_container_async.py | 4 ++-- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_blob_service_client.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_blob_service_client.py index bde847565590..fc1249cf8c02 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_blob_service_client.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_blob_service_client.py @@ -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. @@ -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) @@ -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. diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_blob_service_client_async.py b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_blob_service_client_async.py index ab2e8a0defc7..7ccb4237bc10 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_blob_service_client_async.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/aio/_blob_service_client_async.py @@ -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. @@ -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( @@ -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. diff --git a/sdk/storage/azure-storage-blob/tests/test_container.py b/sdk/storage/azure-storage-blob/tests/test_container.py index 5e182af618b1..f5a4ff21a747 100644 --- a/sdk/storage/azure-storage-blob/tests/test_container.py +++ b/sdk/storage/azure-storage-blob/tests/test_container.py @@ -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 @@ -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 @@ -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 diff --git a/sdk/storage/azure-storage-blob/tests/test_container_async.py b/sdk/storage/azure-storage-blob/tests/test_container_async.py index d6e4563cb406..9c280615e91f 100644 --- a/sdk/storage/azure-storage-blob/tests/test_container_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_container_async.py @@ -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 @@ -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()