-
Notifications
You must be signed in to change notification settings - Fork 169
feat: make retry parameter public and added in other methods #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
d0af8e3
4424b59
674b0f2
3d36abb
e204297
71bdd7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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. | ||
|
|
||
|
|
@@ -187,6 +188,11 @@ 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 | ||
| :param retry: (Optional) How to retry the RPC. To modify the default retry behavior, | ||
| create a new retry object modeled after this one by calling it a ``with_XXX`` method. | ||
| See: https://googleapis.dev/python/google-api-core/latest/retry.html for details. | ||
|
||
| """ | ||
| client = self._require_client(client) | ||
| query_params = self._query_params | ||
|
|
@@ -207,7 +213,7 @@ def reload( | |
| headers=self._encryption_headers(), | ||
| _target_object=self, | ||
| timeout=timeout, | ||
| retry=DEFAULT_RETRY, | ||
| retry=retry, | ||
| ) | ||
| self._set_properties(api_response) | ||
|
|
||
|
|
@@ -247,6 +253,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. | ||
|
|
||
|
|
@@ -286,6 +293,11 @@ 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 | ||
| :param retry: (Optional) How to retry the RPC. To modify the default retry behavior, | ||
| create a new retry object modeled after this one by calling it a ``with_XXX`` method. | ||
| See: https://googleapis.dev/python/google-api-core/latest/retry.html for details. | ||
| """ | ||
| client = self._require_client(client) | ||
| query_params = self._query_params | ||
|
|
@@ -309,7 +321,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) | ||
|
|
||
|
|
@@ -321,6 +333,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. | ||
|
|
||
|
|
@@ -360,6 +373,11 @@ 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 | ||
| :param retry: (Optional) How to retry the RPC. To modify the default retry behavior, | ||
| create a new retry object modeled after this one by calling it a ``with_XXX`` method. | ||
| See: https://googleapis.dev/python/google-api-core/latest/retry.html for details. | ||
| """ | ||
| client = self._require_client(client) | ||
|
|
||
|
|
@@ -380,7 +398,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) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,6 +85,7 @@ | |
| """ | ||
|
|
||
| from google.cloud.storage.constants import _DEFAULT_TIMEOUT | ||
| from google.cloud.storage.retry import DEFAULT_RETRY | ||
|
|
||
|
|
||
| class _ACLEntity(object): | ||
|
|
@@ -430,7 +431,7 @@ def _require_client(self, client): | |
| client = self.client | ||
| return client | ||
|
|
||
| def reload(self, client=None, timeout=_DEFAULT_TIMEOUT): | ||
| def reload(self, client=None, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY): | ||
|
||
| """Reload the ACL data from Cloud Storage. | ||
|
|
||
| If :attr:`user_project` is set, bills the API request to that project. | ||
|
|
@@ -445,6 +446,11 @@ def reload(self, client=None, timeout=_DEFAULT_TIMEOUT): | |
|
|
||
| Can also be passed as a tuple (connect_timeout, read_timeout). | ||
| See :meth:`requests.Session.request` documentation for details. | ||
|
|
||
| :type retry: google.api_core.retry.Retry | ||
| :param retry: (Optional) How to retry the RPC. To modify the default retry behavior, | ||
| create a new retry object modeled after this one by calling it a ``with_XXX`` method. | ||
| See: https://googleapis.dev/python/google-api-core/latest/retry.html for details. | ||
| """ | ||
| path = self.reload_path | ||
| client = self._require_client(client) | ||
|
|
@@ -456,13 +462,19 @@ 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, | ||
| retry=retry, | ||
| ) | ||
| self.loaded = True | ||
| for entry in found.get("items", ()): | ||
| self.add_entity(self.entity_from_dict(entry)) | ||
|
|
||
| def _save(self, acl, predefined, client, timeout=_DEFAULT_TIMEOUT): | ||
| def _save( | ||
|
||
| self, acl, predefined, client, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY | ||
| ): | ||
| """Helper for :meth:`save` and :meth:`save_predefined`. | ||
|
|
||
| :type acl: :class:`google.cloud.storage.acl.ACL`, or a compatible list. | ||
|
|
@@ -483,6 +495,11 @@ def _save(self, acl, predefined, client, timeout=_DEFAULT_TIMEOUT): | |
|
|
||
| Can also be passed as a tuple (connect_timeout, read_timeout). | ||
| See :meth:`requests.Session.request` documentation for details. | ||
|
|
||
| :type retry: google.api_core.retry.Retry | ||
| :param retry: (Optional) How to retry the RPC. To modify the default retry behavior, | ||
| create a new retry object modeled after this one by calling it a ``with_XXX`` method. | ||
| See: https://googleapis.dev/python/google-api-core/latest/retry.html for details. | ||
| """ | ||
| query_params = {"projection": "full"} | ||
| if predefined is not None: | ||
|
|
@@ -501,13 +518,16 @@ def _save(self, acl, predefined, client, timeout=_DEFAULT_TIMEOUT): | |
| data={self._URL_PATH_ELEM: list(acl)}, | ||
| query_params=query_params, | ||
| timeout=timeout, | ||
| retry=retry, | ||
| ) | ||
| self.entities.clear() | ||
| for entry in result.get(self._URL_PATH_ELEM, ()): | ||
| self.add_entity(self.entity_from_dict(entry)) | ||
| self.loaded = True | ||
|
|
||
| def save(self, acl=None, client=None, timeout=_DEFAULT_TIMEOUT): | ||
| def save( | ||
| self, acl=None, client=None, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY | ||
| ): | ||
| """Save this ACL for the current bucket. | ||
|
|
||
| If :attr:`user_project` is set, bills the API request to that project. | ||
|
|
@@ -526,6 +546,11 @@ def save(self, acl=None, client=None, timeout=_DEFAULT_TIMEOUT): | |
|
|
||
| Can also be passed as a tuple (connect_timeout, read_timeout). | ||
| See :meth:`requests.Session.request` documentation for details. | ||
|
|
||
| :type retry: google.api_core.retry.Retry | ||
| :param retry: (Optional) How to retry the RPC. To modify the default retry behavior, | ||
| create a new retry object modeled after this one by calling it a ``with_XXX`` method. | ||
| See: https://googleapis.dev/python/google-api-core/latest/retry.html for details. | ||
| """ | ||
| if acl is None: | ||
| acl = self | ||
|
|
@@ -534,9 +559,11 @@ def save(self, acl=None, client=None, timeout=_DEFAULT_TIMEOUT): | |
| save_to_backend = True | ||
|
|
||
| if save_to_backend: | ||
| self._save(acl, None, client, timeout=timeout) | ||
| self._save(acl, None, client, timeout=timeout, retry=retry) | ||
|
|
||
| def save_predefined(self, predefined, client=None, timeout=_DEFAULT_TIMEOUT): | ||
| def save_predefined( | ||
| self, predefined, client=None, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY | ||
| ): | ||
| """Save this ACL for the current bucket using a predefined ACL. | ||
|
|
||
| If :attr:`user_project` is set, bills the API request to that project. | ||
|
|
@@ -558,11 +585,16 @@ def save_predefined(self, predefined, client=None, timeout=_DEFAULT_TIMEOUT): | |
|
|
||
| Can also be passed as a tuple (connect_timeout, read_timeout). | ||
| See :meth:`requests.Session.request` documentation for details. | ||
|
|
||
| :type retry: google.api_core.retry.Retry | ||
| :param retry: (Optional) How to retry the RPC. To modify the default retry behavior, | ||
| create a new retry object modeled after this one by calling it a ``with_XXX`` method. | ||
| See: https://googleapis.dev/python/google-api-core/latest/retry.html for details. | ||
| """ | ||
| predefined = self.validate_predefined(predefined) | ||
| self._save(None, predefined, client, timeout=timeout) | ||
| self._save(None, predefined, client, timeout=timeout, retry=retry) | ||
|
|
||
| def clear(self, client=None, timeout=_DEFAULT_TIMEOUT): | ||
| def clear(self, client=None, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY): | ||
| """Remove all ACL entries. | ||
|
|
||
| If :attr:`user_project` is set, bills the API request to that project. | ||
|
|
@@ -582,8 +614,13 @@ def clear(self, client=None, timeout=_DEFAULT_TIMEOUT): | |
|
|
||
| Can also be passed as a tuple (connect_timeout, read_timeout). | ||
| See :meth:`requests.Session.request` documentation for details. | ||
|
|
||
| :type retry: google.api_core.retry.Retry | ||
| :param retry: (Optional) How to retry the RPC. To modify the default retry behavior, | ||
| create a new retry object modeled after this one by calling it a ``with_XXX`` method. | ||
| See: https://googleapis.dev/python/google-api-core/latest/retry.html for details. | ||
| """ | ||
| self.save([], client=client, timeout=timeout) | ||
| self.save([], client=client, timeout=timeout, retry=retry) | ||
|
|
||
|
|
||
| class BucketACL(ACL): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically either google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy are supported here, and in some cases ConditionalRetryPolicy is the default so despite the complexity we should document it here.