Skip to content

Commit

Permalink
Adding deleteRecursivelyWithResponse for DataLakeDirectoryClient (#36726
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ibrahimrabab authored Sep 12, 2023
1 parent f4c38bb commit 63b3ac7
Show file tree
Hide file tree
Showing 6 changed files with 326 additions and 127 deletions.
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-file-datalake/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/storage/azure-storage-file-datalake",
"Tag": "java/storage/azure-storage-file-datalake_4452271412"
"Tag": "java/storage/azure-storage-file-datalake_ed7708ef7d"
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,40 @@ public Mono<Void> delete() {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> deleteRecursively() {
return deleteWithResponse(true, null).flatMap(FluxUtil::toMono);
return deleteRecursivelyWithResponse(null).flatMap(FluxUtil::toMono);
}

/**
* Recursively deletes a directory and all contents within the directory.
*
* <p><strong>Code Samples</strong></p>
*
* <!-- src_embed com.azure.storage.file.datalake.DataLakeDirectoryAsyncClient.deleteWithResponse#boolean-DataLakeRequestConditions -->
* <pre>
* DataLakeRequestConditions requestConditions = new DataLakeRequestConditions&#40;&#41;
* .setLeaseId&#40;leaseId&#41;;
* boolean recursive = false; &#47;&#47; Default value
*
* client.deleteWithResponse&#40;recursive, requestConditions&#41;
* .subscribe&#40;response -&gt; System.out.println&#40;&quot;Delete request completed&quot;&#41;&#41;;
* </pre>
* <!-- end com.azure.storage.file.datalake.DataLakeDirectoryAsyncClient.deleteWithResponse#boolean-DataLakeRequestConditions -->
*
* <p>For more information see the
* <a href="https://docs.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/delete">Azure
* Docs</a></p>
*
* @param requestConditions {@link DataLakeRequestConditions}
*
* @return A reactive response signalling completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> deleteRecursivelyWithResponse(DataLakeRequestConditions requestConditions) {
try {
return withContext(context -> deleteWithResponse(true, requestConditions, context));
} catch (RuntimeException ex) {
return monoError(LOGGER, ex);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,37 @@ public void delete() {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void deleteRecursively() {
deleteWithResponse(true, null, null, Context.NONE).getValue();
deleteRecursivelyWithResponse(null, null, Context.NONE).getValue();
}

/**
* Recursively deletes a directory and all contents within the directory.
*
* <p><strong>Code Samples</strong></p>
*
* <!-- src_embed com.azure.storage.file.datalake.DataLakeDirectoryClient.deleteRecursivelyWithResponse#DataLakeRequestConditions-Duration-Context -->
* <pre>
* DataLakeRequestConditions deleteRequestConditions = new DataLakeRequestConditions&#40;&#41;
* .setLeaseId&#40;leaseId&#41;;
* client.deleteRecursivelyWithResponse&#40;deleteRequestConditions, timeout, new Context&#40;key1, value1&#41;&#41;;
* System.out.println&#40;&quot;Delete request completed&quot;&#41;;
* </pre>
* <!-- end com.azure.storage.file.datalake.DataLakeDirectoryClient.deleteRecursivelyWithResponse#DataLakeRequestConditions-Duration-Context -->
*
* <p>For more information see the
* <a href="https://docs.microsoft.com/rest/api/storageservices/datalakestoragegen2/path/delete">Azure
* Docs</a></p>
*
* @param requestConditions {@link DataLakeRequestConditions}
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
* @param context Additional context that is passed through the Http pipeline during the service call.
*
* @return A reactive response signalling completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> deleteRecursivelyWithResponse(DataLakeRequestConditions requestConditions, Duration timeout,
Context context) {
return deleteWithResponse(true, requestConditions, timeout, context);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ public void getFileClient() {

/**
* Code snippets for {@link DataLakeDirectoryAsyncClient#delete()},
* {@link DataLakeDirectoryAsyncClient#deleteWithResponse(boolean, DataLakeRequestConditions)} and
* {@link DataLakeDirectoryAsyncClient#deleteRecursively()}
* {@link DataLakeDirectoryAsyncClient#deleteWithResponse(boolean, DataLakeRequestConditions)},
* {@link DataLakeDirectoryAsyncClient#deleteRecursively()} and
* {@link DataLakeDirectoryAsyncClient#deleteRecursivelyWithResponse(DataLakeRequestConditions)}
*/
public void deleteCodeSnippets() {
// BEGIN: com.azure.storage.file.datalake.DataLakeDirectoryAsyncClient.delete
Expand All @@ -68,6 +69,13 @@ public void deleteCodeSnippets() {
client.deleteRecursively().subscribe(response ->
System.out.println("Delete request completed"));
// END: com.azure.storage.file.datalake.DataLakeDirectoryAsyncClient.deleteRecursively

// BEGIN: com.azure.storage.file.datalake.DataLakeDirectoryAsyncClient.deleteRecursivelyWithResponse#DataLakeRequestConditions
DataLakeRequestConditions deleteRequestConditions = new DataLakeRequestConditions()
.setLeaseId(leaseId);
client.deleteRecursivelyWithResponse(deleteRequestConditions)
.subscribe(response -> System.out.println("Delete request completed"));
// END: com.azure.storage.file.datalake.DataLakeDirectoryAsyncClient.deleteRecursivelyWithResponse#DataLakeRequestConditions
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ public void getFileClient() {

/**
* Code snippets for {@link DataLakeDirectoryClient#delete()},
* {@link DataLakeDirectoryClient#deleteWithResponse(boolean, DataLakeRequestConditions, Duration, Context)} and
* {@link DataLakeDirectoryClient#deleteRecursively()}
* {@link DataLakeDirectoryClient#deleteWithResponse(boolean, DataLakeRequestConditions, Duration, Context)},
* {@link DataLakeDirectoryClient#deleteRecursively()} and
* {@link DataLakeDirectoryClient#deleteRecursivelyWithResponse(DataLakeRequestConditions, Duration, Context)
*/
public void deleteCodeSnippets() {
// BEGIN: com.azure.storage.file.datalake.DataLakeDirectoryClient.delete
Expand All @@ -72,6 +73,13 @@ public void deleteCodeSnippets() {
client.deleteRecursively();
System.out.println("Delete request completed");
// END: com.azure.storage.file.datalake.DataLakeDirectoryClient.deleteRecursively

// BEGIN: com.azure.storage.file.datalake.DataLakeDirectoryClient.deleteRecursivelyWithResponse#DataLakeRequestConditions-Duration-Context
DataLakeRequestConditions deleteRequestConditions = new DataLakeRequestConditions()
.setLeaseId(leaseId);
client.deleteRecursivelyWithResponse(deleteRequestConditions, timeout, new Context(key1, value1));
System.out.println("Delete request completed");
// END: com.azure.storage.file.datalake.DataLakeDirectoryClient.deleteRecursivelyWithResponse#DataLakeRequestConditions-Duration-Context
}

/**
Expand Down
Loading

0 comments on commit 63b3ac7

Please sign in to comment.