|
57 | 57 | from google.cloud.storage.constants import STANDARD_STORAGE_CLASS |
58 | 58 | from google.cloud.storage.notification import BucketNotification |
59 | 59 | from google.cloud.storage.notification import NONE_PAYLOAD_FORMAT |
60 | | - |
| 60 | +from google.cloud.storage.retry import DEFAULT_RETRY |
| 61 | +from google.cloud.storage.retry import DEFAULT_RETRY_IF_GENERATION_SPECIFIED |
| 62 | +from google.cloud.storage.retry import DEFAULT_RETRY_IF_ETAG_IN_JSON |
61 | 63 |
|
62 | 64 | _UBLA_BPO_ENABLED_MESSAGE = ( |
63 | 65 | "Pass only one of 'uniform_bucket_level_access_enabled' / " |
@@ -1244,7 +1246,9 @@ def list_blobs( |
1244 | 1246 |
|
1245 | 1247 | client = self._require_client(client) |
1246 | 1248 | path = self.path + "/o" |
1247 | | - api_request = functools.partial(client._connection.api_request, timeout=timeout) |
| 1249 | + api_request = functools.partial( |
| 1250 | + client._connection.api_request, timeout=timeout, retry=DEFAULT_RETRY |
| 1251 | + ) |
1248 | 1252 | iterator = page_iterator.HTTPIterator( |
1249 | 1253 | client=client, |
1250 | 1254 | api_request=api_request, |
@@ -1283,7 +1287,9 @@ def list_notifications(self, client=None, timeout=_DEFAULT_TIMEOUT): |
1283 | 1287 | """ |
1284 | 1288 | client = self._require_client(client) |
1285 | 1289 | path = self.path + "/notificationConfigs" |
1286 | | - api_request = functools.partial(client._connection.api_request, timeout=timeout) |
| 1290 | + api_request = functools.partial( |
| 1291 | + client._connection.api_request, timeout=timeout, retry=DEFAULT_RETRY |
| 1292 | + ) |
1287 | 1293 | iterator = page_iterator.HTTPIterator( |
1288 | 1294 | client=client, |
1289 | 1295 | api_request=api_request, |
@@ -1424,6 +1430,7 @@ def delete( |
1424 | 1430 | query_params=query_params, |
1425 | 1431 | _target_object=None, |
1426 | 1432 | timeout=timeout, |
| 1433 | + retry=DEFAULT_RETRY, |
1427 | 1434 | ) |
1428 | 1435 |
|
1429 | 1436 | def delete_blob( |
@@ -1521,6 +1528,7 @@ def delete_blob( |
1521 | 1528 | query_params=query_params, |
1522 | 1529 | _target_object=None, |
1523 | 1530 | timeout=timeout, |
| 1531 | + retry=DEFAULT_RETRY_IF_GENERATION_SPECIFIED, |
1524 | 1532 | ) |
1525 | 1533 |
|
1526 | 1534 | def delete_blobs( |
@@ -1795,6 +1803,7 @@ def copy_blob( |
1795 | 1803 | query_params=query_params, |
1796 | 1804 | _target_object=new_blob, |
1797 | 1805 | timeout=timeout, |
| 1806 | + retry=DEFAULT_RETRY_IF_GENERATION_SPECIFIED, |
1798 | 1807 | ) |
1799 | 1808 |
|
1800 | 1809 | if not preserve_acl: |
@@ -2644,6 +2653,7 @@ def get_iam_policy( |
2644 | 2653 | query_params=query_params, |
2645 | 2654 | _target_object=None, |
2646 | 2655 | timeout=timeout, |
| 2656 | + retry=DEFAULT_RETRY, |
2647 | 2657 | ) |
2648 | 2658 | return Policy.from_api_repr(info) |
2649 | 2659 |
|
@@ -2689,6 +2699,7 @@ def set_iam_policy(self, policy, client=None, timeout=_DEFAULT_TIMEOUT): |
2689 | 2699 | data=resource, |
2690 | 2700 | _target_object=None, |
2691 | 2701 | timeout=timeout, |
| 2702 | + retry=DEFAULT_RETRY_IF_ETAG_IN_JSON, |
2692 | 2703 | ) |
2693 | 2704 | return Policy.from_api_repr(info) |
2694 | 2705 |
|
@@ -2727,7 +2738,11 @@ def test_iam_permissions(self, permissions, client=None, timeout=_DEFAULT_TIMEOU |
2727 | 2738 |
|
2728 | 2739 | path = "%s/iam/testPermissions" % (self.path,) |
2729 | 2740 | resp = client._connection.api_request( |
2730 | | - method="GET", path=path, query_params=query_params, timeout=timeout |
| 2741 | + method="GET", |
| 2742 | + path=path, |
| 2743 | + query_params=query_params, |
| 2744 | + timeout=timeout, |
| 2745 | + retry=DEFAULT_RETRY, |
2731 | 2746 | ) |
2732 | 2747 | return resp.get("permissions", []) |
2733 | 2748 |
|
@@ -2967,6 +2982,7 @@ def lock_retention_policy(self, client=None, timeout=_DEFAULT_TIMEOUT): |
2967 | 2982 | query_params=query_params, |
2968 | 2983 | _target_object=self, |
2969 | 2984 | timeout=timeout, |
| 2985 | + retry=DEFAULT_RETRY, |
2970 | 2986 | ) |
2971 | 2987 | self._set_properties(api_response) |
2972 | 2988 |
|
|
0 commit comments