in incubator-tools/Reference_architecture_asynchronous/auto_deploy_v8/CFScript/main.py [0:0]
def delete_blob(bucket_name: str, blob_name: str) -> None:
"""
Deletes specified blob name from Google Cloud Storage bucket.
Args:
bucket_name (str): The name of the bucket.
blob_name (str): The name of the blob inside the bucket.
Returns:
None. If the blob exists, it will be deleted. If it doesn't exist or an error occurs,
the function will log the error. This example catches ValueError and TypeError as
placeholders for more specific exceptions you might want to handle.
"""
print("delete_blob")
storage_client_db = storage.Client()
bucket_db = storage_client_db.bucket(bucket_name)
blob_db = bucket_db.blob(blob_name)
try:
# Example operation that could, in theory, raise a ValueError or TypeError
if not isinstance(bucket_name, str) or not isinstance(blob_name, str):
raise ValueError("Bucket name and blob name must be strings.")
if bucket_name is None or blob_name is None:
raise TypeError("Bucket name and blob name cannot be None.")
blob_db.delete()
except ValueError as ve:
print(f"ValueError occurred: {ve}")
except TypeError as te:
print(f"TypeError occurred: {te}")