diff --git a/sdk/storage/azure-storage-files-datalake/CHANGELOG.md b/sdk/storage/azure-storage-files-datalake/CHANGELOG.md index cc9652aa8..707402aa7 100644 --- a/sdk/storage/azure-storage-files-datalake/CHANGELOG.md +++ b/sdk/storage/azure-storage-files-datalake/CHANGELOG.md @@ -45,6 +45,8 @@ - Type for ETag was changed to `Azure::Core::ETag`. - Type for `IfMatch` and `IfNoneMatch` was changed to `Azure::Core::ETag`. - Renamed `ListDataLakeFileSystemsIncludeItem` to `ListDataLakeFileSystemsIncludeFlags`. +- Removed `DataLakeDirectoryClient::Delete` and `DataLakeDirectoryClient::DeleteIfExists`. Added `DataLakeDirectoryClient::DeleteEmpty`, `DataLakeDirectoryClient::DeleteEmptyIfExists`, `DataLakeDirectoryClient::DeleteRecursive` and `DataLakeDirectoryClient::DeleteRecursiveIfExists` instead. +- Removed `ContinuationToken` in `DeleteDataLakePathResult` and `DeleteDataLakeDirectoryResult`, as they will never be returned for HNS enabled accounts. ### Other Changes and Improvements diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_directory_client.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_directory_client.hpp index 54b1b7e09..073bb9f04 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_directory_client.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_directory_client.hpp @@ -146,30 +146,57 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { = RenameDataLakeSubdirectoryOptions()) const; /** - * @brief Deletes the directory. - * @param recursive If "true", all paths beneath the directory will be deleted. If "false" and - * the directory is non-empty, an error occurs. + * @brief Deletes the empty directory. Throws exception if directory is not empty. * @param options Optional parameters to delete the directory the path points to. * @return Azure::Core::Response containing the information * returned when deleting the directory. * @remark This request is sent to dfs endpoint. */ - Azure::Core::Response Delete( - bool recursive, - const DeleteDataLakeDirectoryOptions& options = DeleteDataLakeDirectoryOptions()) const; + Azure::Core::Response DeleteEmpty( + const DeleteDataLakeDirectoryOptions& options = DeleteDataLakeDirectoryOptions()) const + { + return this->Delete(false, options); + } /** - * @brief Deletes the directory if it already exists. - * @param recursive If "true", all paths beneath the directory will be deleted. If "false" and - * the directory is non-empty, an error occurs. + * @brief Deletes the empty directory if it already exists. Throws exception if directory is not + * empty. * @param options Optional parameters to delete the directory the path points to. * @return Azure::Core::Response containing the information * returned when deleting the directory. * @remark This request is sent to dfs endpoint. */ - Azure::Core::Response DeleteIfExists( - bool recursive, - const DeleteDataLakeDirectoryOptions& options = DeleteDataLakeDirectoryOptions()) const; + Azure::Core::Response DeleteEmptyIfExists( + const DeleteDataLakeDirectoryOptions& options = DeleteDataLakeDirectoryOptions()) const + { + return this->DeleteIfExists(false, options); + } + + /** + * @brief Deletes the directory and all its subdirectories and files. + * @param options Optional parameters to delete the directory the path points to. + * @return Azure::Core::Response containing the information + * returned when deleting the directory. + * @remark This request is sent to dfs endpoint. + */ + Azure::Core::Response DeleteRecursive( + const DeleteDataLakeDirectoryOptions& options = DeleteDataLakeDirectoryOptions()) const + { + return this->Delete(true, options); + } + + /** + * @brief Deletes the directory and all its subdirectories and files if the directory exists. + * @param options Optional parameters to delete the directory the path points to. + * @return Azure::Core::Response containing the information + * returned when deleting the directory. + * @remark This request is sent to dfs endpoint. + */ + Azure::Core::Response DeleteRecursiveIfExists( + const DeleteDataLakeDirectoryOptions& options = DeleteDataLakeDirectoryOptions()) const + { + return this->DeleteIfExists(true, options); + } /** * @brief List the paths in this file system. @@ -193,6 +220,14 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { { } + Azure::Core::Response Delete( + bool recursive, + const DeleteDataLakeDirectoryOptions& options = DeleteDataLakeDirectoryOptions()) const; + + Azure::Core::Response DeleteIfExists( + bool recursive, + const DeleteDataLakeDirectoryOptions& options = DeleteDataLakeDirectoryOptions()) const; + friend class DataLakeFileSystemClient; }; }}}} // namespace Azure::Storage::Files::DataLake diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_client.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_client.hpp index 3f8e38c84..858fe063a 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_client.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_client.hpp @@ -252,6 +252,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { m_blockBlobClient(std::move(blockBlobClient)) { } + friend class DataLakeFileSystemClient; friend class DataLakeDirectoryClient; }; diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp index 55424b7db..db385d6fc 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp @@ -514,15 +514,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { */ Azure::Core::Context Context; - /** - * @brief When deleting a directory, the number of paths that are deleted with each invocation - * is limited. If the number of paths to be deleted exceeds this limit, a continuation - * token is returned in this response header. When a continuation token is returned in - * the response, it must be specified in a subsequent invocation of the delete operation - * to continue deleting the directory. - */ - Azure::Core::Nullable ContinuationToken; - /** * @brief Required and valid only when the resource is a directory. If "true", all paths beneath * the directory will be deleted. If "false" and the directory is non-empty, an error @@ -660,15 +651,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { */ Azure::Core::Context Context; - /** - * @brief When deleting a directory, the number of paths that are deleted with each invocation - * is limited. If the number of paths to be deleted exceeds this limit, a continuation - * token is returned in this response header. When a continuation token is returned in - * the response, it must be specified in a subsequent invocation of the delete operation - * to continue deleting the directory. - */ - Azure::Core::Nullable ContinuationToken; - /** * @brief Specify the access condition for the path. */ diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_responses.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_responses.hpp index b6110512f..39be8862d 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_responses.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_responses.hpp @@ -93,7 +93,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { nam struct DeleteDataLakePathResult { bool Deleted = true; - Azure::Core::Nullable ContinuationToken; std::string RequestId; }; diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_directory_client.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_directory_client.cpp index fbf27d73c..d69087051 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_directory_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_directory_client.cpp @@ -244,7 +244,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { DeleteDataLakePathOptions deleteOptions; deleteOptions.AccessConditions = options.AccessConditions; deleteOptions.Context = options.Context; - deleteOptions.ContinuationToken = options.ContinuationToken; deleteOptions.Recursive = recursive; return DataLakePathClient::Delete(deleteOptions); } @@ -255,7 +254,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { DeleteDataLakePathOptions deleteOptions; deleteOptions.AccessConditions = options.AccessConditions; deleteOptions.Context = options.Context; - deleteOptions.ContinuationToken = options.ContinuationToken; deleteOptions.Recursive = recursive; return DataLakePathClient::DeleteIfExists(deleteOptions); } diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_path_client.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_path_client.cpp index fa6d99f02..cd1e80369 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_path_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_path_client.cpp @@ -308,7 +308,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { const DeleteDataLakePathOptions& options) const { Details::DataLakeRestClient::Path::DeleteOptions protocolLayerOptions; - protocolLayerOptions.ContinuationToken = options.ContinuationToken; protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch; protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch; @@ -318,7 +317,6 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { auto result = Details::DataLakeRestClient::Path::Delete( m_dfsUrl, *m_pipeline, options.Context, protocolLayerOptions); Models::DeleteDataLakePathResult ret; - ret.ContinuationToken = std::move(result->ContinuationToken); ret.Deleted = true; ret.RequestId = std::move(result->RequestId); return Azure::Core::Response( diff --git a/sdk/storage/azure-storage-files-datalake/test/datalake_directory_client_test.cpp b/sdk/storage/azure-storage-files-datalake/test/datalake_directory_client_test.cpp index 4a1c94b15..8c9afac65 100644 --- a/sdk/storage/azure-storage-files-datalake/test/datalake_directory_client_test.cpp +++ b/sdk/storage/azure-storage-files-datalake/test/datalake_directory_client_test.cpp @@ -43,7 +43,7 @@ namespace Azure { namespace Storage { namespace Test { } for (const auto& client : directoryClient) { - EXPECT_NO_THROW(client.Delete(false)); + EXPECT_NO_THROW(client.DeleteEmpty()); } } { @@ -61,10 +61,10 @@ namespace Azure { namespace Storage { namespace Test { Files::DataLake::DeleteDataLakeDirectoryOptions options1; options1.AccessConditions.IfModifiedSince = response->LastModified; EXPECT_TRUE(IsValidTime(response->LastModified)); - EXPECT_THROW(client.Delete(false, options1), StorageException); + EXPECT_THROW(client.DeleteEmpty(options1), StorageException); Files::DataLake::DeleteDataLakeDirectoryOptions options2; options2.AccessConditions.IfUnmodifiedSince = response->LastModified; - EXPECT_NO_THROW(client.Delete(false, options2)); + EXPECT_NO_THROW(client.DeleteEmpty(options2)); } } { @@ -81,10 +81,10 @@ namespace Azure { namespace Storage { namespace Test { auto response = client.GetProperties(); Files::DataLake::DeleteDataLakeDirectoryOptions options1; options1.AccessConditions.IfNoneMatch = response->ETag; - EXPECT_THROW(client.Delete(false, options1), StorageException); + EXPECT_THROW(client.DeleteEmpty(options1), StorageException); Files::DataLake::DeleteDataLakeDirectoryOptions options2; options2.AccessConditions.IfMatch = response->ETag; - EXPECT_NO_THROW(client.Delete(false, options2)); + EXPECT_NO_THROW(client.DeleteEmpty(options2)); } } @@ -100,8 +100,8 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_NO_THROW(client.Create()); directoryClient.emplace_back(std::move(client)); } - EXPECT_THROW(rootDirClient.Delete(false), StorageException); - EXPECT_NO_THROW(rootDirClient.Delete(true)); + EXPECT_THROW(rootDirClient.DeleteEmpty(), StorageException); + EXPECT_NO_THROW(rootDirClient.DeleteRecursive()); } } @@ -115,16 +115,16 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_TRUE(created); EXPECT_NO_THROW(created = client.CreateIfNotExists()->Created); EXPECT_FALSE(created); - EXPECT_NO_THROW(deleted = client.Delete(false)->Deleted); + EXPECT_NO_THROW(deleted = client.DeleteEmpty()->Deleted); EXPECT_TRUE(deleted); - EXPECT_NO_THROW(deleted = client.DeleteIfExists(false)->Deleted); + EXPECT_NO_THROW(deleted = client.DeleteEmptyIfExists()->Deleted); EXPECT_FALSE(deleted); } { auto client = Files::DataLake::DataLakeDirectoryClient::CreateFromConnectionString( AdlsGen2ConnectionString(), LowercaseRandomString(), RandomString()); bool deleted = false; - EXPECT_NO_THROW(deleted = client.DeleteIfExists(false)->Deleted); + EXPECT_NO_THROW(deleted = client.DeleteEmptyIfExists()->Deleted); EXPECT_FALSE(deleted); } } @@ -149,11 +149,11 @@ namespace Azure { namespace Storage { namespace Test { } for (const auto& client : directoryClients) { - EXPECT_THROW(client.Delete(false), StorageException); + EXPECT_THROW(client.DeleteEmpty(), StorageException); } for (const auto& client : newDirectoryClients) { - EXPECT_NO_THROW(client.Delete(false)); + EXPECT_NO_THROW(client.DeleteEmpty()); } } { @@ -176,7 +176,7 @@ namespace Azure { namespace Storage { namespace Test { options2.SourceAccessConditions.IfUnmodifiedSince = response->LastModified; auto newPath = RandomString(); EXPECT_NO_THROW( - client.RenameSubdirectory("", newPath, options2).ExtractValue().Delete(false)); + client.RenameSubdirectory("", newPath, options2).ExtractValue().DeleteEmpty()); } } { @@ -198,7 +198,7 @@ namespace Azure { namespace Storage { namespace Test { options2.SourceAccessConditions.IfMatch = response->ETag; auto newPath = RandomString(); EXPECT_NO_THROW( - client.RenameSubdirectory("", newPath, options2).ExtractValue().Delete(false)); + client.RenameSubdirectory("", newPath, options2).ExtractValue().DeleteEmpty()); } } { @@ -233,7 +233,7 @@ namespace Azure { namespace Storage { namespace Test { { auto newPath = RandomString(); EXPECT_NO_THROW( - client.RenameSubdirectory("", newPath, options).ExtractValue().Delete(false)); + client.RenameSubdirectory("", newPath, options).ExtractValue().DeleteEmpty()); } } } @@ -321,7 +321,7 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_EQ(httpHeader.ContentDisposition, result->HttpHeaders.ContentDisposition); EXPECT_EQ(httpHeader.ContentLanguage, result->HttpHeaders.ContentLanguage); EXPECT_EQ(httpHeader.ContentType, result->HttpHeaders.ContentType); - EXPECT_NO_THROW(client.Delete(false)); + EXPECT_NO_THROW(client.DeleteEmpty()); } } } @@ -604,7 +604,7 @@ namespace Azure { namespace Storage { namespace Test { = Azure::Storage::Files::DataLake::DataLakeDirectoryClient::CreateFromConnectionString( AdlsGen2ConnectionString(), m_fileSystemName, directoryName); EXPECT_NO_THROW(connectionStringClient.Create()); - EXPECT_NO_THROW(connectionStringClient.Delete(true)); + EXPECT_NO_THROW(connectionStringClient.DeleteRecursive()); } { @@ -619,7 +619,7 @@ namespace Azure { namespace Storage { namespace Test { credential); EXPECT_NO_THROW(clientSecretClient.Create()); - EXPECT_NO_THROW(clientSecretClient.Delete(true)); + EXPECT_NO_THROW(clientSecretClient.DeleteRecursive()); } {