@@ -575,7 +575,7 @@ def delete(self, force=False, client=None):
575575 query_params = query_params ,
576576 _target_object = None )
577577
578- def delete_blob (self , blob_name , client = None ):
578+ def delete_blob (self , blob_name , client = None , generation = None ):
579579 """Deletes a blob from the current bucket.
580580
581581 If the blob isn't found (backend 404), raises a
@@ -597,6 +597,11 @@ def delete_blob(self, blob_name, client=None):
597597 :param client: Optional. The client to use. If not passed, falls back
598598 to the ``client`` stored on the current bucket.
599599
600+ :type generation: :class:`~google.cloud.storage.client.Client` or
601+ ``NoneType``
602+ :param generation: Optional. The generation of the blob to delete. If
603+ not passed, deletes the current version.
604+
600605 :raises: :class:`google.cloud.exceptions.NotFound` (to suppress
601606 the exception, call ``delete_blobs``, passing a no-op
602607 ``on_error`` callback, e.g.:
@@ -616,11 +621,18 @@ def delete_blob(self, blob_name, client=None):
616621 # We intentionally pass `_target_object=None` since a DELETE
617622 # request has no response value (whether in a standard request or
618623 # in a batch request).
619- client ._connection .api_request (
620- method = 'DELETE' ,
621- path = blob_path ,
622- query_params = query_params ,
623- _target_object = None )
624+ if not generation :
625+ client ._connection .api_request (
626+ method = 'DELETE' ,
627+ path = blob_path ,
628+ query_params = query_params ,
629+ _target_object = None )
630+ else :
631+ client ._connection .api_request (
632+ method = 'DELETE' ,
633+ path = blob_path + '?generation={}' .format (generation ),
634+ query_params = query_params ,
635+ _target_object = None )
624636
625637 def delete_blobs (self , blobs , on_error = None , client = None ):
626638 """Deletes a list of blobs from the current bucket.
0 commit comments