Skip to content

feat(storage): add deleteFolderRecursive sample - #14305

Closed
nidhiii-27 wants to merge 31 commits into
mainfrom
feat/add-delete-folder-recursive
Closed

feat(storage): add deleteFolderRecursive sample#14305
nidhiii-27 wants to merge 31 commits into
mainfrom
feat/add-delete-folder-recursive

Conversation

@nidhiii-27

Copy link
Copy Markdown
Contributor

feat(python): add deleteFolderRecursive sample

This adds a sample demonstrating how to recursively delete a folder in a hierarchical namespace bucket.

Fixes: b/521168740

[Generated-by: AI]

This adds a sample demonstrating how to recursively delete a folder in a hierarchical namespace bucket.

Fixes: b/521168740

[Generated-by: AI]
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Jun 11, 2026
@nidhiii-27 nidhiii-27 added ai-generated storage-sample-architect and removed samples Issues that are directly related to samples. labels Jun 11, 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 script delete_folder_recursive.py that implements recursive folder deletion using the Google Cloud Storage Control API, along with corresponding integration tests in snippets_test.py. The feedback recommends moving the inline import of delete_folder_recursive in the test file to the top of the file to adhere to PEP 8 guidelines.

Comment thread storagecontrol/snippets_test.py Outdated
def test_delete_folder_recursive(
capsys: pytest.LogCaptureFixture, hns_enabled_bucket: storage.Bucket, uuid_name: str
) -> None:
import delete_folder_recursive

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 PEP 8, imports should always be placed at the top of the file, just after any module comments and docstrings, and before module globals and constants.

Please move import delete_folder_recursive to the top of the file, grouping it alphabetically with the other local imports (e.g., right after import delete_folder on line 20).

References
  1. PEP 8 specifies that imports should always be put at the top of the file, grouped and ordered. (link)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Jun 12, 2026
@nidhiii-27 nidhiii-27 changed the title feat(python): add deleteFolderRecursive sample feat(storage): add deleteFolderRecursive sample Jun 26, 2026


if __name__ == "__main__":
delete_folder_recursive(bucket_name=sys.argv[1], folder_name=sys.argv[2])

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.

what if user doesn't provide 2nd argument ? (which might happen due to many reasons) ,

What is the behavior of storage_control_client.delete_folder_recursive

@nidhiii-27 nidhiii-27 Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Firstly, if user doesn't provide the folder_name, the program will throw an Index error.
Regarding the behavior of storage_control_client.delete_folder_recursive: the folder resource path is constructed as projects/_/buckets/{bucket_name}/folders/{folder_name}. If the folder name is empty, the API call fails with a validation error on the resource path and does not perform any deletion. If the bucket doesn't support hierarchical namespaces or if the folder does not exist, the API will fail with a 404 Not Found or 400 Bad Request error.

Co-authored by AI Agent

@nidhiii-27
nidhiii-27 marked this pull request as ready for review July 2, 2026 07:20
@nidhiii-27
nidhiii-27 requested review from a team as code owners July 2, 2026 07:20
@snippet-bot

snippet-bot Bot commented Jul 2, 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

@nidhiii-27
nidhiii-27 requested review from a team as code owners July 5, 2026 13:46
@nidhiii-27 nidhiii-27 closed this Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated samples Issues that are directly related to samples. storage-sample-architect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants