Skip to content

samples(storagecontrol): add delete folder recursive sample#15658

Closed
nidhiii-27 wants to merge 1 commit into
mainfrom
add-delete-folder-recursive-sample
Closed

samples(storagecontrol): add delete folder recursive sample#15658
nidhiii-27 wants to merge 1 commit into
mainfrom
add-delete-folder-recursive-sample

Conversation

@nidhiii-27

Copy link
Copy Markdown

This PR adds the SDK sample and tests for the hierarchical namespace recursive delete feature, resolving b/521168740.

@nidhiii-27 nidhiii-27 requested review from a team as code owners June 10, 2026 08:52
@snippet-bot

snippet-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Jun 10, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new sample and corresponding test for recursively deleting folders using the StorageControlClient. The review feedback suggests improving the sample by using the strongly-typed FolderName class instead of manual string formatting, and enhancing the test assertions to verify the exception message in addition to the status code.

Comment on lines +27 to +30
// Format: projects/{project}/buckets/{bucket}/folders/{folder}
string folderResourceName = $"projects/_/buckets/{bucketName}/folders/{folderName}";

storageControlClient.DeleteFolderRecursive(folderResourceName).PollUntilCompleted();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To align with the project's use of strongly-typed resource names (like BucketName), consider using FolderName instead of manually formatting the resource name string. This reduces the risk of formatting errors and makes the code cleaner.

            FolderName folderResourceName = FolderName.FromProjectBucketFolder("_", bucketName, folderName);

            storageControlClient.DeleteFolderRecursive(folderResourceName).PollUntilCompleted();

Comment on lines +66 to +68
var ex = Assert.Throws<Grpc.Core.RpcException>(() =>
storageControlClient.GetFolder(new GetFolderRequest { Name = folder.Name }));
Assert.Equal(Grpc.Core.StatusCode.NotFound, ex.StatusCode);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the repository's general rules, when asserting that an exception is thrown in a test, we should also assert on the exception message to ensure the correct exception is being propagated.

                var ex = Assert.Throws<Grpc.Core.RpcException>(() => 
                    storageControlClient.GetFolder(new GetFolderRequest { Name = folder.Name }));
                Assert.Equal(Grpc.Core.StatusCode.NotFound, ex.StatusCode);
                Assert.Contains("not found", ex.Message, StringComparison.OrdinalIgnoreCase);
References
  1. When asserting that an exception is thrown in a test, also assert on the exception message to ensure the correct exception is being propagated.

@github-actions

Copy link
Copy Markdown

Pull request diff results
Finding changes in Google.Cloud.Storage.Control.V2...
Comparing old and new versions (by source)
Diff level: Identical

Comparing with previous NuGet package
Checking compatibility for Google.Cloud.Storage.Control.V2 version 1.8.0
Differences from 1.8.0
Diff level: Identical

Finished comparisons for Google.Cloud.Storage.Control.V2

@amanda-tarafa amanda-tarafa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project where you have added these samples contains generated code only. It will be deleted and re-generated the next time the API changes.

Handwritten simples go in https://github.com/GoogleCloudPlatform/dotnet-docs-samples.

@amanda-tarafa amanda-tarafa added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jun 10, 2026
@amanda-tarafa

Copy link
Copy Markdown
Contributor

I will be closing this PR now, because it cannot be merged on this repo. Thanks.

@amanda-tarafa amanda-tarafa deleted the add-delete-folder-recursive-sample branch June 10, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge Indicates a pull request not ready for merge, due to either quality or timing. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants