Skip to content

Commit 0426005

Browse files
authored
feat: Retry by default for uploads, blob deletes, metadata updates (#1400)
1 parent 0c21210 commit 0426005

12 files changed

+449
-126
lines changed

google/cloud/storage/_helpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def patch(
339339
if_metageneration_match=None,
340340
if_metageneration_not_match=None,
341341
timeout=_DEFAULT_TIMEOUT,
342-
retry=DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED,
342+
retry=DEFAULT_RETRY,
343343
override_unlocked_retention=False,
344344
):
345345
"""Sends all changed properties in a PATCH request.

google/cloud/storage/acl.py

+182
Original file line numberDiff line numberDiff line change
@@ -752,3 +752,185 @@ def save_path(self):
752752
def user_project(self):
753753
"""Compute the user project charged for API requests for this ACL."""
754754
return self.blob.user_project
755+
756+
def save(
757+
self,
758+
acl=None,
759+
client=None,
760+
if_generation_match=None,
761+
if_generation_not_match=None,
762+
if_metageneration_match=None,
763+
if_metageneration_not_match=None,
764+
timeout=_DEFAULT_TIMEOUT,
765+
retry=DEFAULT_RETRY,
766+
):
767+
"""Save this ACL for the current object.
768+
769+
If :attr:`user_project` is set, bills the API request to that project.
770+
771+
:type acl: :class:`google.cloud.storage.acl.ACL`, or a compatible list.
772+
:param acl: The ACL object to save. If left blank, this will save
773+
current entries.
774+
775+
:type client: :class:`~google.cloud.storage.client.Client` or
776+
``NoneType``
777+
:param client: (Optional) The client to use. If not passed, falls back
778+
to the ``client`` stored on the ACL's parent.
779+
780+
:type if_generation_match: long
781+
:param if_generation_match:
782+
(Optional) See :ref:`using-if-generation-match`
783+
784+
:type if_generation_not_match: long
785+
:param if_generation_not_match:
786+
(Optional) See :ref:`using-if-generation-not-match`
787+
788+
:type if_metageneration_match: long
789+
:param if_metageneration_match:
790+
(Optional) See :ref:`using-if-metageneration-match`
791+
792+
:type if_metageneration_not_match: long
793+
:param if_metageneration_not_match:
794+
(Optional) See :ref:`using-if-metageneration-not-match`
795+
796+
:type timeout: float or tuple
797+
:param timeout:
798+
(Optional) The amount of time, in seconds, to wait
799+
for the server response. See: :ref:`configuring_timeouts`
800+
801+
:type retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
802+
:param retry:
803+
(Optional) How to retry the RPC. See: :ref:`configuring_retries`
804+
"""
805+
super().save(
806+
acl=acl,
807+
client=client,
808+
if_generation_match=if_generation_match,
809+
if_generation_not_match=if_generation_not_match,
810+
if_metageneration_match=if_metageneration_match,
811+
if_metageneration_not_match=if_metageneration_not_match,
812+
timeout=timeout,
813+
retry=retry,
814+
)
815+
816+
def save_predefined(
817+
self,
818+
predefined,
819+
client=None,
820+
if_generation_match=None,
821+
if_generation_not_match=None,
822+
if_metageneration_match=None,
823+
if_metageneration_not_match=None,
824+
timeout=_DEFAULT_TIMEOUT,
825+
retry=DEFAULT_RETRY,
826+
):
827+
"""Save this ACL for the current object using a predefined ACL.
828+
829+
If :attr:`user_project` is set, bills the API request to that project.
830+
831+
:type predefined: str
832+
:param predefined: An identifier for a predefined ACL. Must be one
833+
of the keys in :attr:`PREDEFINED_JSON_ACLS`
834+
or :attr:`PREDEFINED_XML_ACLS` (which will be
835+
aliased to the corresponding JSON name).
836+
If passed, `acl` must be None.
837+
838+
:type client: :class:`~google.cloud.storage.client.Client` or
839+
``NoneType``
840+
:param client: (Optional) The client to use. If not passed, falls back
841+
to the ``client`` stored on the ACL's parent.
842+
843+
:type if_generation_match: long
844+
:param if_generation_match:
845+
(Optional) See :ref:`using-if-generation-match`
846+
847+
:type if_generation_not_match: long
848+
:param if_generation_not_match:
849+
(Optional) See :ref:`using-if-generation-not-match`
850+
851+
:type if_metageneration_match: long
852+
:param if_metageneration_match:
853+
(Optional) See :ref:`using-if-metageneration-match`
854+
855+
:type if_metageneration_not_match: long
856+
:param if_metageneration_not_match:
857+
(Optional) See :ref:`using-if-metageneration-not-match`
858+
859+
:type timeout: float or tuple
860+
:param timeout:
861+
(Optional) The amount of time, in seconds, to wait
862+
for the server response. See: :ref:`configuring_timeouts`
863+
864+
:type retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
865+
:param retry:
866+
(Optional) How to retry the RPC. See: :ref:`configuring_retries`
867+
"""
868+
super().save_predefined(
869+
predefined=predefined,
870+
client=client,
871+
if_generation_match=if_generation_match,
872+
if_generation_not_match=if_generation_not_match,
873+
if_metageneration_match=if_metageneration_match,
874+
if_metageneration_not_match=if_metageneration_not_match,
875+
timeout=timeout,
876+
retry=retry,
877+
)
878+
879+
def clear(
880+
self,
881+
client=None,
882+
if_generation_match=None,
883+
if_generation_not_match=None,
884+
if_metageneration_match=None,
885+
if_metageneration_not_match=None,
886+
timeout=_DEFAULT_TIMEOUT,
887+
retry=DEFAULT_RETRY,
888+
):
889+
"""Remove all ACL entries.
890+
891+
If :attr:`user_project` is set, bills the API request to that project.
892+
893+
Note that this won't actually remove *ALL* the rules, but it
894+
will remove all the non-default rules. In short, you'll still
895+
have access to a bucket that you created even after you clear
896+
ACL rules with this method.
897+
898+
:type client: :class:`~google.cloud.storage.client.Client` or
899+
``NoneType``
900+
:param client: (Optional) The client to use. If not passed, falls back
901+
to the ``client`` stored on the ACL's parent.
902+
903+
:type if_generation_match: long
904+
:param if_generation_match:
905+
(Optional) See :ref:`using-if-generation-match`
906+
907+
:type if_generation_not_match: long
908+
:param if_generation_not_match:
909+
(Optional) See :ref:`using-if-generation-not-match`
910+
911+
:type if_metageneration_match: long
912+
:param if_metageneration_match:
913+
(Optional) See :ref:`using-if-metageneration-match`
914+
915+
:type if_metageneration_not_match: long
916+
:param if_metageneration_not_match:
917+
(Optional) See :ref:`using-if-metageneration-not-match`
918+
919+
:type timeout: float or tuple
920+
:param timeout:
921+
(Optional) The amount of time, in seconds, to wait
922+
for the server response. See: :ref:`configuring_timeouts`
923+
924+
:type retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
925+
:param retry:
926+
(Optional) How to retry the RPC. See: :ref:`configuring_retries`
927+
"""
928+
super().clear(
929+
client=client,
930+
if_generation_match=if_generation_match,
931+
if_generation_not_match=if_generation_not_match,
932+
if_metageneration_match=if_metageneration_match,
933+
if_metageneration_not_match=if_metageneration_not_match,
934+
timeout=timeout,
935+
retry=retry,
936+
)

0 commit comments

Comments
 (0)