Skip to content

Commit

Permalink
feat: make retry parameter public and added in other methods (googlea…
Browse files Browse the repository at this point in the history
…pis#331)

* feat: make retry parameter public and added in other methods

* feat: change in doc string

* feat: changes in docstring

* feat: remove retry for acl
  • Loading branch information
HemangChothani authored and cojenco committed Oct 13, 2021
1 parent 56695ce commit 98bd78a
Show file tree
Hide file tree
Showing 11 changed files with 866 additions and 67 deletions.
51 changes: 48 additions & 3 deletions google/cloud/storage/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def reload(
if_generation_not_match=None,
if_metageneration_match=None,
if_metageneration_not_match=None,
retry=DEFAULT_RETRY,
):
"""Reload properties from Cloud Storage.
Expand Down Expand Up @@ -187,6 +188,20 @@ def reload(
:type if_metageneration_not_match: long
:param if_metageneration_not_match: (Optional) Make the operation conditional on whether the
blob's current metageneration does not match the given value.
:type retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
:param retry: (Optional) How to retry the RPC. A None value will disable retries.
A google.api_core.retry.Retry value will enable retries, and the object will
define retriable response codes and errors and configure backoff and timeout options.
A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and
activates it only if certain conditions are met. This class exists to provide safe defaults
for RPC calls that are not technically safe to retry normally (due to potential data
duplication or other side-effects) but become safe to retry if a condition such as
if_metageneration_match is set.
See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for
information on retry types and how to configure them.
"""
client = self._require_client(client)
query_params = self._query_params
Expand All @@ -207,7 +222,7 @@ def reload(
headers=self._encryption_headers(),
_target_object=self,
timeout=timeout,
retry=DEFAULT_RETRY,
retry=retry,
)
self._set_properties(api_response)

Expand Down Expand Up @@ -247,6 +262,7 @@ def patch(
if_generation_not_match=None,
if_metageneration_match=None,
if_metageneration_not_match=None,
retry=DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED,
):
"""Sends all changed properties in a PATCH request.
Expand Down Expand Up @@ -286,6 +302,20 @@ def patch(
:type if_metageneration_not_match: long
:param if_metageneration_not_match: (Optional) Make the operation conditional on whether the
blob's current metageneration does not match the given value.
:type retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
:param retry: (Optional) How to retry the RPC. A None value will disable retries.
A google.api_core.retry.Retry value will enable retries, and the object will
define retriable response codes and errors and configure backoff and timeout options.
A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and
activates it only if certain conditions are met. This class exists to provide safe defaults
for RPC calls that are not technically safe to retry normally (due to potential data
duplication or other side-effects) but become safe to retry if a condition such as
if_metageneration_match is set.
See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for
information on retry types and how to configure them.
"""
client = self._require_client(client)
query_params = self._query_params
Expand All @@ -309,7 +339,7 @@ def patch(
query_params=query_params,
_target_object=self,
timeout=timeout,
retry=DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED,
retry=retry,
)
self._set_properties(api_response)

Expand All @@ -321,6 +351,7 @@ def update(
if_generation_not_match=None,
if_metageneration_match=None,
if_metageneration_not_match=None,
retry=DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED,
):
"""Sends all properties in a PUT request.
Expand Down Expand Up @@ -360,6 +391,20 @@ def update(
:type if_metageneration_not_match: long
:param if_metageneration_not_match: (Optional) Make the operation conditional on whether the
blob's current metageneration does not match the given value.
:type retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
:param retry: (Optional) How to retry the RPC. A None value will disable retries.
A google.api_core.retry.Retry value will enable retries, and the object will
define retriable response codes and errors and configure backoff and timeout options.
A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and
activates it only if certain conditions are met. This class exists to provide safe defaults
for RPC calls that are not technically safe to retry normally (due to potential data
duplication or other side-effects) but become safe to retry if a condition such as
if_metageneration_match is set.
See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for
information on retry types and how to configure them.
"""
client = self._require_client(client)

Expand All @@ -380,7 +425,7 @@ def update(
query_params=query_params,
_target_object=self,
timeout=timeout,
retry=DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED,
retry=retry,
)
self._set_properties(api_response)

Expand Down
2 changes: 1 addition & 1 deletion google/cloud/storage/acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def reload(self, client=None, timeout=_DEFAULT_TIMEOUT):
self.entities.clear()

found = client._connection.api_request(
method="GET", path=path, query_params=query_params, timeout=timeout
method="GET", path=path, query_params=query_params, timeout=timeout,
)
self.loaded = True
for entry in found.get("items", ()):
Expand Down
Loading

0 comments on commit 98bd78a

Please sign in to comment.