Created
June 4, 2024 13:55
-
-
Save Intelrunner/acf2e3f8355ac49245c0a92227a1c882 to your computer and use it in GitHub Desktop.
Update all buckets in project to X soft_delete_duration (Google Cloud)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.cloud import storage | |
import os | |
def update_soft_delete(): | |
"""Lists all buckets in a project.""" | |
storage_client = storage.Client() | |
buckets = storage_client.list_buckets() | |
for bucket in buckets: | |
print ("****************") | |
print(f"OLD Soft delete duration of {bucket.name} is {bucket.soft_delete_policy.retention_duration_seconds}") | |
print("_____________") | |
bucket.soft_delete_policy.retention_duration_seconds = 604800 | |
print(f"Soft delete duration of {bucket.name} is {bucket.soft_delete_policy.retention_duration_seconds}") | |
bucket.update() | |
print("****************") | |
update_soft_delete() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment