@@ -1666,7 +1666,21 @@ def copy_blob(
16661666 new_blob ._set_properties (copy_result )
16671667 return new_blob
16681668
1669- def rename_blob (self , blob , new_name , client = None , timeout = _DEFAULT_TIMEOUT ):
1669+ def rename_blob (
1670+ self ,
1671+ blob ,
1672+ new_name ,
1673+ client = None ,
1674+ timeout = _DEFAULT_TIMEOUT ,
1675+ if_generation_match = None ,
1676+ if_generation_not_match = None ,
1677+ if_metageneration_match = None ,
1678+ if_metageneration_not_match = None ,
1679+ if_source_generation_match = None ,
1680+ if_source_generation_not_match = None ,
1681+ if_source_metageneration_match = None ,
1682+ if_source_metageneration_not_match = None ,
1683+ ):
16701684 """Rename the given blob using copy and delete operations.
16711685
16721686 If :attr:`user_project` is set, bills the API request to that project.
@@ -1699,16 +1713,93 @@ def rename_blob(self, blob, new_name, client=None, timeout=_DEFAULT_TIMEOUT):
16991713 Can also be passed as a tuple (connect_timeout, read_timeout).
17001714 See :meth:`requests.Session.request` documentation for details.
17011715
1716+ :type if_generation_match: long
1717+ :param if_generation_match: (Optional) Makes the operation
1718+ conditional on whether the destination
1719+ object's current generation matches the
1720+ given value. Setting to 0 makes the
1721+ operation succeed only if there are no
1722+ live versions of the object.
1723+
1724+ :type if_generation_not_match: long
1725+ :param if_generation_not_match: (Optional) Makes the operation
1726+ conditional on whether the
1727+ destination object's current
1728+ generation does not match the given
1729+ value. If no live object exists,
1730+ the precondition fails. Setting to
1731+ 0 makes the operation succeed only
1732+ if there is a live version
1733+ of the object.
1734+
1735+ :type if_metageneration_match: long
1736+ :param if_metageneration_match: (Optional) Makes the operation
1737+ conditional on whether the
1738+ destination object's current
1739+ metageneration matches the given
1740+ value.
1741+
1742+ :type if_metageneration_not_match: long
1743+ :param if_metageneration_not_match: (Optional) Makes the operation
1744+ conditional on whether the
1745+ destination object's current
1746+ metageneration does not match
1747+ the given value.
1748+
1749+ :type if_source_generation_match: long
1750+ :param if_source_generation_match: (Optional) Makes the operation
1751+ conditional on whether the source
1752+ object's generation matches the
1753+ given value.
1754+
1755+ :type if_source_generation_not_match: long
1756+ :param if_source_generation_not_match: (Optional) Makes the operation
1757+ conditional on whether the source
1758+ object's generation does not match
1759+ the given value.
1760+
1761+ :type if_source_metageneration_match: long
1762+ :param if_source_metageneration_match: (Optional) Makes the operation
1763+ conditional on whether the source
1764+ object's current metageneration
1765+ matches the given value.
1766+
1767+ :type if_source_metageneration_not_match: long
1768+ :param if_source_metageneration_not_match: (Optional) Makes the operation
1769+ conditional on whether the source
1770+ object's current metageneration
1771+ does not match the given value.
1772+
17021773 :rtype: :class:`Blob`
17031774 :returns: The newly-renamed blob.
17041775 """
17051776 same_name = blob .name == new_name
17061777
1707- new_blob = self .copy_blob (blob , self , new_name , client = client , timeout = timeout )
1778+ new_blob = self .copy_blob (
1779+ blob ,
1780+ self ,
1781+ new_name ,
1782+ client = client ,
1783+ timeout = timeout ,
1784+ if_generation_match = if_generation_match ,
1785+ if_generation_not_match = if_generation_not_match ,
1786+ if_metageneration_match = if_metageneration_match ,
1787+ if_metageneration_not_match = if_metageneration_not_match ,
1788+ if_source_generation_match = if_source_generation_match ,
1789+ if_source_generation_not_match = if_source_generation_not_match ,
1790+ if_source_metageneration_match = if_source_metageneration_match ,
1791+ if_source_metageneration_not_match = if_source_metageneration_not_match ,
1792+ )
17081793
17091794 if not same_name :
1710- blob .delete (client = client , timeout = timeout )
1711-
1795+ blob .delete (
1796+ client = client ,
1797+ timeout = timeout ,
1798+ if_generation_match = if_generation_match ,
1799+ if_generation_not_match = if_generation_not_match ,
1800+ if_metageneration_match = if_metageneration_match ,
1801+ if_metageneration_not_match = if_metageneration_not_match ,
1802+ )
17121803 return new_blob
17131804
17141805 @property
0 commit comments