From ec5beeeef09473ee7a2b0ea387078dd073681e54 Mon Sep 17 00:00:00 2001
From: tasherif-msft <69483382+tasherif-msft@users.noreply.github.com>
Date: Sun, 17 Jan 2021 22:49:30 -0800
Subject: [PATCH] Added Container Rename (Blobs & Datalake) and Container
Restore (Datalake) (#16088)
* generated container rename
* ormetadata
* added sync and async method for
* added all missing methods
* added all missing methods
* added kwargs
* generated from main swagger branch
* swagger change
* downgraded version
* added rename_container sync and async tests
* added all tests and fixed filesystems models
* fixing recordings
* removed uselesss param
* fixed failing test
* fixed bad import
---
.../storage/blob/_blob_service_client.py | 36 +-
.../storage/blob/_generated/_configuration.py | 2 +-
.../blob/_generated/aio/_configuration.py | 2 +-
.../aio/operations/_container_operations.py | 170 +++++++++-
.../operations/_container_operations.py | 172 +++++++++-
.../blob/aio/_blob_service_client_async.py | 36 +-
.../azure-storage-blob/swagger/README.md | 2 +-
.../test_container.test_rename_container.yaml | 281 ++++++++++++++++
...st_rename_container_with_source_lease.yaml | 258 +++++++++++++++
...container_async.test_rename_container.yaml | 204 ++++++++++++
...st_rename_container_with_source_lease.yaml | 189 +++++++++++
.../tests/test_container.py | 44 ++-
.../tests/test_container_async.py | 46 +++
.../filedatalake/_data_lake_service_client.py | 52 +++
.../azure/storage/filedatalake/_models.py | 2 +
.../aio/_data_lake_service_client_async.py | 54 +++
...t_file_system.test_rename_file_system.yaml | 309 ++++++++++++++++++
..._rename_file_system_with_source_lease.yaml | 282 ++++++++++++++++
....test_restore_to_existing_file_system.yaml | 211 ++++++++++++
...file_system.test_undelete_file_system.yaml | 168 ++++++++++
..._system_async.test_rename_file_system.yaml | 225 +++++++++++++
..._rename_file_system_with_source_lease.yaml | 207 ++++++++++++
....test_restore_to_existing_file_system.yaml | 158 +++++++++
...ystem_async.test_undelete_file_system.yaml | 127 +++++++
.../tests/test_file_system.py | 127 ++++++-
.../tests/test_file_system_async.py | 150 ++++++++-
26 files changed, 3501 insertions(+), 13 deletions(-)
create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_container.test_rename_container.yaml
create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_container.test_rename_container_with_source_lease.yaml
create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_container_async.test_rename_container.yaml
create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_container_async.test_rename_container_with_source_lease.yaml
create mode 100644 sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_rename_file_system.yaml
create mode 100644 sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_rename_file_system_with_source_lease.yaml
create mode 100644 sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_restore_to_existing_file_system.yaml
create mode 100644 sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_undelete_file_system.yaml
create mode 100644 sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_rename_file_system.yaml
create mode 100644 sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_rename_file_system_with_source_lease.yaml
create mode 100644 sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_restore_to_existing_file_system.yaml
create mode 100644 sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_undelete_file_system.yaml
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 8658363f8248..c1f12f24b6ba 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
@@ -574,9 +574,43 @@ def delete_container(
timeout=timeout,
**kwargs)
+ @distributed_trace
+ def rename_container(self, source_container_name, destination_container_name, **kwargs):
+ # type: (str, str, **Any) -> ContainerClient
+ """Renames a container.
+
+ Operation is successful only if the source container exists.
+
+ .. versionadded:: 12.7.0.
+ This operation was introduced in API version '2020-04-08'.
+
+ :param str source_container_name:
+ The name of the container to rename.
+ :param str destination_container_name:
+ The new container name the user wants to rename to.
+ :keyword source_lease:
+ Specify this to perform only if the lease ID given
+ matches the active lease ID of the source container.
+ :paramtype source_lease: ~azure.storage.blob.BlobLeaseClient or str
+ :keyword int timeout:
+ The timeout parameter is expressed in seconds.
+ :rtype: ~azure.storage.blob.ContainerClient
+ """
+ renamed_container = self.get_container_client(destination_container_name)
+ source_lease = kwargs.pop('source_lease', None)
+ try:
+ kwargs['source_lease_id'] = source_lease.id # type: str
+ except AttributeError:
+ kwargs['source_lease_id'] = source_lease
+ try:
+ renamed_container._client.container.rename(source_container_name, **kwargs) # pylint: disable = protected-access
+ return renamed_container
+ except HttpResponseError as error:
+ process_storage_error(error)
+
@distributed_trace
def undelete_container(self, deleted_container_name, deleted_container_version, **kwargs):
- # type: (str, str, str, **Any) -> ContainerClient
+ # type: (str, str, **Any) -> ContainerClient
"""Restores soft-deleted container.
Operation will only be successful if used within the specified number of days
diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/_configuration.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/_configuration.py
index fb74f9ee4f8b..6c37b2421150 100644
--- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/_configuration.py
+++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/_configuration.py
@@ -38,7 +38,7 @@ def __init__(
super(AzureBlobStorageConfiguration, self).__init__(**kwargs)
self.url = url
- self.version = "2020-06-12"
+ self.version = "2020-04-08"
kwargs.setdefault('sdk_moniker', 'azureblobstorage/{}'.format(VERSION))
self._configure(**kwargs)
diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/_configuration.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/_configuration.py
index 1924efa17196..5727357d92f7 100644
--- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/_configuration.py
+++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/_configuration.py
@@ -33,7 +33,7 @@ def __init__(
super(AzureBlobStorageConfiguration, self).__init__(**kwargs)
self.url = url
- self.version = "2020-06-12"
+ self.version = "2020-04-08"
kwargs.setdefault('sdk_moniker', 'azureblobstorage/{}'.format(VERSION))
self._configure(**kwargs)
diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_container_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_container_operations.py
index ed32bc96241b..904fea36f6a3 100644
--- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_container_operations.py
+++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/aio/operations/_container_operations.py
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
import datetime
-from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union
+from typing import Any, Callable, Dict, Generic, IO, List, Optional, TypeVar, Union
import warnings
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
@@ -699,6 +699,174 @@ async def restore(
restore.metadata = {'url': '/{containerName}'} # type: ignore
+ async def rename(
+ self,
+ source_container_name: str,
+ timeout: Optional[int] = None,
+ request_id_parameter: Optional[str] = None,
+ source_lease_id: Optional[str] = None,
+ **kwargs
+ ) -> None:
+ """Renames an existing container.
+
+ :param source_container_name: Required. Specifies the name of the container to rename.
+ :type source_container_name: str
+ :param timeout: The timeout parameter is expressed in seconds. For more information, see
+ :code:`Setting Timeouts for Blob Service Operations.`.
+ :type timeout: int
+ :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character
+ limit that is recorded in the analytics logs when storage analytics logging is enabled.
+ :type request_id_parameter: str
+ :param source_lease_id: A lease ID for the source path. If specified, the source path must have
+ an active lease and the lease ID must match.
+ :type source_lease_id: str
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: None, or the result of cls(response)
+ :rtype: None
+ :raises: ~azure.core.exceptions.HttpResponseError
+ """
+ cls = kwargs.pop('cls', None) # type: ClsType[None]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+ restype = "container"
+ comp = "rename"
+ accept = "application/xml"
+
+ # Construct URL
+ url = self.rename.metadata['url'] # type: ignore
+ path_format_arguments = {
+ 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True),
+ }
+ url = self._client.format_url(url, **path_format_arguments)
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+ query_parameters['restype'] = self._serialize.query("restype", restype, 'str')
+ query_parameters['comp'] = self._serialize.query("comp", comp, 'str')
+ if timeout is not None:
+ query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0)
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str')
+ if request_id_parameter is not None:
+ header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id_parameter", request_id_parameter, 'str')
+ header_parameters['x-ms-source-container-name'] = self._serialize.header("source_container_name", source_container_name, 'str')
+ if source_lease_id is not None:
+ header_parameters['x-ms-source-lease-id'] = self._serialize.header("source_lease_id", source_lease_id, 'str')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ request = self._client.put(url, query_parameters, header_parameters)
+ pipeline_response = await self._client._pipeline.run(request, stream=False, **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(_models.StorageError, response)
+ raise HttpResponseError(response=response, model=error)
+
+ response_headers = {}
+ response_headers['x-ms-client-request-id']=self._deserialize('str', response.headers.get('x-ms-client-request-id'))
+ response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id'))
+ response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version'))
+ response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date'))
+
+ if cls:
+ return cls(pipeline_response, None, response_headers)
+
+ rename.metadata = {'url': '/{containerName}'} # type: ignore
+
+ async def submit_batch(
+ self,
+ content_length: int,
+ multipart_content_type: str,
+ body: IO,
+ timeout: Optional[int] = None,
+ request_id_parameter: Optional[str] = None,
+ **kwargs
+ ) -> IO:
+ """The Batch operation allows multiple API calls to be embedded into a single HTTP request.
+
+ :param content_length: The length of the request.
+ :type content_length: long
+ :param multipart_content_type: Required. The value of this header must be multipart/mixed with
+ a batch boundary. Example header value: multipart/mixed; boundary=batch_:code:``.
+ :type multipart_content_type: str
+ :param body: Initial data.
+ :type body: IO
+ :param timeout: The timeout parameter is expressed in seconds. For more information, see
+ :code:`Setting Timeouts for Blob Service Operations.`.
+ :type timeout: int
+ :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character
+ limit that is recorded in the analytics logs when storage analytics logging is enabled.
+ :type request_id_parameter: str
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: IO, or the result of cls(response)
+ :rtype: IO
+ :raises: ~azure.core.exceptions.HttpResponseError
+ """
+ cls = kwargs.pop('cls', None) # type: ClsType[IO]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+ restype = "container"
+ comp = "batch"
+ content_type = kwargs.pop("content_type", "application/xml")
+ accept = "application/xml"
+
+ # Construct URL
+ url = self.submit_batch.metadata['url'] # type: ignore
+ path_format_arguments = {
+ 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True),
+ }
+ url = self._client.format_url(url, **path_format_arguments)
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+ query_parameters['restype'] = self._serialize.query("restype", restype, 'str')
+ query_parameters['comp'] = self._serialize.query("comp", comp, 'str')
+ if timeout is not None:
+ query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0)
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Content-Length'] = self._serialize.header("content_length", content_length, 'long')
+ header_parameters['Content-Type'] = self._serialize.header("multipart_content_type", multipart_content_type, 'str')
+ header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str')
+ if request_id_parameter is not None:
+ header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id_parameter", request_id_parameter, 'str')
+ header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ body_content_kwargs = {} # type: Dict[str, Any]
+ body_content = self._serialize.body(body, 'IO', is_xml=True)
+ body_content_kwargs['content'] = body_content
+ request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs)
+ pipeline_response = await self._client._pipeline.run(request, stream=True, **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(_models.StorageError, response)
+ raise HttpResponseError(response=response, model=error)
+
+ response_headers = {}
+ response_headers['Content-Type']=self._deserialize('str', response.headers.get('Content-Type'))
+ response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id'))
+ response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version'))
+ deserialized = response.stream_download(self._client._pipeline)
+
+ if cls:
+ return cls(pipeline_response, deserialized, response_headers)
+
+ return deserialized
+ submit_batch.metadata = {'url': '/{containerName}'} # type: ignore
+
async def acquire_lease(
self,
timeout: Optional[int] = None,
diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_container_operations.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_container_operations.py
index 41a1c8aa2daf..32197532ef36 100644
--- a/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_container_operations.py
+++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/operations/_container_operations.py
@@ -17,7 +17,7 @@
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
- from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union
+ from typing import Any, Callable, Dict, Generic, IO, List, Optional, TypeVar, Union
T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
@@ -710,6 +710,176 @@ def restore(
restore.metadata = {'url': '/{containerName}'} # type: ignore
+ def rename(
+ self,
+ source_container_name, # type: str
+ timeout=None, # type: Optional[int]
+ request_id_parameter=None, # type: Optional[str]
+ source_lease_id=None, # type: Optional[str]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ """Renames an existing container.
+
+ :param source_container_name: Required. Specifies the name of the container to rename.
+ :type source_container_name: str
+ :param timeout: The timeout parameter is expressed in seconds. For more information, see
+ :code:`Setting Timeouts for Blob Service Operations.`.
+ :type timeout: int
+ :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character
+ limit that is recorded in the analytics logs when storage analytics logging is enabled.
+ :type request_id_parameter: str
+ :param source_lease_id: A lease ID for the source path. If specified, the source path must have
+ an active lease and the lease ID must match.
+ :type source_lease_id: str
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: None, or the result of cls(response)
+ :rtype: None
+ :raises: ~azure.core.exceptions.HttpResponseError
+ """
+ cls = kwargs.pop('cls', None) # type: ClsType[None]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+ restype = "container"
+ comp = "rename"
+ accept = "application/xml"
+
+ # Construct URL
+ url = self.rename.metadata['url'] # type: ignore
+ path_format_arguments = {
+ 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True),
+ }
+ url = self._client.format_url(url, **path_format_arguments)
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+ query_parameters['restype'] = self._serialize.query("restype", restype, 'str')
+ query_parameters['comp'] = self._serialize.query("comp", comp, 'str')
+ if timeout is not None:
+ query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0)
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str')
+ if request_id_parameter is not None:
+ header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id_parameter", request_id_parameter, 'str')
+ header_parameters['x-ms-source-container-name'] = self._serialize.header("source_container_name", source_container_name, 'str')
+ if source_lease_id is not None:
+ header_parameters['x-ms-source-lease-id'] = self._serialize.header("source_lease_id", source_lease_id, 'str')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ request = self._client.put(url, query_parameters, header_parameters)
+ pipeline_response = self._client._pipeline.run(request, stream=False, **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(_models.StorageError, response)
+ raise HttpResponseError(response=response, model=error)
+
+ response_headers = {}
+ response_headers['x-ms-client-request-id']=self._deserialize('str', response.headers.get('x-ms-client-request-id'))
+ response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id'))
+ response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version'))
+ response_headers['Date']=self._deserialize('rfc-1123', response.headers.get('Date'))
+
+ if cls:
+ return cls(pipeline_response, None, response_headers)
+
+ rename.metadata = {'url': '/{containerName}'} # type: ignore
+
+ def submit_batch(
+ self,
+ content_length, # type: int
+ multipart_content_type, # type: str
+ body, # type: IO
+ timeout=None, # type: Optional[int]
+ request_id_parameter=None, # type: Optional[str]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> IO
+ """The Batch operation allows multiple API calls to be embedded into a single HTTP request.
+
+ :param content_length: The length of the request.
+ :type content_length: long
+ :param multipart_content_type: Required. The value of this header must be multipart/mixed with
+ a batch boundary. Example header value: multipart/mixed; boundary=batch_:code:``.
+ :type multipart_content_type: str
+ :param body: Initial data.
+ :type body: IO
+ :param timeout: The timeout parameter is expressed in seconds. For more information, see
+ :code:`Setting Timeouts for Blob Service Operations.`.
+ :type timeout: int
+ :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character
+ limit that is recorded in the analytics logs when storage analytics logging is enabled.
+ :type request_id_parameter: str
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: IO, or the result of cls(response)
+ :rtype: IO
+ :raises: ~azure.core.exceptions.HttpResponseError
+ """
+ cls = kwargs.pop('cls', None) # type: ClsType[IO]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+ restype = "container"
+ comp = "batch"
+ content_type = kwargs.pop("content_type", "application/xml")
+ accept = "application/xml"
+
+ # Construct URL
+ url = self.submit_batch.metadata['url'] # type: ignore
+ path_format_arguments = {
+ 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True),
+ }
+ url = self._client.format_url(url, **path_format_arguments)
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+ query_parameters['restype'] = self._serialize.query("restype", restype, 'str')
+ query_parameters['comp'] = self._serialize.query("comp", comp, 'str')
+ if timeout is not None:
+ query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0)
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Content-Length'] = self._serialize.header("content_length", content_length, 'long')
+ header_parameters['Content-Type'] = self._serialize.header("multipart_content_type", multipart_content_type, 'str')
+ header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str')
+ if request_id_parameter is not None:
+ header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id_parameter", request_id_parameter, 'str')
+ header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ body_content_kwargs = {} # type: Dict[str, Any]
+ body_content = self._serialize.body(body, 'IO', is_xml=True)
+ body_content_kwargs['content'] = body_content
+ request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs)
+ pipeline_response = self._client._pipeline.run(request, stream=True, **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(_models.StorageError, response)
+ raise HttpResponseError(response=response, model=error)
+
+ response_headers = {}
+ response_headers['Content-Type']=self._deserialize('str', response.headers.get('Content-Type'))
+ response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id'))
+ response_headers['x-ms-version']=self._deserialize('str', response.headers.get('x-ms-version'))
+ deserialized = response.stream_download(self._client._pipeline)
+
+ if cls:
+ return cls(pipeline_response, deserialized, response_headers)
+
+ return deserialized
+ submit_batch.metadata = {'url': '/{containerName}'} # type: ignore
+
def acquire_lease(
self,
timeout=None, # type: Optional[int]
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 4e91743c38be..aeec5af748fa 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
@@ -522,9 +522,43 @@ async def delete_container(
timeout=timeout,
**kwargs)
+ @distributed_trace_async
+ async def rename_container(self, source_container_name, destination_container_name, **kwargs):
+ # type: (str, str, **Any) -> ContainerClient
+ """Renames a container.
+
+ Operation is successful only if the source container exists.
+
+ .. versionadded:: 12.7.0.
+ This operation was introduced in API version '2020-04-08'.
+
+ :param str source_container_name:
+ The name of the container to rename.
+ :param str destination_container_name:
+ The new container name the user wants to rename to.
+ :keyword source_lease:
+ Specify this to perform only if the lease ID given
+ matches the active lease ID of the source container.
+ :paramtype source_lease: ~azure.storage.blob.BlobLeaseClient or str
+ :keyword int timeout:
+ The timeout parameter is expressed in seconds.
+ :rtype: ~azure.storage.blob.ContainerClient
+ """
+ renamed_container = self.get_container_client(destination_container_name)
+ source_lease = kwargs.pop('source_lease', None)
+ try:
+ kwargs['source_lease_id'] = source_lease.id # type: str
+ except AttributeError:
+ kwargs['source_lease_id'] = source_lease
+ try:
+ await renamed_container._client.container.rename(source_container_name, **kwargs) # pylint: disable = protected-access
+ return renamed_container
+ except HttpResponseError as error:
+ process_storage_error(error)
+
@distributed_trace_async
async def undelete_container(self, deleted_container_name, deleted_container_version, **kwargs):
- # type: (str, str, str, **Any) -> ContainerClient
+ # type: (str, str, **Any) -> ContainerClient
"""Restores soft-deleted container.
Operation will only be successful if used within the specified number of days
diff --git a/sdk/storage/azure-storage-blob/swagger/README.md b/sdk/storage/azure-storage-blob/swagger/README.md
index e14276425d34..e54914c0e21d 100644
--- a/sdk/storage/azure-storage-blob/swagger/README.md
+++ b/sdk/storage/azure-storage-blob/swagger/README.md
@@ -16,7 +16,7 @@ autorest --v3 --python
### Settings
``` yaml
-input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/storage-dataplane-preview/specification/storage/data-plane/Microsoft.BlobStorage/preview/2020-06-12/blob.json
+input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/storage-dataplane-preview/specification/storage/data-plane/Microsoft.BlobStorage/preview/2020-04-08/blob.json
output-folder: ../azure/storage/blob/_generated
namespace: azure.storage.blob
no-namespace-folders: true
diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_container.test_rename_container.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_container.test_rename_container.yaml
new file mode 100644
index 000000000000..2e5e17ec5459
--- /dev/null
+++ b/sdk/storage/azure-storage-blob/tests/recordings/test_container.test_rename_container.yaml
@@ -0,0 +1,281 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:17:38 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/oldcontainer112270eca?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ date:
+ - Tue, 12 Jan 2021 05:17:38 GMT
+ etag:
+ - '"0x8D8B6B961509D23"'
+ last-modified:
+ - Tue, 12 Jan 2021 05:17:39 GMT
+ server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ transfer-encoding:
+ - chunked
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 201
+ message: Created
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:17:39 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/oldcontainer212270eca?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ date:
+ - Tue, 12 Jan 2021 05:17:38 GMT
+ etag:
+ - '"0x8D8B6B961684822"'
+ last-modified:
+ - Tue, 12 Jan 2021 05:17:39 GMT
+ server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ transfer-encoding:
+ - chunked
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 201
+ message: Created
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:17:39 GMT
+ x-ms-source-container-name:
+ - oldcontainer112270eca
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/newcontainer12270eca?restype=container&comp=rename
+ response:
+ body:
+ string: ''
+ headers:
+ content-length:
+ - '0'
+ date:
+ - Tue, 12 Jan 2021 05:17:38 GMT
+ server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 200
+ message: OK
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:17:39 GMT
+ x-ms-source-container-name:
+ - oldcontainer212270eca
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/newcontainer12270eca?restype=container&comp=rename
+ response:
+ body:
+ string: "\uFEFF\nContainerAlreadyExists
The
+ specified container already exists.\nRequestId:500753c8-001e-000c-54a2-e80fb8000000\nTime:2021-01-12T05:17:39.4786055Z"
+ headers:
+ content-length:
+ - '231'
+ content-type:
+ - application/xml
+ date:
+ - Tue, 12 Jan 2021 05:17:38 GMT
+ server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code:
+ - ContainerAlreadyExists
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 409
+ message: The specified container already exists.
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:17:39 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/oldcontainer112270eca?restype=container
+ response:
+ body:
+ string: "\uFEFFContainerNotFound
The
+ specified container does not exist.\nRequestId:500753c9-001e-000c-55a2-e80fb8000000\nTime:2021-01-12T05:17:39.5886831Z"
+ headers:
+ content-length:
+ - '225'
+ content-type:
+ - application/xml
+ date:
+ - Tue, 12 Jan 2021 05:17:38 GMT
+ server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code:
+ - ContainerNotFound
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 404
+ message: The specified container does not exist.
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:17:39 GMT
+ x-ms-source-container-name:
+ - badcontainer
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/container?restype=container&comp=rename
+ response:
+ body:
+ string: "\uFEFF\nContainerAlreadyExists
The
+ specified container already exists.\nRequestId:500753ca-001e-000c-56a2-e80fb8000000\nTime:2021-01-12T05:17:39.6937570Z"
+ headers:
+ content-length:
+ - '231'
+ content-type:
+ - application/xml
+ date:
+ - Tue, 12 Jan 2021 05:17:38 GMT
+ server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code:
+ - ContainerAlreadyExists
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 409
+ message: The specified container already exists.
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:17:39 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/newcontainer12270eca?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ date:
+ - Tue, 12 Jan 2021 05:17:38 GMT
+ etag:
+ - '"0x8D8B6B9617C5196"'
+ last-modified:
+ - Tue, 12 Jan 2021 05:17:39 GMT
+ server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ transfer-encoding:
+ - chunked
+ x-ms-default-encryption-scope:
+ - $account-encryption-key
+ x-ms-deny-encryption-scope-override:
+ - 'false'
+ x-ms-has-immutability-policy:
+ - 'false'
+ x-ms-has-legal-hold:
+ - 'false'
+ x-ms-lease-state:
+ - available
+ x-ms-lease-status:
+ - unlocked
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 200
+ message: OK
+version: 1
diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_container.test_rename_container_with_source_lease.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_container.test_rename_container_with_source_lease.yaml
new file mode 100644
index 000000000000..59708e4a160c
--- /dev/null
+++ b/sdk/storage/azure-storage-blob/tests/recordings/test_container.test_rename_container_with_source_lease.yaml
@@ -0,0 +1,258 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:17:49 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/old63ce163e?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ date:
+ - Tue, 12 Jan 2021 05:17:48 GMT
+ etag:
+ - '"0x8D8B6B9677DC03D"'
+ last-modified:
+ - Tue, 12 Jan 2021 05:17:49 GMT
+ server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ transfer-encoding:
+ - chunked
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 201
+ message: Created
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:17:49 GMT
+ x-ms-lease-action:
+ - acquire
+ x-ms-lease-duration:
+ - '-1'
+ x-ms-proposed-lease-id:
+ - 41dd6248-aa56-4555-a9d5-a322e127c44a
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/old63ce163e?comp=lease&restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ date:
+ - Tue, 12 Jan 2021 05:17:48 GMT
+ etag:
+ - '"0x8D8B6B9677DC03D"'
+ last-modified:
+ - Tue, 12 Jan 2021 05:17:49 GMT
+ server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ transfer-encoding:
+ - chunked
+ x-ms-lease-id:
+ - 41dd6248-aa56-4555-a9d5-a322e127c44a
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 201
+ message: Created
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:17:49 GMT
+ x-ms-source-container-name:
+ - old63ce163e
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/new63ce163e?restype=container&comp=rename
+ response:
+ body:
+ string: "\uFEFF\nLeaseIdMissing
There
+ is currently a lease on the container and no lease ID was specified in the
+ request.\nRequestId:dc7f58ee-f01e-0012-76a2-e8d555000000\nTime:2021-01-12T05:17:49.7396734Z"
+ headers:
+ content-length:
+ - '273'
+ content-type:
+ - application/xml
+ date:
+ - Tue, 12 Jan 2021 05:17:48 GMT
+ server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code:
+ - LeaseIdMissing
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 412
+ message: There is currently a lease on the container and no lease ID was specified
+ in the request.
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:17:49 GMT
+ x-ms-source-container-name:
+ - old63ce163e
+ x-ms-source-lease-id:
+ - bad_id
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/new63ce163e?restype=container&comp=rename
+ response:
+ body:
+ string: "\uFEFF\nInvalidHeaderValue
The
+ value for one of the HTTP headers is not in the correct format.\nRequestId:dc7f58ef-f01e-0012-77a2-e8d555000000\nTime:2021-01-12T05:17:49.8457482Zx-ms-source-lease-idbad_id"
+ headers:
+ content-length:
+ - '333'
+ content-type:
+ - application/xml
+ date:
+ - Tue, 12 Jan 2021 05:17:48 GMT
+ server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code:
+ - InvalidHeaderValue
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 400
+ message: The value for one of the HTTP headers is not in the correct format.
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:17:49 GMT
+ x-ms-source-container-name:
+ - old63ce163e
+ x-ms-source-lease-id:
+ - 41dd6248-aa56-4555-a9d5-a322e127c44a
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/new63ce163e?restype=container&comp=rename
+ response:
+ body:
+ string: ''
+ headers:
+ content-length:
+ - '0'
+ date:
+ - Tue, 12 Jan 2021 05:17:49 GMT
+ server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 200
+ message: OK
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:17:49 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/new63ce163e?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ date:
+ - Tue, 12 Jan 2021 05:17:49 GMT
+ etag:
+ - '"0x8D8B6B967CCB6DB"'
+ last-modified:
+ - Tue, 12 Jan 2021 05:17:49 GMT
+ server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ transfer-encoding:
+ - chunked
+ x-ms-default-encryption-scope:
+ - $account-encryption-key
+ x-ms-deny-encryption-scope-override:
+ - 'false'
+ x-ms-has-immutability-policy:
+ - 'false'
+ x-ms-has-legal-hold:
+ - 'false'
+ x-ms-lease-state:
+ - available
+ x-ms-lease-status:
+ - unlocked
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 200
+ message: OK
+version: 1
diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_container_async.test_rename_container.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_container_async.test_rename_container.yaml
new file mode 100644
index 000000000000..011ba4353a97
--- /dev/null
+++ b/sdk/storage/azure-storage-blob/tests/recordings/test_container_async.test_rename_container.yaml
@@ -0,0 +1,204 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:20:56 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/oldcontainer174cc1147?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ date: Tue, 12 Jan 2021 05:20:56 GMT
+ etag: '"0x8D8B6B9D734FD1F"'
+ last-modified: Tue, 12 Jan 2021 05:20:56 GMT
+ server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ transfer-encoding: chunked
+ x-ms-version: '2020-04-08'
+ status:
+ code: 201
+ message: Created
+ url: https://storagename.blob.core.windows.net/oldcontainer174cc1147?restype=container
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:20:56 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/oldcontainer274cc1147?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ date: Tue, 12 Jan 2021 05:20:56 GMT
+ etag: '"0x8D8B6B9D7457AD3"'
+ last-modified: Tue, 12 Jan 2021 05:20:56 GMT
+ server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ transfer-encoding: chunked
+ x-ms-version: '2020-04-08'
+ status:
+ code: 201
+ message: Created
+ url: https://storagename.blob.core.windows.net/oldcontainer274cc1147?restype=container
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:20:57 GMT
+ x-ms-source-container-name:
+ - oldcontainer174cc1147
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/newcontainer74cc1147?restype=container&comp=rename
+ response:
+ body:
+ string: ''
+ headers:
+ content-length: '0'
+ date: Tue, 12 Jan 2021 05:20:56 GMT
+ server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-version: '2020-04-08'
+ status:
+ code: 200
+ message: OK
+ url: https://storagename.blob.core.windows.net/newcontainer74cc1147?restype=container&comp=rename
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:20:57 GMT
+ x-ms-source-container-name:
+ - oldcontainer274cc1147
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/newcontainer74cc1147?restype=container&comp=rename
+ response:
+ body:
+ string: "\uFEFF\nContainerAlreadyExists
The
+ specified container already exists.\nRequestId:f442c638-901e-0002-79a2-e8e3b3000000\nTime:2021-01-12T05:20:57.1456215Z"
+ headers:
+ content-length: '231'
+ content-type: application/xml
+ date: Tue, 12 Jan 2021 05:20:56 GMT
+ server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code: ContainerAlreadyExists
+ x-ms-version: '2020-04-08'
+ status:
+ code: 409
+ message: The specified container already exists.
+ url: https://storagename.blob.core.windows.net/newcontainer74cc1147?restype=container&comp=rename
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:20:57 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/oldcontainer174cc1147?restype=container
+ response:
+ body:
+ string: "\uFEFFContainerNotFound
The
+ specified container does not exist.\nRequestId:f442c639-901e-0002-7aa2-e8e3b3000000\nTime:2021-01-12T05:20:57.2086649Z"
+ headers:
+ content-length: '225'
+ content-type: application/xml
+ date: Tue, 12 Jan 2021 05:20:57 GMT
+ server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code: ContainerNotFound
+ x-ms-version: '2020-04-08'
+ status:
+ code: 404
+ message: The specified container does not exist.
+ url: https://storagename.blob.core.windows.net/oldcontainer174cc1147?restype=container
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:20:57 GMT
+ x-ms-source-container-name:
+ - badcontainer
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/container?restype=container&comp=rename
+ response:
+ body:
+ string: "\uFEFF\nContainerAlreadyExists
The
+ specified container already exists.\nRequestId:f442c63a-901e-0002-7ba2-e8e3b3000000\nTime:2021-01-12T05:20:57.2707083Z"
+ headers:
+ content-length: '231'
+ content-type: application/xml
+ date: Tue, 12 Jan 2021 05:20:57 GMT
+ server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code: ContainerAlreadyExists
+ x-ms-version: '2020-04-08'
+ status:
+ code: 409
+ message: The specified container already exists.
+ url: https://storagename.blob.core.windows.net/container?restype=container&comp=rename
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:20:57 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/newcontainer74cc1147?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ date: Tue, 12 Jan 2021 05:20:57 GMT
+ etag: '"0x8D8B6B9D7547066"'
+ last-modified: Tue, 12 Jan 2021 05:20:57 GMT
+ server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ transfer-encoding: chunked
+ x-ms-default-encryption-scope: $account-encryption-key
+ x-ms-deny-encryption-scope-override: 'false'
+ x-ms-has-immutability-policy: 'false'
+ x-ms-has-legal-hold: 'false'
+ x-ms-lease-state: available
+ x-ms-lease-status: unlocked
+ x-ms-version: '2020-04-08'
+ status:
+ code: 200
+ message: OK
+ url: https://storagename.blob.core.windows.net/newcontainer74cc1147?restype=container
+version: 1
diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_container_async.test_rename_container_with_source_lease.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_container_async.test_rename_container_with_source_lease.yaml
new file mode 100644
index 000000000000..525fa48f5fe9
--- /dev/null
+++ b/sdk/storage/azure-storage-blob/tests/recordings/test_container_async.test_rename_container_with_source_lease.yaml
@@ -0,0 +1,189 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:21:07 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/oldf33d18bb?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ date: Tue, 12 Jan 2021 05:21:07 GMT
+ etag: '"0x8D8B6B9DDF50B42"'
+ last-modified: Tue, 12 Jan 2021 05:21:08 GMT
+ server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ transfer-encoding: chunked
+ x-ms-version: '2020-04-08'
+ status:
+ code: 201
+ message: Created
+ url: https://storagename.blob.core.windows.net/oldf33d18bb?restype=container
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:21:08 GMT
+ x-ms-lease-action:
+ - acquire
+ x-ms-lease-duration:
+ - '-1'
+ x-ms-proposed-lease-id:
+ - 1c9d54a6-d687-4797-9ae6-5f47d2006af7
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/oldf33d18bb?comp=lease&restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ date: Tue, 12 Jan 2021 05:21:07 GMT
+ etag: '"0x8D8B6B9DDF50B42"'
+ last-modified: Tue, 12 Jan 2021 05:21:08 GMT
+ server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ transfer-encoding: chunked
+ x-ms-lease-id: 1c9d54a6-d687-4797-9ae6-5f47d2006af7
+ x-ms-version: '2020-04-08'
+ status:
+ code: 201
+ message: Created
+ url: https://storagename.blob.core.windows.net/oldf33d18bb?comp=lease&restype=container
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:21:08 GMT
+ x-ms-source-container-name:
+ - oldf33d18bb
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/newf33d18bb?restype=container&comp=rename
+ response:
+ body:
+ string: "\uFEFF\nLeaseIdMissing
There
+ is currently a lease on the container and no lease ID was specified in the
+ request.\nRequestId:e45ec78c-c01e-0011-69a2-e8d652000000\nTime:2021-01-12T05:21:08.3875482Z"
+ headers:
+ content-length: '273'
+ content-type: application/xml
+ date: Tue, 12 Jan 2021 05:21:07 GMT
+ server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code: LeaseIdMissing
+ x-ms-version: '2020-04-08'
+ status:
+ code: 412
+ message: There is currently a lease on the container and no lease ID was specified
+ in the request.
+ url: https://storagename.blob.core.windows.net/newf33d18bb?restype=container&comp=rename
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:21:08 GMT
+ x-ms-source-container-name:
+ - oldf33d18bb
+ x-ms-source-lease-id:
+ - bad_id
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/newf33d18bb?restype=container&comp=rename
+ response:
+ body:
+ string: "\uFEFF\nInvalidHeaderValue
The
+ value for one of the HTTP headers is not in the correct format.\nRequestId:e45ec78d-c01e-0011-6aa2-e8d652000000\nTime:2021-01-12T05:21:08.4475910Zx-ms-source-lease-idbad_id"
+ headers:
+ content-length: '333'
+ content-type: application/xml
+ date: Tue, 12 Jan 2021 05:21:07 GMT
+ server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code: InvalidHeaderValue
+ x-ms-version: '2020-04-08'
+ status:
+ code: 400
+ message: The value for one of the HTTP headers is not in the correct format.
+ url: https://storagename.blob.core.windows.net/newf33d18bb?restype=container&comp=rename
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:21:08 GMT
+ x-ms-source-container-name:
+ - oldf33d18bb
+ x-ms-source-lease-id:
+ - 1c9d54a6-d687-4797-9ae6-5f47d2006af7
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/newf33d18bb?restype=container&comp=rename
+ response:
+ body:
+ string: ''
+ headers:
+ content-length: '0'
+ date: Tue, 12 Jan 2021 05:21:07 GMT
+ server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-version: '2020-04-08'
+ status:
+ code: 200
+ message: OK
+ url: https://storagename.blob.core.windows.net/newf33d18bb?restype=container&comp=rename
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-date:
+ - Tue, 12 Jan 2021 05:21:08 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/newf33d18bb?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ date: Tue, 12 Jan 2021 05:21:07 GMT
+ etag: '"0x8D8B6B9DE253F94"'
+ last-modified: Tue, 12 Jan 2021 05:21:08 GMT
+ server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ transfer-encoding: chunked
+ x-ms-default-encryption-scope: $account-encryption-key
+ x-ms-deny-encryption-scope-override: 'false'
+ x-ms-has-immutability-policy: 'false'
+ x-ms-has-legal-hold: 'false'
+ x-ms-lease-state: available
+ x-ms-lease-status: unlocked
+ x-ms-version: '2020-04-08'
+ status:
+ code: 200
+ message: OK
+ url: https://storagename.blob.core.windows.net/newf33d18bb?restype=container
+version: 1
diff --git a/sdk/storage/azure-storage-blob/tests/test_container.py b/sdk/storage/azure-storage-blob/tests/test_container.py
index ff2c33347c96..7440675d65ab 100644
--- a/sdk/storage/azure-storage-blob/tests/test_container.py
+++ b/sdk/storage/azure-storage-blob/tests/test_container.py
@@ -135,6 +135,48 @@ def test_container_exists_with_lease(self, resource_group, location, storage_acc
# Assert
self.assertTrue(exists)
+ @GlobalStorageAccountPreparer()
+ def test_rename_container(self, resource_group, location, storage_account, storage_account_key):
+ bsc = BlobServiceClient(self.account_url(storage_account, "blob"), storage_account_key)
+ old_name1 = self._get_container_reference(prefix="oldcontainer1")
+ old_name2 = self._get_container_reference(prefix="oldcontainer2")
+ new_name = self._get_container_reference(prefix="newcontainer")
+ container1 = bsc.get_container_client(old_name1)
+ container2 = bsc.get_container_client(old_name2)
+
+ container1.create_container()
+ container2.create_container()
+
+ new_container = bsc.rename_container(
+ source_container_name=old_name1, destination_container_name=new_name)
+ with self.assertRaises(HttpResponseError):
+ bsc.rename_container(
+ source_container_name=old_name2, destination_container_name=new_name)
+ with self.assertRaises(HttpResponseError):
+ container1.get_container_properties()
+ with self.assertRaises(HttpResponseError):
+ bsc.rename_container(
+ source_container_name="badcontainer", destination_container_name="container")
+ self.assertEqual(new_name, new_container.get_container_properties().name)
+
+ @GlobalStorageAccountPreparer()
+ def test_rename_container_with_source_lease(self, resource_group, location, storage_account, storage_account_key):
+ bsc = BlobServiceClient(self.account_url(storage_account, "blob"), storage_account_key)
+ old_name = self._get_container_reference(prefix="old")
+ new_name = self._get_container_reference(prefix="new")
+ container = bsc.get_container_client(old_name)
+ container.create_container()
+ container_lease_id = container.acquire_lease()
+ with self.assertRaises(HttpResponseError):
+ bsc.rename_container(
+ source_container_name=old_name, destination_container_name=new_name)
+ with self.assertRaises(HttpResponseError):
+ bsc.rename_container(
+ source_container_name=old_name, destination_container_name=new_name, source_lease="bad_id")
+ new_container = bsc.rename_container(
+ source_container_name=old_name, destination_container_name=new_name, source_lease=container_lease_id)
+ self.assertEqual(new_name, new_container.get_container_properties().name)
+
@GlobalStorageAccountPreparer()
def test_unicode_create_container_unicode_name(self, resource_group, location, storage_account, storage_account_key):
bsc = BlobServiceClient(self.account_url(storage_account, "blob"), storage_account_key)
@@ -146,8 +188,6 @@ def test_unicode_create_container_unicode_name(self, resource_group, location, s
# not supported - container name must be alphanumeric, lowercase
container.create_container()
- # Assert
-
@GlobalStorageAccountPreparer()
def test_list_containers(self, resource_group, location, storage_account, storage_account_key):
bsc = BlobServiceClient(self.account_url(storage_account, "blob"), storage_account_key)
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 9c280615e91f..fa08eceff224 100644
--- a/sdk/storage/azure-storage-blob/tests/test_container_async.py
+++ b/sdk/storage/azure-storage-blob/tests/test_container_async.py
@@ -174,6 +174,52 @@ async def test_container_exists_with_lease(self, resource_group, location, stora
# Assert
self.assertTrue(exists)
+ @GlobalStorageAccountPreparer()
+ @AsyncStorageTestCase.await_prepared_test
+ async def test_rename_container(self, resource_group, location, storage_account, storage_account_key):
+ bsc = BlobServiceClient(self.account_url(storage_account, "blob"), storage_account_key)
+ old_name1 = self._get_container_reference(prefix="oldcontainer1")
+ old_name2 = self._get_container_reference(prefix="oldcontainer2")
+ new_name = self._get_container_reference(prefix="newcontainer")
+ container1 = bsc.get_container_client(old_name1)
+ container2 = bsc.get_container_client(old_name2)
+
+ await container1.create_container()
+ await container2.create_container()
+
+ new_container = await bsc.rename_container(
+ source_container_name=old_name1, destination_container_name=new_name)
+ with self.assertRaises(HttpResponseError):
+ await bsc.rename_container(
+ source_container_name=old_name2, destination_container_name=new_name)
+ with self.assertRaises(HttpResponseError):
+ await container1.get_container_properties()
+ with self.assertRaises(HttpResponseError):
+ await bsc.rename_container(
+ source_container_name="badcontainer", destination_container_name="container")
+ props = await new_container.get_container_properties()
+ self.assertEqual(new_name, props.name)
+
+ @GlobalStorageAccountPreparer()
+ @AsyncStorageTestCase.await_prepared_test
+ async def test_rename_container_with_source_lease(self, resource_group, location, storage_account, storage_account_key):
+ bsc = BlobServiceClient(self.account_url(storage_account, "blob"), storage_account_key)
+ old_name = self._get_container_reference(prefix="old")
+ new_name = self._get_container_reference(prefix="new")
+ container = bsc.get_container_client(old_name)
+ await container.create_container()
+ container_lease_id = await container.acquire_lease()
+ with self.assertRaises(HttpResponseError):
+ await bsc.rename_container(
+ source_container_name=old_name, destination_container_name=new_name)
+ with self.assertRaises(HttpResponseError):
+ await bsc.rename_container(
+ source_container_name=old_name, destination_container_name=new_name, source_lease="bad_id")
+ new_container = await bsc.rename_container(
+ source_container_name=old_name, destination_container_name=new_name, source_lease=container_lease_id)
+ props = await new_container.get_container_properties()
+ self.assertEqual(new_name, props.name)
+
@GlobalStorageAccountPreparer()
@AsyncStorageTestCase.await_prepared_test
async def test_unicode_create_container_unicode_name(self, resource_group, location, storage_account, storage_account_key):
diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_service_client.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_service_client.py
index c97ae67c8763..33d9cdc7edd5 100644
--- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_service_client.py
+++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_service_client.py
@@ -3,6 +3,7 @@
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
+from typing import Any
try:
from urllib.parse import urlparse
@@ -250,6 +251,57 @@ def create_file_system(self, file_system, # type: Union[FileSystemProperties, s
file_system_client.create_file_system(metadata=metadata, public_access=public_access, **kwargs)
return file_system_client
+ def rename_file_system(self, source_file_system_name, destination_file_system_name, **kwargs):
+ # type: (str, str, **Any) -> FileSystemClient
+ """Renames a filesystem.
+
+ Operation is successful only if the source filesystem exists.
+
+ .. versionadded:: 12.3.0.
+ This operation was introduced in API version '2020-04-08'.
+
+ :param str source_file_system_name:
+ The name of the filesystem to rename.
+ :param str destination_file_system_name:
+ The new filesystem name the user wants to rename to.
+ :keyword source_lease:
+ Specify this to perform only if the lease ID given
+ matches the active lease ID of the source filesystem.
+ :paramtype source_lease: ~azure.storage.filedatalake.DataLakeLeaseClient or str
+ :keyword int timeout:
+ The timeout parameter is expressed in seconds.
+ :rtype: ~azure.storage.filedatalake.FileSystemClient
+ """
+ self._blob_service_client.rename_container(source_file_system_name, destination_file_system_name, **kwargs) # pylint: disable=protected-access
+ renamed_file_system = self.get_file_system_client(destination_file_system_name)
+ return renamed_file_system
+
+ def undelete_file_system(self, deleted_file_system_name, deleted_file_system_version, **kwargs):
+ # type: (str, str, **Any) -> FileSystemClient
+ """Restores soft-deleted filesystem.
+
+ Operation will only be successful if used within the specified number of days
+ set in the delete retention policy.
+
+ .. versionadded:: 12.3.0
+ This operation was introduced in API version '2019-12-12'.
+
+ :param str deleted_file_system_name:
+ Specifies the name of the deleted filesystem to restore.
+ :param str deleted_file_system_version:
+ Specifies the version of the deleted filesystem to restore.
+ :keyword str new_name:
+ The new name for the deleted filesystem to be restored to.
+ If not specified deleted_file_system_name will be used as the restored filesystem name.
+ :keyword int timeout:
+ The timeout parameter is expressed in seconds.
+ :rtype: ~azure.storage.filedatalake.FileSystemClient
+ """
+ new_name = kwargs.pop('new_name', None)
+ self._blob_service_client.undelete_container(deleted_file_system_name, deleted_file_system_version, **kwargs) # pylint: disable=protected-access
+ file_system = self.get_file_system_client(new_name or deleted_file_system_name)
+ return file_system
+
def delete_file_system(self, file_system, # type: Union[FileSystemProperties, str]
**kwargs):
# type: (...) -> FileSystemClient
diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_models.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_models.py
index 8964ced388d9..fe59b3f31684 100644
--- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_models.py
+++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_models.py
@@ -54,12 +54,14 @@ def __init__(self):
self.has_immutability_policy = None
self.has_legal_hold = None
self.metadata = None
+ self.deleted = None
@classmethod
def _from_generated(cls, generated):
props = cls()
props.name = generated.name
props.last_modified = generated.properties.last_modified
+ props.deleted = generated.deleted
props.etag = generated.properties.etag
props.lease = LeaseProperties._from_generated(generated) # pylint: disable=protected-access
props.public_access = PublicAccess._from_generated( # pylint: disable=protected-access
diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_service_client_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_service_client_async.py
index facaba2f9bc7..4bfe52058262 100644
--- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_service_client_async.py
+++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_service_client_async.py
@@ -4,6 +4,7 @@
# license information.
# --------------------------------------------------------------------------
# pylint: disable=invalid-overridden-method
+from typing import Any
from azure.core.paging import ItemPaged
from azure.core.pipeline import AsyncPipeline
@@ -200,6 +201,59 @@ async def create_file_system(self, file_system, # type: Union[FileSystemPropert
await file_system_client.create_file_system(metadata=metadata, public_access=public_access, **kwargs)
return file_system_client
+ async def rename_file_system(self, source_file_system_name, destination_file_system_name, **kwargs):
+ # type: (str, str, **Any) -> FileSystemClient
+ """Renames a filesystem.
+
+ Operation is successful only if the source filesystem exists.
+
+ .. versionadded:: 12.3.0.
+ This operation was introduced in API version '2020-04-08'.
+
+ :param str source_file_system_name:
+ The name of the filesystem to rename.
+ :param str destination_file_system_name:
+ The new filesystem name the user wants to rename to.
+ :keyword source_lease:
+ Specify this to perform only if the lease ID given
+ matches the active lease ID of the source filesystem.
+ :paramtype source_lease: ~azure.storage.filedatalake.DataLakeLeaseClient or str
+ :keyword int timeout:
+ The timeout parameter is expressed in seconds.
+ :rtype: ~azure.storage.filedatalake.FileSystemClient
+ """
+ await self._blob_service_client.rename_container(
+ source_file_system_name, destination_file_system_name, **kwargs) # pylint: disable=protected-access
+ renamed_file_system = self.get_file_system_client(destination_file_system_name)
+ return renamed_file_system
+
+ async def undelete_file_system(self, deleted_file_system_name, deleted_file_system_version, **kwargs):
+ # type: (str, str, **Any) -> FileSystemClient
+ """Restores soft-deleted filesystem.
+
+ Operation will only be successful if used within the specified number of days
+ set in the delete retention policy.
+
+ .. versionadded:: 12.3.0
+ This operation was introduced in API version '2019-12-12'.
+
+ :param str deleted_file_system_name:
+ Specifies the name of the deleted filesystem to restore.
+ :param str deleted_file_system_version:
+ Specifies the version of the deleted filesystem to restore.
+ :keyword str new_name:
+ The new name for the deleted filesystem to be restored to.
+ If not specified deleted_file_system_name will be used as the restored filesystem name.
+ :keyword int timeout:
+ The timeout parameter is expressed in seconds.
+ :rtype: ~azure.storage.filedatalake.FileSystemClient
+ """
+ new_name = kwargs.pop('new_name', None)
+ await self._blob_service_client.undelete_container(
+ deleted_file_system_name, deleted_file_system_version, **kwargs) # pylint: disable=protected-access
+ file_system = self.get_file_system_client(new_name or deleted_file_system_name)
+ return file_system
+
async def delete_file_system(self, file_system, # type: Union[FileSystemProperties, str]
**kwargs):
# type: (...) -> FileSystemClient
diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_rename_file_system.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_rename_file_system.yaml
new file mode 100644
index 000000000000..96b4e96368ca
--- /dev/null
+++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_rename_file_system.yaml
@@ -0,0 +1,309 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - c687c715-549f-11eb-8dba-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 06:31:17 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/oldcontainer15303108c?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date:
+ - Tue, 12 Jan 2021 06:31:17 GMT
+ ETag:
+ - '"0x8D8B6C3AB1693AC"'
+ Last-Modified:
+ - Tue, 12 Jan 2021 06:31:17 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding:
+ - chunked
+ x-ms-request-id:
+ - d501c99e-901e-0009-80ac-e8fbc7000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 201
+ message: Created
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - c6f404ff-549f-11eb-8ec8-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 06:31:17 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/oldcontainer25303108c?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date:
+ - Tue, 12 Jan 2021 06:31:17 GMT
+ ETag:
+ - '"0x8D8B6C3AB3852A2"'
+ Last-Modified:
+ - Tue, 12 Jan 2021 06:31:18 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding:
+ - chunked
+ x-ms-request-id:
+ - d501c9a4-901e-0009-02ac-e8fbc7000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 201
+ message: Created
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - c7093ab6-549f-11eb-8e60-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 06:31:18 GMT
+ x-ms-source-container-name:
+ - oldcontainer15303108c
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/newcontainer5303108c?restype=container&comp=rename
+ response:
+ body:
+ string: ''
+ headers:
+ Content-Length:
+ - '0'
+ Date:
+ - Tue, 12 Jan 2021 06:31:18 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-request-id:
+ - 429e36d5-301e-0004-30ac-e814cb000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 200
+ message: OK
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - c7474ea0-549f-11eb-b6d8-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 06:31:18 GMT
+ x-ms-source-container-name:
+ - oldcontainer25303108c
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/newcontainer5303108c?restype=container&comp=rename
+ response:
+ body:
+ string: "\uFEFF\nContainerAlreadyExists
The
+ specified container already exists.\nRequestId:429e36d7-301e-0004-32ac-e814cb000000\nTime:2021-01-12T06:31:18.5745405Z"
+ headers:
+ Content-Length:
+ - '231'
+ Content-Type:
+ - application/xml
+ Date:
+ - Tue, 12 Jan 2021 06:31:18 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code:
+ - ContainerAlreadyExists
+ x-ms-request-id:
+ - 429e36d7-301e-0004-32ac-e814cb000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 409
+ message: The specified container already exists.
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - c7577c81-549f-11eb-90ac-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 06:31:18 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/oldcontainer15303108c?restype=container
+ response:
+ body:
+ string: "\uFEFFContainerNotFound
The
+ specified container does not exist.\nRequestId:d501c9a7-901e-0009-04ac-e8fbc7000000\nTime:2021-01-12T06:31:18.6822824Z"
+ headers:
+ Content-Length:
+ - '225'
+ Content-Type:
+ - application/xml
+ Date:
+ - Tue, 12 Jan 2021 06:31:17 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code:
+ - ContainerNotFound
+ x-ms-request-id:
+ - d501c9a7-901e-0009-04ac-e8fbc7000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 404
+ message: The specified container does not exist.
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - c767a7d2-549f-11eb-99b1-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 06:31:18 GMT
+ x-ms-source-container-name:
+ - badfilesystem
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/filesystem?restype=container&comp=rename
+ response:
+ body:
+ string: "\uFEFF\nContainerNotFound
The
+ specified container does not exist.\nRequestId:429e36da-301e-0004-35ac-e814cb000000\nTime:2021-01-12T06:31:18.7886908Z"
+ headers:
+ Content-Length:
+ - '226'
+ Content-Type:
+ - application/xml
+ Date:
+ - Tue, 12 Jan 2021 06:31:18 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code:
+ - ContainerNotFound
+ x-ms-request-id:
+ - 429e36da-301e-0004-35ac-e814cb000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 404
+ message: The specified container does not exist.
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - c777d175-549f-11eb-97b9-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 06:31:18 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/newcontainer5303108c?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date:
+ - Tue, 12 Jan 2021 06:31:17 GMT
+ ETag:
+ - '"0x8D8B6C3AB793363"'
+ Last-Modified:
+ - Tue, 12 Jan 2021 06:31:18 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding:
+ - chunked
+ x-ms-default-encryption-scope:
+ - $account-encryption-key
+ x-ms-deny-encryption-scope-override:
+ - 'false'
+ x-ms-has-immutability-policy:
+ - 'false'
+ x-ms-has-legal-hold:
+ - 'false'
+ x-ms-lease-state:
+ - available
+ x-ms-lease-status:
+ - unlocked
+ x-ms-request-id:
+ - d501c9a8-901e-0009-05ac-e8fbc7000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 200
+ message: OK
+version: 1
diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_rename_file_system_with_source_lease.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_rename_file_system_with_source_lease.yaml
new file mode 100644
index 000000000000..9b119f21fa15
--- /dev/null
+++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_rename_file_system_with_source_lease.yaml
@@ -0,0 +1,282 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - d13a0bed-549f-11eb-ac2b-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 06:31:35 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/oldc44e1800?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date:
+ - Tue, 12 Jan 2021 06:31:34 GMT
+ ETag:
+ - '"0x8D8B6C3B5AEEE7F"'
+ Last-Modified:
+ - Tue, 12 Jan 2021 06:31:35 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding:
+ - chunked
+ x-ms-request-id:
+ - 6d44400c-101e-0013-0bac-e8d4a8000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 201
+ message: Created
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - d17fa06a-549f-11eb-8f28-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 06:31:35 GMT
+ x-ms-lease-action:
+ - acquire
+ x-ms-lease-duration:
+ - '-1'
+ x-ms-proposed-lease-id:
+ - 497f066a-c59c-4dae-be30-20a0df2eee69
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/oldc44e1800?comp=lease&restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date:
+ - Tue, 12 Jan 2021 06:31:34 GMT
+ ETag:
+ - '"0x8D8B6C3B5AEEE7F"'
+ Last-Modified:
+ - Tue, 12 Jan 2021 06:31:35 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding:
+ - chunked
+ x-ms-lease-id:
+ - 497f066a-c59c-4dae-be30-20a0df2eee69
+ x-ms-request-id:
+ - 6d444011-101e-0013-0cac-e8d4a8000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 201
+ message: Created
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - d1976e28-549f-11eb-a604-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 06:31:35 GMT
+ x-ms-source-container-name:
+ - oldc44e1800
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/newc44e1800?restype=container&comp=rename
+ response:
+ body:
+ string: "\uFEFF\nLeaseIdMissing
There
+ is currently a lease on the container and no lease ID was specified in the
+ request.\nRequestId:238a38e4-001e-0007-77ac-e817cc000000\nTime:2021-01-12T06:31:36.1516703Z"
+ headers:
+ Content-Length:
+ - '273'
+ Content-Type:
+ - application/xml
+ Date:
+ - Tue, 12 Jan 2021 06:31:35 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code:
+ - LeaseIdMissing
+ x-ms-request-id:
+ - 238a38e4-001e-0007-77ac-e817cc000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 412
+ message: There is currently a lease on the container and no lease ID was specified
+ in the request.
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - d1d17a6d-549f-11eb-ae04-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 06:31:36 GMT
+ x-ms-source-container-name:
+ - oldc44e1800
+ x-ms-source-lease-id:
+ - bad_id
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/newc44e1800?restype=container&comp=rename
+ response:
+ body:
+ string: "\uFEFF\nInvalidHeaderValue
The
+ value for one of the HTTP headers is not in the correct format.\nRequestId:238a38f3-001e-0007-06ac-e817cc000000\nTime:2021-01-12T06:31:36.2577450Zx-ms-source-lease-idbad_id"
+ headers:
+ Content-Length:
+ - '333'
+ Content-Type:
+ - application/xml
+ Date:
+ - Tue, 12 Jan 2021 06:31:35 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code:
+ - InvalidHeaderValue
+ x-ms-request-id:
+ - 238a38f3-001e-0007-06ac-e817cc000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 400
+ message: The value for one of the HTTP headers is not in the correct format.
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - d1e17f97-549f-11eb-ae18-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 06:31:36 GMT
+ x-ms-source-container-name:
+ - oldc44e1800
+ x-ms-source-lease-id:
+ - 497f066a-c59c-4dae-be30-20a0df2eee69
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/newc44e1800?restype=container&comp=rename
+ response:
+ body:
+ string: ''
+ headers:
+ Content-Length:
+ - '0'
+ Date:
+ - Tue, 12 Jan 2021 06:31:35 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-request-id:
+ - 238a38f7-001e-0007-0aac-e817cc000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 200
+ message: OK
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - d1f2bee8-549f-11eb-9bbd-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 06:31:36 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/newc44e1800?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date:
+ - Tue, 12 Jan 2021 06:31:35 GMT
+ ETag:
+ - '"0x8D8B6C3B624B43B"'
+ Last-Modified:
+ - Tue, 12 Jan 2021 06:31:36 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding:
+ - chunked
+ x-ms-default-encryption-scope:
+ - $account-encryption-key
+ x-ms-deny-encryption-scope-override:
+ - 'false'
+ x-ms-has-immutability-policy:
+ - 'false'
+ x-ms-has-legal-hold:
+ - 'false'
+ x-ms-lease-state:
+ - available
+ x-ms-lease-status:
+ - unlocked
+ x-ms-request-id:
+ - 6d444012-101e-0013-0dac-e8d4a8000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 200
+ message: OK
+version: 1
diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_restore_to_existing_file_system.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_restore_to_existing_file_system.yaml
new file mode 100644
index 000000000000..a1735ca9727f
--- /dev/null
+++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_restore_to_existing_file_system.yaml
@@ -0,0 +1,211 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - a9986e72-555f-11eb-ae37-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:24:52 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/existing254311624?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date:
+ - Wed, 13 Jan 2021 05:24:51 GMT
+ ETag:
+ - '"0x8D8B7838E1223F2"'
+ Last-Modified:
+ - Wed, 13 Jan 2021 05:24:52 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding:
+ - chunked
+ x-ms-request-id:
+ - e9f5c23d-901e-0002-366c-e9e3b3000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 201
+ message: Created
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - a9debca0-555f-11eb-a16c-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:24:52 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/filesystem254311624?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date:
+ - Wed, 13 Jan 2021 05:24:51 GMT
+ ETag:
+ - '"0x8D8B7838E26E82B"'
+ Last-Modified:
+ - Wed, 13 Jan 2021 05:24:52 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding:
+ - chunked
+ x-ms-request-id:
+ - e9f5c245-901e-0002-3a6c-e9e3b3000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 201
+ message: Created
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - a9f2b9d6-555f-11eb-8c1f-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:24:52 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: DELETE
+ uri: https://storagename.blob.core.windows.net/filesystem254311624?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date:
+ - Wed, 13 Jan 2021 05:24:52 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding:
+ - chunked
+ x-ms-request-id:
+ - e9f5c247-901e-0002-3b6c-e9e3b3000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 202
+ message: Accepted
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - aa1cbb31-555f-11eb-ab23-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:24:52 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/filesystem254311624?restype=container
+ response:
+ body:
+ string: "\uFEFFContainerNotFound
The
+ specified container does not exist.\nRequestId:e9f5c24d-901e-0002-3f6c-e9e3b3000000\nTime:2021-01-13T05:24:53.0511286Z"
+ headers:
+ Content-Length:
+ - '225'
+ Content-Type:
+ - application/xml
+ Date:
+ - Wed, 13 Jan 2021 05:24:52 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code:
+ - ContainerNotFound
+ x-ms-request-id:
+ - e9f5c24d-901e-0002-3f6c-e9e3b3000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 404
+ message: The specified container does not exist.
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - aa2ee3c5-555f-11eb-be92-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:24:53 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/?comp=list&include=
+ response:
+ body:
+ string: "\uFEFFexisting254311624Wed,
+ 13 Jan 2021 05:24:52 GMT\"0x8D8B7838E1223F2\"unlockedavailable$account-encryption-keyfalsefalsefalsenewc44e1800Tue,
+ 12 Jan 2021 06:31:36 GMT\"0x8D8B6C3B624B43B\"unlockedavailable$account-encryption-keyfalsefalsefalsenewcontainer5303108cTue,
+ 12 Jan 2021 06:31:18 GMT\"0x8D8B6C3AB793363\"unlockedavailable$account-encryption-keyfalsefalsefalsenewcontainerbfe81309Tue,
+ 12 Jan 2021 07:27:39 GMT\"0x8D8B6CB8AA8F4E6\"unlockedavailable$account-encryption-keyfalsefalsefalseoldcontainer25303108cTue,
+ 12 Jan 2021 06:31:18 GMT\"0x8D8B6C3AB3852A2\"unlockedavailable$account-encryption-keyfalsefalsefalseoldcontainer2bfe81309Tue,
+ 12 Jan 2021 07:27:39 GMT\"0x8D8B6CB8A9CE62B\"unlockedavailable$account-encryption-keyfalsefalsefalse"
+ headers:
+ Content-Type:
+ - application/xml
+ Date:
+ - Wed, 13 Jan 2021 05:24:52 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding:
+ - chunked
+ x-ms-request-id:
+ - 3db8dbc6-101e-0018-1b6c-e9ccdc000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 200
+ message: OK
+version: 1
diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_undelete_file_system.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_undelete_file_system.yaml
new file mode 100644
index 000000000000..4a9f824c3fa6
--- /dev/null
+++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system.test_undelete_file_system.yaml
@@ -0,0 +1,168 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - a3a936f5-555f-11eb-9833-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:24:42 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/filesystem75f5116a?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date:
+ - Wed, 13 Jan 2021 05:24:41 GMT
+ ETag:
+ - '"0x8D8B783882B32E9"'
+ Last-Modified:
+ - Wed, 13 Jan 2021 05:24:42 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding:
+ - chunked
+ x-ms-request-id:
+ - f3b632f3-e01e-0006-056c-e91631000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 201
+ message: Created
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - a3f8bf75-555f-11eb-9194-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:24:42 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: DELETE
+ uri: https://storagename.blob.core.windows.net/filesystem75f5116a?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date:
+ - Wed, 13 Jan 2021 05:24:41 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding:
+ - chunked
+ x-ms-request-id:
+ - f3b632f7-e01e-0006-066c-e91631000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 202
+ message: Accepted
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - a40e69e8-555f-11eb-a428-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:24:42 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/filesystem75f5116a?restype=container
+ response:
+ body:
+ string: "\uFEFFContainerNotFound
The
+ specified container does not exist.\nRequestId:f3b632f9-e01e-0006-076c-e91631000000\nTime:2021-01-13T05:24:42.8868423Z"
+ headers:
+ Content-Length:
+ - '225'
+ Content-Type:
+ - application/xml
+ Date:
+ - Wed, 13 Jan 2021 05:24:42 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code:
+ - ContainerNotFound
+ x-ms-request-id:
+ - f3b632f9-e01e-0006-076c-e91631000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 404
+ message: The specified container does not exist.
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - a4204a05-555f-11eb-98d7-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:24:42 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/?comp=list&include=
+ response:
+ body:
+ string: "\uFEFFnewc44e1800Tue,
+ 12 Jan 2021 06:31:36 GMT\"0x8D8B6C3B624B43B\"unlockedavailable$account-encryption-keyfalsefalsefalsenewcontainer5303108cTue,
+ 12 Jan 2021 06:31:18 GMT\"0x8D8B6C3AB793363\"unlockedavailable$account-encryption-keyfalsefalsefalsenewcontainerbfe81309Tue,
+ 12 Jan 2021 07:27:39 GMT\"0x8D8B6CB8AA8F4E6\"unlockedavailable$account-encryption-keyfalsefalsefalseoldcontainer25303108cTue,
+ 12 Jan 2021 06:31:18 GMT\"0x8D8B6C3AB3852A2\"unlockedavailable$account-encryption-keyfalsefalsefalseoldcontainer2bfe81309Tue,
+ 12 Jan 2021 07:27:39 GMT\"0x8D8B6CB8A9CE62B\"unlockedavailable$account-encryption-keyfalsefalsefalse"
+ headers:
+ Content-Type:
+ - application/xml
+ Date:
+ - Wed, 13 Jan 2021 05:24:42 GMT
+ Server:
+ - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding:
+ - chunked
+ x-ms-request-id:
+ - d5b08137-401e-000b-276c-e9f93d000000
+ x-ms-version:
+ - '2020-04-08'
+ status:
+ code: 200
+ message: OK
+version: 1
diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_rename_file_system.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_rename_file_system.yaml
new file mode 100644
index 000000000000..f7b0fa160d92
--- /dev/null
+++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_rename_file_system.yaml
@@ -0,0 +1,225 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - a62c7126-54a7-11eb-98b0-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 07:27:38 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/oldcontainer1bfe81309?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date: Tue, 12 Jan 2021 07:27:39 GMT
+ ETag: '"0x8D8B6CB8A9039B0"'
+ Last-Modified: Tue, 12 Jan 2021 07:27:39 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding: chunked
+ x-ms-request-id: 238cd6fb-001e-0007-59b4-e817cc000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 201
+ message: Created
+ url: https://storagename.blob.core.windows.net/oldcontainer1bfe81309?restype=container
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - a6603b70-54a7-11eb-9017-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 07:27:39 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/oldcontainer2bfe81309?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date: Tue, 12 Jan 2021 07:27:39 GMT
+ ETag: '"0x8D8B6CB8A9CE62B"'
+ Last-Modified: Tue, 12 Jan 2021 07:27:39 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding: chunked
+ x-ms-request-id: 238cd6ff-001e-0007-5ab4-e817cc000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 201
+ message: Created
+ url: https://storagename.blob.core.windows.net/oldcontainer2bfe81309?restype=container
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - a66b8611-54a7-11eb-95af-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 07:27:39 GMT
+ x-ms-source-container-name:
+ - oldcontainer1bfe81309
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/newcontainerbfe81309?restype=container&comp=rename
+ response:
+ body:
+ string: ''
+ headers:
+ Content-Length: '0'
+ Date: Tue, 12 Jan 2021 07:27:39 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-request-id: 238cd702-001e-0007-5bb4-e817cc000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 200
+ message: OK
+ url: https://storagename.blob.core.windows.net/newcontainerbfe81309?restype=container&comp=rename
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - a6765b80-54a7-11eb-80ea-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 07:27:39 GMT
+ x-ms-source-container-name:
+ - oldcontainer2bfe81309
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/newcontainerbfe81309?restype=container&comp=rename
+ response:
+ body:
+ string: "\uFEFF\nContainerAlreadyExists
The
+ specified container already exists.\nRequestId:238cd703-001e-0007-5cb4-e817cc000000\nTime:2021-01-12T07:27:39.4520865Z"
+ headers:
+ Content-Length: '231'
+ Content-Type: application/xml
+ Date: Tue, 12 Jan 2021 07:27:39 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code: ContainerAlreadyExists
+ x-ms-request-id: 238cd703-001e-0007-5cb4-e817cc000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 409
+ message: The specified container already exists.
+ url: https://storagename.blob.core.windows.net/newcontainerbfe81309?restype=container&comp=rename
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - a67f8354-54a7-11eb-9924-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 07:27:39 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/oldcontainer1bfe81309?restype=container
+ response:
+ body:
+ string: "\uFEFFContainerNotFound
The
+ specified container does not exist.\nRequestId:238cd704-001e-0007-5db4-e817cc000000\nTime:2021-01-12T07:27:39.5121288Z"
+ headers:
+ Content-Length: '225'
+ Content-Type: application/xml
+ Date: Tue, 12 Jan 2021 07:27:39 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code: ContainerNotFound
+ x-ms-request-id: 238cd704-001e-0007-5db4-e817cc000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 404
+ message: The specified container does not exist.
+ url: https://storagename.blob.core.windows.net/oldcontainer1bfe81309?restype=container
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - a688a6e3-54a7-11eb-80fd-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 07:27:39 GMT
+ x-ms-source-container-name:
+ - badfilesystem
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/filesystem?restype=container&comp=rename
+ response:
+ body:
+ string: "\uFEFF\nContainerNotFound
The
+ specified container does not exist.\nRequestId:238cd705-001e-0007-5eb4-e817cc000000\nTime:2021-01-12T07:27:39.5731715Z"
+ headers:
+ Content-Length: '226'
+ Content-Type: application/xml
+ Date: Tue, 12 Jan 2021 07:27:39 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code: ContainerNotFound
+ x-ms-request-id: 238cd705-001e-0007-5eb4-e817cc000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 404
+ message: The specified container does not exist.
+ url: https://storagename.blob.core.windows.net/filesystem?restype=container&comp=rename
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - a6921cdf-54a7-11eb-8aa1-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 07:27:39 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/newcontainerbfe81309?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date: Tue, 12 Jan 2021 07:27:39 GMT
+ ETag: '"0x8D8B6CB8AA8F4E6"'
+ Last-Modified: Tue, 12 Jan 2021 07:27:39 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding: chunked
+ x-ms-default-encryption-scope: $account-encryption-key
+ x-ms-deny-encryption-scope-override: 'false'
+ x-ms-has-immutability-policy: 'false'
+ x-ms-has-legal-hold: 'false'
+ x-ms-lease-state: available
+ x-ms-lease-status: unlocked
+ x-ms-request-id: 238cd706-001e-0007-5fb4-e817cc000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 200
+ message: OK
+ url: https://storagename.blob.core.windows.net/newcontainerbfe81309?restype=container
+version: 1
diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_rename_file_system_with_source_lease.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_rename_file_system_with_source_lease.yaml
new file mode 100644
index 000000000000..ad011acd9f21
--- /dev/null
+++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_rename_file_system_with_source_lease.yaml
@@ -0,0 +1,207 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - b0e6998a-54a7-11eb-a963-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 07:27:56 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/old5e0c1a7d?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date: Tue, 12 Jan 2021 07:27:57 GMT
+ ETag: '"0x8D8B6CB953F97B8"'
+ Last-Modified: Tue, 12 Jan 2021 07:27:57 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding: chunked
+ x-ms-request-id: 247881fb-701e-0008-22b4-e8fa3a000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 201
+ message: Created
+ url: https://storagename.blob.core.windows.net/old5e0c1a7d?restype=container
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - b110dded-54a7-11eb-8172-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 07:27:57 GMT
+ x-ms-lease-action:
+ - acquire
+ x-ms-lease-duration:
+ - '-1'
+ x-ms-proposed-lease-id:
+ - 6c0de9a0-60ff-4ad5-a11e-3642d5da43b6
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/old5e0c1a7d?comp=lease&restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date: Tue, 12 Jan 2021 07:27:57 GMT
+ ETag: '"0x8D8B6CB953F97B8"'
+ Last-Modified: Tue, 12 Jan 2021 07:27:57 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding: chunked
+ x-ms-lease-id: 6c0de9a0-60ff-4ad5-a11e-3642d5da43b6
+ x-ms-request-id: 247881ff-701e-0008-23b4-e8fa3a000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 201
+ message: Created
+ url: https://storagename.blob.core.windows.net/old5e0c1a7d?comp=lease&restype=container
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - b11a0591-54a7-11eb-9b96-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 07:27:57 GMT
+ x-ms-source-container-name:
+ - old5e0c1a7d
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/new5e0c1a7d?restype=container&comp=rename
+ response:
+ body:
+ string: "\uFEFF\nLeaseIdMissing
There
+ is currently a lease on the container and no lease ID was specified in the
+ request.\nRequestId:24788200-701e-0008-24b4-e8fa3a000000\nTime:2021-01-12T07:27:57.3085406Z"
+ headers:
+ Content-Length: '273'
+ Content-Type: application/xml
+ Date: Tue, 12 Jan 2021 07:27:57 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code: LeaseIdMissing
+ x-ms-request-id: 24788200-701e-0008-24b4-e8fa3a000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 412
+ message: There is currently a lease on the container and no lease ID was specified
+ in the request.
+ url: https://storagename.blob.core.windows.net/new5e0c1a7d?restype=container&comp=rename
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - b12417be-54a7-11eb-abcc-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 07:27:57 GMT
+ x-ms-source-container-name:
+ - old5e0c1a7d
+ x-ms-source-lease-id:
+ - bad_id
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/new5e0c1a7d?restype=container&comp=rename
+ response:
+ body:
+ string: "\uFEFF\nInvalidHeaderValue
The
+ value for one of the HTTP headers is not in the correct format.\nRequestId:24788201-701e-0008-25b4-e8fa3a000000\nTime:2021-01-12T07:27:57.3665815Zx-ms-source-lease-idbad_id"
+ headers:
+ Content-Length: '333'
+ Content-Type: application/xml
+ Date: Tue, 12 Jan 2021 07:27:57 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code: InvalidHeaderValue
+ x-ms-request-id: 24788201-701e-0008-25b4-e8fa3a000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 400
+ message: The value for one of the HTTP headers is not in the correct format.
+ url: https://storagename.blob.core.windows.net/new5e0c1a7d?restype=container&comp=rename
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - b12cf181-54a7-11eb-9a54-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 07:27:57 GMT
+ x-ms-source-container-name:
+ - old5e0c1a7d
+ x-ms-source-lease-id:
+ - 6c0de9a0-60ff-4ad5-a11e-3642d5da43b6
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/new5e0c1a7d?restype=container&comp=rename
+ response:
+ body:
+ string: ''
+ headers:
+ Content-Length: '0'
+ Date: Tue, 12 Jan 2021 07:27:57 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-request-id: 24788202-701e-0008-26b4-e8fa3a000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 200
+ message: OK
+ url: https://storagename.blob.core.windows.net/new5e0c1a7d?restype=container&comp=rename
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - b13778d7-54a7-11eb-9c90-c8348e5fffbc
+ x-ms-date:
+ - Tue, 12 Jan 2021 07:27:57 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/new5e0c1a7d?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date: Tue, 12 Jan 2021 07:27:57 GMT
+ ETag: '"0x8D8B6CB956A2461"'
+ Last-Modified: Tue, 12 Jan 2021 07:27:57 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding: chunked
+ x-ms-default-encryption-scope: $account-encryption-key
+ x-ms-deny-encryption-scope-override: 'false'
+ x-ms-has-immutability-policy: 'false'
+ x-ms-has-legal-hold: 'false'
+ x-ms-lease-state: available
+ x-ms-lease-status: unlocked
+ x-ms-request-id: 24788203-701e-0008-27b4-e8fa3a000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 200
+ message: OK
+ url: https://storagename.blob.core.windows.net/new5e0c1a7d?restype=container
+version: 1
diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_restore_to_existing_file_system.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_restore_to_existing_file_system.yaml
new file mode 100644
index 000000000000..17232380b4c1
--- /dev/null
+++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_restore_to_existing_file_system.yaml
@@ -0,0 +1,158 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - c9a2c93b-555f-11eb-bc76-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:25:45 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/existinge16f18a1?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date: Wed, 13 Jan 2021 05:25:45 GMT
+ ETag: '"0x8D8B783AE0F5FEB"'
+ Last-Modified: Wed, 13 Jan 2021 05:25:46 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding: chunked
+ x-ms-request-id: ac5b6366-d01e-000e-596c-e90d42000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 201
+ message: Created
+ url: https://storagename.blob.core.windows.net/existinge16f18a1?restype=container
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - c9dbdc67-555f-11eb-bf56-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:25:46 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/filesysteme16f18a1?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date: Wed, 13 Jan 2021 05:25:45 GMT
+ ETag: '"0x8D8B783AE1B7006"'
+ Last-Modified: Wed, 13 Jan 2021 05:25:46 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding: chunked
+ x-ms-request-id: ac5b636c-d01e-000e-5c6c-e90d42000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 201
+ message: Created
+ url: https://storagename.blob.core.windows.net/filesysteme16f18a1?restype=container
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - c9e7c366-555f-11eb-b896-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:25:46 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: DELETE
+ uri: https://storagename.blob.core.windows.net/filesysteme16f18a1?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date: Wed, 13 Jan 2021 05:25:45 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding: chunked
+ x-ms-request-id: ac5b636e-d01e-000e-5d6c-e90d42000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 202
+ message: Accepted
+ url: https://storagename.blob.core.windows.net/filesysteme16f18a1?restype=container
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - c9f4ab42-555f-11eb-a8dc-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:25:46 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/filesysteme16f18a1?restype=container
+ response:
+ body:
+ string: "\uFEFFContainerNotFound
The
+ specified container does not exist.\nRequestId:ac5b636f-d01e-000e-5e6c-e90d42000000\nTime:2021-01-13T05:25:46.4168842Z"
+ headers:
+ Content-Length: '225'
+ Content-Type: application/xml
+ Date: Wed, 13 Jan 2021 05:25:45 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code: ContainerNotFound
+ x-ms-request-id: ac5b636f-d01e-000e-5e6c-e90d42000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 404
+ message: The specified container does not exist.
+ url: https://storagename.blob.core.windows.net/filesysteme16f18a1?restype=container
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - c9fe0ede-555f-11eb-ab84-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:25:46 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/?comp=list&include=
+ response:
+ body:
+ string: "\uFEFFexistinge16f18a1Wed,
+ 13 Jan 2021 05:25:46 GMT\"0x8D8B783AE0F5FEB\"unlockedavailable$account-encryption-keyfalsefalsefalsenewc44e1800Tue,
+ 12 Jan 2021 06:31:36 GMT\"0x8D8B6C3B624B43B\"unlockedavailable$account-encryption-keyfalsefalsefalsenewcontainer5303108cTue,
+ 12 Jan 2021 06:31:18 GMT\"0x8D8B6C3AB793363\"unlockedavailable$account-encryption-keyfalsefalsefalsenewcontainerbfe81309Tue,
+ 12 Jan 2021 07:27:39 GMT\"0x8D8B6CB8AA8F4E6\"unlockedavailable$account-encryption-keyfalsefalsefalseoldcontainer25303108cTue,
+ 12 Jan 2021 06:31:18 GMT\"0x8D8B6C3AB3852A2\"unlockedavailable$account-encryption-keyfalsefalsefalseoldcontainer2bfe81309Tue,
+ 12 Jan 2021 07:27:39 GMT\"0x8D8B6CB8A9CE62B\"unlockedavailable$account-encryption-keyfalsefalsefalse"
+ headers:
+ Content-Type: application/xml
+ Date: Wed, 13 Jan 2021 05:25:45 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding: chunked
+ x-ms-request-id: ac5b6370-d01e-000e-5f6c-e90d42000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 200
+ message: OK
+ url: https://storagename.blob.core.windows.net/?comp=list&include=
+version: 1
diff --git a/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_undelete_file_system.yaml b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_undelete_file_system.yaml
new file mode 100644
index 000000000000..053f2138ad16
--- /dev/null
+++ b/sdk/storage/azure-storage-file-datalake/tests/recordings/test_file_system_async.test_undelete_file_system.yaml
@@ -0,0 +1,127 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - c52243d6-555f-11eb-95a0-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:25:38 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: PUT
+ uri: https://storagename.blob.core.windows.net/filesysteme7d413e7?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date: Wed, 13 Jan 2021 05:25:37 GMT
+ ETag: '"0x8D8B783A982BA7C"'
+ Last-Modified: Wed, 13 Jan 2021 05:25:38 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding: chunked
+ x-ms-request-id: cb1d8a08-801e-0016-706c-e920d7000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 201
+ message: Created
+ url: https://storagename.blob.core.windows.net/filesysteme7d413e7?restype=container
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - c557b10f-555f-11eb-8082-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:25:38 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: DELETE
+ uri: https://storagename.blob.core.windows.net/filesysteme7d413e7?restype=container
+ response:
+ body:
+ string: ''
+ headers:
+ Date: Wed, 13 Jan 2021 05:25:38 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding: chunked
+ x-ms-request-id: cb1d8a0d-801e-0016-726c-e920d7000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 202
+ message: Accepted
+ url: https://storagename.blob.core.windows.net/filesysteme7d413e7?restype=container
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-dfs/12.2.1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - c56609b7-555f-11eb-848b-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:25:38 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/filesysteme7d413e7?restype=container
+ response:
+ body:
+ string: "\uFEFFContainerNotFound
The
+ specified container does not exist.\nRequestId:cb1d8a0e-801e-0016-736c-e920d7000000\nTime:2021-01-13T05:25:38.7712499Z"
+ headers:
+ Content-Length: '225'
+ Content-Type: application/xml
+ Date: Wed, 13 Jan 2021 05:25:38 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ x-ms-error-code: ContainerNotFound
+ x-ms-request-id: cb1d8a0e-801e-0016-736c-e920d7000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 404
+ message: The specified container does not exist.
+ url: https://storagename.blob.core.windows.net/filesysteme7d413e7?restype=container
+- request:
+ body: null
+ headers:
+ Accept:
+ - application/xml
+ User-Agent:
+ - azsdk-python-storage-blob/12.7.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
+ x-ms-client-request-id:
+ - c56fa695-555f-11eb-9119-c8348e5fffbc
+ x-ms-date:
+ - Wed, 13 Jan 2021 05:25:38 GMT
+ x-ms-version:
+ - '2020-04-08'
+ method: GET
+ uri: https://storagename.blob.core.windows.net/?comp=list&include=
+ response:
+ body:
+ string: "\uFEFFnewc44e1800Tue,
+ 12 Jan 2021 06:31:36 GMT\"0x8D8B6C3B624B43B\"unlockedavailable$account-encryption-keyfalsefalsefalsenewcontainer5303108cTue,
+ 12 Jan 2021 06:31:18 GMT\"0x8D8B6C3AB793363\"unlockedavailable$account-encryption-keyfalsefalsefalsenewcontainerbfe81309Tue,
+ 12 Jan 2021 07:27:39 GMT\"0x8D8B6CB8AA8F4E6\"unlockedavailable$account-encryption-keyfalsefalsefalseoldcontainer25303108cTue,
+ 12 Jan 2021 06:31:18 GMT\"0x8D8B6C3AB3852A2\"unlockedavailable$account-encryption-keyfalsefalsefalseoldcontainer2bfe81309Tue,
+ 12 Jan 2021 07:27:39 GMT\"0x8D8B6CB8A9CE62B\"unlockedavailable$account-encryption-keyfalsefalsefalse"
+ headers:
+ Content-Type: application/xml
+ Date: Wed, 13 Jan 2021 05:25:38 GMT
+ Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
+ Transfer-Encoding: chunked
+ x-ms-request-id: cb1d8a10-801e-0016-756c-e920d7000000
+ x-ms-version: '2020-04-08'
+ status:
+ code: 200
+ message: OK
+ url: https://storagename.blob.core.windows.net/?comp=list&include=
+version: 1
diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_file_system.py b/sdk/storage/azure-storage-file-datalake/tests/test_file_system.py
index f461bb8c6da8..bda3d442d605 100644
--- a/sdk/storage/azure-storage-file-datalake/tests/test_file_system.py
+++ b/sdk/storage/azure-storage-file-datalake/tests/test_file_system.py
@@ -8,14 +8,16 @@
import unittest
from datetime import datetime, timedelta
-from azure.core.exceptions import ResourceNotFoundError
+from azure.core.exceptions import ResourceNotFoundError, HttpResponseError
from azure.core import MatchConditions
-from azure.storage.filedatalake import DataLakeServiceClient, PublicAccess
+from azure.storage.filedatalake import DataLakeServiceClient, PublicAccess, generate_account_sas, ResourceTypes, \
+ AccountSasPermissions
from testcase import (
StorageTestCase,
record,
+ TestMode
)
# ------------------------------------------------------------------------------
@@ -122,6 +124,127 @@ def test_list_file_systemss(self):
self.assertIsNotNone(file_systems[0].has_immutability_policy)
self.assertIsNotNone(file_systems[0].has_legal_hold)
+ @record
+ def test_rename_file_system(self):
+ old_name1 = self._get_file_system_reference(prefix="oldcontainer1")
+ old_name2 = self._get_file_system_reference(prefix="oldcontainer2")
+ new_name = self._get_file_system_reference(prefix="newcontainer")
+ filesystem1 = self.dsc.create_file_system(old_name1)
+ self.dsc.create_file_system(old_name2)
+
+ new_filesystem = self.dsc.rename_file_system(
+ source_file_system_name=old_name1, destination_file_system_name=new_name)
+ with self.assertRaises(HttpResponseError):
+ self.dsc.rename_file_system(
+ source_file_system_name=old_name2, destination_file_system_name=new_name)
+ with self.assertRaises(HttpResponseError):
+ filesystem1.get_file_system_properties()
+ with self.assertRaises(HttpResponseError):
+ self.dsc.rename_file_system(
+ source_file_system_name="badfilesystem", destination_file_system_name="filesystem")
+ self.assertEqual(new_name, new_filesystem.get_file_system_properties().name)
+
+ @record
+ def test_rename_file_system_with_source_lease(self):
+ old_name = self._get_file_system_reference(prefix="old")
+ new_name = self._get_file_system_reference(prefix="new")
+ filesystem = self.dsc.create_file_system(old_name)
+ filesystem_lease_id = filesystem.acquire_lease()
+ with self.assertRaises(HttpResponseError):
+ self.dsc.rename_file_system(
+ source_file_system_name=old_name, destination_file_system_name=new_name)
+ with self.assertRaises(HttpResponseError):
+ self.dsc.rename_file_system(
+ source_file_system_name=old_name, destination_file_system_name=new_name, source_lease="bad_id")
+ new_filesystem = self.dsc.rename_file_system(
+ source_file_system_name=old_name, destination_file_system_name=new_name, source_lease=filesystem_lease_id)
+ self.assertEqual(new_name, new_filesystem.get_file_system_properties().name)
+
+ @record
+ def test_undelete_file_system(self):
+ name = self._get_file_system_reference(prefix="filesystem")
+ filesystem_client = self.dsc.create_file_system(name)
+
+ # Act
+ filesystem_client.delete_file_system()
+ # to make sure the filesystem deleted
+ with self.assertRaises(ResourceNotFoundError):
+ filesystem_client.get_file_system_properties()
+
+ filesystem_list = list(self.dsc.list_file_systems())
+ self.assertTrue(len(filesystem_list) >= 1)
+
+ restored_version = 0
+ for filesystem in filesystem_list:
+ # find the deleted filesystem and restore it
+ if filesystem.deleted and filesystem.name == filesystem_client.file_system_name:
+ restored_fs_client = self.dsc.undelete_file_system(filesystem.name, filesystem.version,
+ new_name="restored" + str(restored_version))
+ restored_version += 1
+
+ # to make sure the deleted filesystem is restored
+ props = restored_fs_client.get_file_system_properties()
+ self.assertIsNotNone(props)
+
+ @record
+ def test_restore_to_existing_file_system(self):
+ # get an existing filesystem
+ existing_name = self._get_file_system_reference(prefix="existing2")
+ name = self._get_file_system_reference(prefix="filesystem2")
+ existing_filesystem_client = self.dsc.create_file_system(existing_name)
+ filesystem_client = self.dsc.create_file_system(name)
+
+ # Act
+ filesystem_client.delete_file_system()
+ # to make sure the filesystem deleted
+ with self.assertRaises(ResourceNotFoundError):
+ filesystem_client.get_file_system_properties()
+
+ filesystem_list = list(self.dsc.list_file_systems())
+ self.assertTrue(len(filesystem_list) >= 1)
+
+ for filesystem in filesystem_list:
+ # find the deleted filesystem and restore it
+ if filesystem.deleted and filesystem.name == filesystem_client.file_system_name:
+ with self.assertRaises(HttpResponseError):
+ self.dsc.undelete_file_system(filesystem.name, filesystem.version,
+ new_name=existing_filesystem_client.file_system_name)
+
+ @record
+ def test_restore_file_system_with_sas(self):
+ # We are generating a SAS token therefore play only live
+ if TestMode.need_recording_file(self.test_mode):
+ return
+ token = generate_account_sas(
+ self.dsc.account_name,
+ self.dsc.credential.account_key,
+ ResourceTypes(service=True, file_system=True),
+ AccountSasPermissions(read=True, write=True, list=True, delete=True),
+ datetime.utcnow() + timedelta(hours=1),
+ )
+ dsc = DataLakeServiceClient(self.dsc.url, token)
+ name = self._get_file_system_reference(prefix="filesystem")
+ filesystem_client = dsc.create_file_system(name)
+ filesystem_client.delete_file_system()
+ # to make sure the filesystem is deleted
+ with self.assertRaises(ResourceNotFoundError):
+ filesystem_client.get_file_system_properties()
+
+ filesystem_list = list(dsc.list_file_systems())
+ self.assertTrue(len(filesystem_list) >= 1)
+
+ restored_version = 0
+ for filesystem in filesystem_list:
+ # find the deleted filesystem and restore it
+ if filesystem.deleted and filesystem.name == filesystem_client.file_system_name:
+ restored_fs_client = dsc.undelete_file_system(filesystem.name, filesystem.version,
+ new_name="restored" + str(restored_version))
+ restored_version += 1
+
+ # to make sure the deleted filesystem is restored
+ props = restored_fs_client.get_file_system_properties()
+ self.assertIsNotNone(props)
+
@record
def test_delete_file_system_with_existing_file_system(self):
# Arrange
diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_file_system_async.py b/sdk/storage/azure-storage-file-datalake/tests/test_file_system_async.py
index b42931da419e..33902d44e505 100644
--- a/sdk/storage/azure-storage-file-datalake/tests/test_file_system_async.py
+++ b/sdk/storage/azure-storage-file-datalake/tests/test_file_system_async.py
@@ -12,14 +12,14 @@
import pytest
-from azure.core.exceptions import ResourceNotFoundError
+from azure.core.exceptions import ResourceNotFoundError, HttpResponseError
from azure.core import MatchConditions
from azure.core.pipeline.transport import AioHttpTransport
from multidict import CIMultiDict, CIMultiDictProxy
from azure.storage.filedatalake import AccessPolicy, generate_directory_sas, DirectorySasPermissions, \
- generate_file_system_sas
+ generate_file_system_sas, generate_account_sas, ResourceTypes, AccountSasPermissions
from azure.storage.filedatalake.aio import DataLakeServiceClient, DataLakeDirectoryClient, FileSystemClient
from azure.storage.filedatalake import PublicAccess
from testcase import (
@@ -154,6 +154,152 @@ def test_delete_file_system_with_existing_file_system_async(self):
loop = asyncio.get_event_loop()
loop.run_until_complete(self._test_delete_file_system_with_existing_file_system_async())
+ async def _test_rename_file_system(self):
+ old_name1 = self._get_file_system_reference(prefix="oldcontainer1")
+ old_name2 = self._get_file_system_reference(prefix="oldcontainer2")
+ new_name = self._get_file_system_reference(prefix="newcontainer")
+ filesystem1 = await self.dsc.create_file_system(old_name1)
+ await self.dsc.create_file_system(old_name2)
+
+ new_filesystem = await self.dsc.rename_file_system(
+ source_file_system_name=old_name1, destination_file_system_name=new_name)
+ with self.assertRaises(HttpResponseError):
+ await self.dsc.rename_file_system(
+ source_file_system_name=old_name2, destination_file_system_name=new_name)
+ with self.assertRaises(HttpResponseError):
+ await filesystem1.get_file_system_properties()
+ with self.assertRaises(HttpResponseError):
+ await self.dsc.rename_file_system(
+ source_file_system_name="badfilesystem", destination_file_system_name="filesystem")
+ props = await new_filesystem.get_file_system_properties()
+ self.assertEqual(new_name, props.name)
+
+ @record
+ def test_rename_file_system(self):
+ loop = asyncio.get_event_loop()
+ loop.run_until_complete(self._test_rename_file_system())
+
+ async def _test_rename_file_system_with_source_lease(self):
+ old_name = self._get_file_system_reference(prefix="old")
+ new_name = self._get_file_system_reference(prefix="new")
+ filesystem = await self.dsc.create_file_system(old_name)
+ filesystem_lease_id = await filesystem.acquire_lease()
+ with self.assertRaises(HttpResponseError):
+ await self.dsc.rename_file_system(
+ source_file_system_name=old_name, destination_file_system_name=new_name)
+ with self.assertRaises(HttpResponseError):
+ await self.dsc.rename_file_system(
+ source_file_system_name=old_name, destination_file_system_name=new_name, source_lease="bad_id")
+ new_filesystem = await self.dsc.rename_file_system(
+ source_file_system_name=old_name, destination_file_system_name=new_name, source_lease=filesystem_lease_id)
+ props = await new_filesystem.get_file_system_properties()
+ self.assertEqual(new_name, props.name)
+
+ @record
+ def test_rename_file_system_with_source_lease(self):
+ loop = asyncio.get_event_loop()
+ loop.run_until_complete(self._test_rename_file_system_with_source_lease())
+
+ async def _test_undelete_file_system(self):
+ name = self._get_file_system_reference(prefix="filesystem")
+ filesystem_client = await self.dsc.create_file_system(name)
+
+ await filesystem_client.delete_file_system()
+ # to make sure the filesystem deleted
+ with self.assertRaises(ResourceNotFoundError):
+ await filesystem_client.get_file_system_properties()
+
+ filesystem_list = []
+ async for fs in self.dsc.list_file_systems():
+ filesystem_list.append(fs)
+ self.assertTrue(len(filesystem_list) >= 1)
+
+ restored_version = 0
+ for filesystem in filesystem_list:
+ # find the deleted filesystem and restore it
+ if filesystem.deleted and filesystem.name == filesystem_client.file_system_name:
+ restored_fs_client = await self.dsc.undelete_file_system(filesystem.name, filesystem.version,
+ new_name="restored" + str(restored_version))
+ restored_version += 1
+
+ # to make sure the deleted filesystem is restored
+ props = await restored_fs_client.get_file_system_properties()
+ self.assertIsNotNone(props)
+
+ @record
+ def test_undelete_file_system(self):
+ loop = asyncio.get_event_loop()
+ loop.run_until_complete(self._test_undelete_file_system())
+
+ async def _test_restore_to_existing_file_system(self):
+ # get an existing filesystem
+ existing_name = self._get_file_system_reference(prefix="existing")
+ name = self._get_file_system_reference(prefix="filesystem")
+ existing_filesystem_client = await self.dsc.create_file_system(existing_name)
+ filesystem_client = await self.dsc.create_file_system(name)
+
+ # Act
+ await filesystem_client.delete_file_system()
+ # to make sure the filesystem deleted
+ with self.assertRaises(ResourceNotFoundError):
+ await filesystem_client.get_file_system_properties()
+
+ filesystem_list = []
+ async for fs in self.dsc.list_file_systems():
+ filesystem_list.append(fs)
+ self.assertTrue(len(filesystem_list) >= 1)
+
+ for filesystem in filesystem_list:
+ # find the deleted filesystem and restore it
+ if filesystem.deleted and filesystem.name == filesystem_client.file_system_name:
+ with self.assertRaises(HttpResponseError):
+ await self.dsc.undelete_file_system(filesystem.name, filesystem.version,
+ new_name=existing_filesystem_client.file_system_name)
+ @record
+ def test_restore_to_existing_file_system(self):
+ loop = asyncio.get_event_loop()
+ loop.run_until_complete(self._test_restore_to_existing_file_system())
+
+ async def _test_restore_file_system_with_sas(self):
+ # We are generating a SAS token therefore play only live
+ if TestMode.need_recording_file(self.test_mode):
+ return
+ token = generate_account_sas(
+ self.dsc.account_name,
+ self.dsc.credential.account_key,
+ ResourceTypes(service=True, file_system=True),
+ AccountSasPermissions(read=True, write=True, list=True, delete=True),
+ datetime.utcnow() + timedelta(hours=1),
+ )
+ dsc = DataLakeServiceClient(self.dsc.url, token)
+ name = self._get_file_system_reference(prefix="filesystem")
+ filesystem_client = await dsc.create_file_system(name)
+ await filesystem_client.delete_file_system()
+ # to make sure the filesystem is deleted
+ with self.assertRaises(ResourceNotFoundError):
+ await filesystem_client.get_file_system_properties()
+
+ filesystem_list = []
+ async for fs in self.dsc.list_file_systems():
+ filesystem_list.append(fs)
+ self.assertTrue(len(filesystem_list) >= 1)
+
+ restored_version = 0
+ for filesystem in filesystem_list:
+ # find the deleted filesystem and restore it
+ if filesystem.deleted and filesystem.name == filesystem_client.file_system_name:
+ restored_fs_client = await dsc.undelete_file_system(filesystem.name, filesystem.version,
+ new_name="restored" + str(restored_version))
+ restored_version += 1
+
+ # to make sure the deleted filesystem is restored
+ props = await restored_fs_client.get_file_system_properties()
+ self.assertIsNotNone(props)
+ @record
+ def test_restore_file_system_with_sas(self):
+ loop = asyncio.get_event_loop()
+ loop.run_until_complete(self._test_restore_file_system_with_sas())
+
async def _test_delete_none_existing_file_system_async(self):
fake_file_system_client = self.dsc.get_file_system_client("fakeclient")