Skip to content

Commit c79f7f5

Browse files
fix: use retry_async instead of retry in async client (#816)
* chore: Update gapic-generator-python to v1.13.0 PiperOrigin-RevId: 586460538 Source-Link: googleapis/googleapis@44582d0 Source-Link: googleapis/googleapis-gen@5e7073c Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNWU3MDczYzlkZTg0NzkyOWM0YWU5N2Y4YTQ0NGMzZmNhMmQ0NWE2YiJ9 chore: Update gapic-generator-python to v1.12.0 PiperOrigin-RevId: 586356061 Source-Link: googleapis/googleapis@72a1f55 Source-Link: googleapis/googleapis-gen@558a04b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTU4YTA0YmNkMWNjMDU3NmU4ZmFjMTA4OWU0OGU0OGIyN2FjMTYxYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 6591b53 commit c79f7f5

File tree

7 files changed

+97
-97
lines changed

7 files changed

+97
-97
lines changed

google/cloud/logging_v2/services/config_service_v2/async_client.py

+48-48
Large diffs are not rendered by default.

google/cloud/logging_v2/services/logging_service_v2/async_client.py

+21-21
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
from google.api_core.client_options import ClientOptions
3737
from google.api_core import exceptions as core_exceptions
3838
from google.api_core import gapic_v1
39-
from google.api_core import retry as retries
39+
from google.api_core import retry_async as retries
4040
from google.auth import credentials as ga_credentials # type: ignore
4141
from google.oauth2 import service_account # type: ignore
4242

4343
try:
44-
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
44+
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault]
4545
except AttributeError: # pragma: NO COVER
46-
OptionalRetry = Union[retries.Retry, object] # type: ignore
46+
OptionalRetry = Union[retries.AsyncRetry, object] # type: ignore
4747

4848
from google.api import monitored_resource_pb2 # type: ignore
4949
from google.cloud.logging_v2.services.logging_service_v2 import pagers
@@ -278,7 +278,7 @@ async def sample_delete_log():
278278
This corresponds to the ``log_name`` field
279279
on the ``request`` instance; if ``request`` is provided, this
280280
should not be set.
281-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
281+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
282282
should be retried.
283283
timeout (float): The timeout for this request.
284284
metadata (Sequence[Tuple[str, str]]): Strings which should be
@@ -305,7 +305,7 @@ async def sample_delete_log():
305305
# and friendly error handling.
306306
rpc = gapic_v1.method_async.wrap_method(
307307
self._client._transport.delete_log,
308-
default_retry=retries.Retry(
308+
default_retry=retries.AsyncRetry(
309309
initial=0.1,
310310
maximum=60.0,
311311
multiplier=1.3,
@@ -472,7 +472,7 @@ async def sample_write_log_entries():
472472
This corresponds to the ``entries`` field
473473
on the ``request`` instance; if ``request`` is provided, this
474474
should not be set.
475-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
475+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
476476
should be retried.
477477
timeout (float): The timeout for this request.
478478
metadata (Sequence[Tuple[str, str]]): Strings which should be
@@ -510,7 +510,7 @@ async def sample_write_log_entries():
510510
# and friendly error handling.
511511
rpc = gapic_v1.method_async.wrap_method(
512512
self._client._transport.write_log_entries,
513-
default_retry=retries.Retry(
513+
default_retry=retries.AsyncRetry(
514514
initial=0.1,
515515
maximum=60.0,
516516
multiplier=1.3,
@@ -629,7 +629,7 @@ async def sample_list_log_entries():
629629
This corresponds to the ``order_by`` field
630630
on the ``request`` instance; if ``request`` is provided, this
631631
should not be set.
632-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
632+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
633633
should be retried.
634634
timeout (float): The timeout for this request.
635635
metadata (Sequence[Tuple[str, str]]): Strings which should be
@@ -668,7 +668,7 @@ async def sample_list_log_entries():
668668
# and friendly error handling.
669669
rpc = gapic_v1.method_async.wrap_method(
670670
self._client._transport.list_log_entries,
671-
default_retry=retries.Retry(
671+
default_retry=retries.AsyncRetry(
672672
initial=0.1,
673673
maximum=60.0,
674674
multiplier=1.3,
@@ -746,7 +746,7 @@ async def sample_list_monitored_resource_descriptors():
746746
request (Optional[Union[google.cloud.logging_v2.types.ListMonitoredResourceDescriptorsRequest, dict]]):
747747
The request object. The parameters to
748748
ListMonitoredResourceDescriptors
749-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
749+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
750750
should be retried.
751751
timeout (float): The timeout for this request.
752752
metadata (Sequence[Tuple[str, str]]): Strings which should be
@@ -768,7 +768,7 @@ async def sample_list_monitored_resource_descriptors():
768768
# and friendly error handling.
769769
rpc = gapic_v1.method_async.wrap_method(
770770
self._client._transport.list_monitored_resource_descriptors,
771-
default_retry=retries.Retry(
771+
default_retry=retries.AsyncRetry(
772772
initial=0.1,
773773
maximum=60.0,
774774
multiplier=1.3,
@@ -857,7 +857,7 @@ async def sample_list_logs():
857857
This corresponds to the ``parent`` field
858858
on the ``request`` instance; if ``request`` is provided, this
859859
should not be set.
860-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
860+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
861861
should be retried.
862862
timeout (float): The timeout for this request.
863863
metadata (Sequence[Tuple[str, str]]): Strings which should be
@@ -893,7 +893,7 @@ async def sample_list_logs():
893893
# and friendly error handling.
894894
rpc = gapic_v1.method_async.wrap_method(
895895
self._client._transport.list_logs,
896-
default_retry=retries.Retry(
896+
default_retry=retries.AsyncRetry(
897897
initial=0.1,
898898
maximum=60.0,
899899
multiplier=1.3,
@@ -986,7 +986,7 @@ def request_generator():
986986
Args:
987987
requests (AsyncIterator[`google.cloud.logging_v2.types.TailLogEntriesRequest`]):
988988
The request object AsyncIterator. The parameters to ``TailLogEntries``.
989-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
989+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
990990
should be retried.
991991
timeout (float): The timeout for this request.
992992
metadata (Sequence[Tuple[str, str]]): Strings which should be
@@ -1001,7 +1001,7 @@ def request_generator():
10011001
# and friendly error handling.
10021002
rpc = gapic_v1.method_async.wrap_method(
10031003
self._client._transport.tail_log_entries,
1004-
default_retry=retries.Retry(
1004+
default_retry=retries.AsyncRetry(
10051005
initial=0.1,
10061006
maximum=60.0,
10071007
multiplier=1.3,
@@ -1041,7 +1041,7 @@ async def list_operations(
10411041
request (:class:`~.operations_pb2.ListOperationsRequest`):
10421042
The request object. Request message for
10431043
`ListOperations` method.
1044-
retry (google.api_core.retry.Retry): Designation of what errors,
1044+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
10451045
if any, should be retried.
10461046
timeout (float): The timeout for this request.
10471047
metadata (Sequence[Tuple[str, str]]): Strings which should be
@@ -1058,7 +1058,7 @@ async def list_operations(
10581058

10591059
# Wrap the RPC method; this adds retry and timeout information,
10601060
# and friendly error handling.
1061-
rpc = gapic_v1.method.wrap_method(
1061+
rpc = gapic_v1.method_async.wrap_method(
10621062
self._client._transport.list_operations,
10631063
default_timeout=None,
10641064
client_info=DEFAULT_CLIENT_INFO,
@@ -1095,7 +1095,7 @@ async def get_operation(
10951095
request (:class:`~.operations_pb2.GetOperationRequest`):
10961096
The request object. Request message for
10971097
`GetOperation` method.
1098-
retry (google.api_core.retry.Retry): Designation of what errors,
1098+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
10991099
if any, should be retried.
11001100
timeout (float): The timeout for this request.
11011101
metadata (Sequence[Tuple[str, str]]): Strings which should be
@@ -1112,7 +1112,7 @@ async def get_operation(
11121112

11131113
# Wrap the RPC method; this adds retry and timeout information,
11141114
# and friendly error handling.
1115-
rpc = gapic_v1.method.wrap_method(
1115+
rpc = gapic_v1.method_async.wrap_method(
11161116
self._client._transport.get_operation,
11171117
default_timeout=None,
11181118
client_info=DEFAULT_CLIENT_INFO,
@@ -1153,7 +1153,7 @@ async def cancel_operation(
11531153
request (:class:`~.operations_pb2.CancelOperationRequest`):
11541154
The request object. Request message for
11551155
`CancelOperation` method.
1156-
retry (google.api_core.retry.Retry): Designation of what errors,
1156+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
11571157
if any, should be retried.
11581158
timeout (float): The timeout for this request.
11591159
metadata (Sequence[Tuple[str, str]]): Strings which should be
@@ -1169,7 +1169,7 @@ async def cancel_operation(
11691169

11701170
# Wrap the RPC method; this adds retry and timeout information,
11711171
# and friendly error handling.
1172-
rpc = gapic_v1.method.wrap_method(
1172+
rpc = gapic_v1.method_async.wrap_method(
11731173
self._client._transport.cancel_operation,
11741174
default_timeout=None,
11751175
client_info=DEFAULT_CLIENT_INFO,

google/cloud/logging_v2/services/metrics_service_v2/async_client.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333
from google.api_core.client_options import ClientOptions
3434
from google.api_core import exceptions as core_exceptions
3535
from google.api_core import gapic_v1
36-
from google.api_core import retry as retries
36+
from google.api_core import retry_async as retries
3737
from google.auth import credentials as ga_credentials # type: ignore
3838
from google.oauth2 import service_account # type: ignore
3939

4040
try:
41-
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
41+
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault]
4242
except AttributeError: # pragma: NO COVER
43-
OptionalRetry = Union[retries.Retry, object] # type: ignore
43+
OptionalRetry = Union[retries.AsyncRetry, object] # type: ignore
4444

4545
from google.api import distribution_pb2 # type: ignore
4646
from google.api import metric_pb2 # type: ignore
@@ -269,7 +269,7 @@ async def sample_list_log_metrics():
269269
This corresponds to the ``parent`` field
270270
on the ``request`` instance; if ``request`` is provided, this
271271
should not be set.
272-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
272+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
273273
should be retried.
274274
timeout (float): The timeout for this request.
275275
metadata (Sequence[Tuple[str, str]]): Strings which should be
@@ -305,7 +305,7 @@ async def sample_list_log_metrics():
305305
# and friendly error handling.
306306
rpc = gapic_v1.method_async.wrap_method(
307307
self._client._transport.list_log_metrics,
308-
default_retry=retries.Retry(
308+
default_retry=retries.AsyncRetry(
309309
initial=0.1,
310310
maximum=60.0,
311311
multiplier=1.3,
@@ -396,7 +396,7 @@ async def sample_get_log_metric():
396396
This corresponds to the ``metric_name`` field
397397
on the ``request`` instance; if ``request`` is provided, this
398398
should not be set.
399-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
399+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
400400
should be retried.
401401
timeout (float): The timeout for this request.
402402
metadata (Sequence[Tuple[str, str]]): Strings which should be
@@ -439,7 +439,7 @@ async def sample_get_log_metric():
439439
# and friendly error handling.
440440
rpc = gapic_v1.method_async.wrap_method(
441441
self._client._transport.get_log_metric,
442-
default_retry=retries.Retry(
442+
default_retry=retries.AsyncRetry(
443443
initial=0.1,
444444
maximum=60.0,
445445
multiplier=1.3,
@@ -540,7 +540,7 @@ async def sample_create_log_metric():
540540
This corresponds to the ``metric`` field
541541
on the ``request`` instance; if ``request`` is provided, this
542542
should not be set.
543-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
543+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
544544
should be retried.
545545
timeout (float): The timeout for this request.
546546
metadata (Sequence[Tuple[str, str]]): Strings which should be
@@ -672,7 +672,7 @@ async def sample_update_log_metric():
672672
This corresponds to the ``metric`` field
673673
on the ``request`` instance; if ``request`` is provided, this
674674
should not be set.
675-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
675+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
676676
should be retried.
677677
timeout (float): The timeout for this request.
678678
metadata (Sequence[Tuple[str, str]]): Strings which should be
@@ -717,7 +717,7 @@ async def sample_update_log_metric():
717717
# and friendly error handling.
718718
rpc = gapic_v1.method_async.wrap_method(
719719
self._client._transport.update_log_metric,
720-
default_retry=retries.Retry(
720+
default_retry=retries.AsyncRetry(
721721
initial=0.1,
722722
maximum=60.0,
723723
multiplier=1.3,
@@ -798,7 +798,7 @@ async def sample_delete_log_metric():
798798
This corresponds to the ``metric_name`` field
799799
on the ``request`` instance; if ``request`` is provided, this
800800
should not be set.
801-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
801+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
802802
should be retried.
803803
timeout (float): The timeout for this request.
804804
metadata (Sequence[Tuple[str, str]]): Strings which should be
@@ -825,7 +825,7 @@ async def sample_delete_log_metric():
825825
# and friendly error handling.
826826
rpc = gapic_v1.method_async.wrap_method(
827827
self._client._transport.delete_log_metric,
828-
default_retry=retries.Retry(
828+
default_retry=retries.AsyncRetry(
829829
initial=0.1,
830830
maximum=60.0,
831831
multiplier=1.3,
@@ -870,7 +870,7 @@ async def list_operations(
870870
request (:class:`~.operations_pb2.ListOperationsRequest`):
871871
The request object. Request message for
872872
`ListOperations` method.
873-
retry (google.api_core.retry.Retry): Designation of what errors,
873+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
874874
if any, should be retried.
875875
timeout (float): The timeout for this request.
876876
metadata (Sequence[Tuple[str, str]]): Strings which should be
@@ -887,7 +887,7 @@ async def list_operations(
887887

888888
# Wrap the RPC method; this adds retry and timeout information,
889889
# and friendly error handling.
890-
rpc = gapic_v1.method.wrap_method(
890+
rpc = gapic_v1.method_async.wrap_method(
891891
self._client._transport.list_operations,
892892
default_timeout=None,
893893
client_info=DEFAULT_CLIENT_INFO,
@@ -924,7 +924,7 @@ async def get_operation(
924924
request (:class:`~.operations_pb2.GetOperationRequest`):
925925
The request object. Request message for
926926
`GetOperation` method.
927-
retry (google.api_core.retry.Retry): Designation of what errors,
927+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
928928
if any, should be retried.
929929
timeout (float): The timeout for this request.
930930
metadata (Sequence[Tuple[str, str]]): Strings which should be
@@ -941,7 +941,7 @@ async def get_operation(
941941

942942
# Wrap the RPC method; this adds retry and timeout information,
943943
# and friendly error handling.
944-
rpc = gapic_v1.method.wrap_method(
944+
rpc = gapic_v1.method_async.wrap_method(
945945
self._client._transport.get_operation,
946946
default_timeout=None,
947947
client_info=DEFAULT_CLIENT_INFO,
@@ -982,7 +982,7 @@ async def cancel_operation(
982982
request (:class:`~.operations_pb2.CancelOperationRequest`):
983983
The request object. Request message for
984984
`CancelOperation` method.
985-
retry (google.api_core.retry.Retry): Designation of what errors,
985+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
986986
if any, should be retried.
987987
timeout (float): The timeout for this request.
988988
metadata (Sequence[Tuple[str, str]]): Strings which should be
@@ -998,7 +998,7 @@ async def cancel_operation(
998998

999999
# Wrap the RPC method; this adds retry and timeout information,
10001000
# and friendly error handling.
1001-
rpc = gapic_v1.method.wrap_method(
1001+
rpc = gapic_v1.method_async.wrap_method(
10021002
self._client._transport.cancel_operation,
10031003
default_timeout=None,
10041004
client_info=DEFAULT_CLIENT_INFO,

samples/generated_samples/snippet_metadata_google.logging.v2.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-logging",
11-
"version": "3.8.0"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

tests/unit/gapic/logging_v2/test_config_service_v2.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -9112,7 +9112,7 @@ def test_cancel_operation(transport: str = "grpc"):
91129112

91139113

91149114
@pytest.mark.asyncio
9115-
async def test_cancel_operation_async(transport: str = "grpc"):
9115+
async def test_cancel_operation_async(transport: str = "grpc_asyncio"):
91169116
client = ConfigServiceV2AsyncClient(
91179117
credentials=ga_credentials.AnonymousCredentials(),
91189118
transport=transport,
@@ -9251,7 +9251,7 @@ def test_get_operation(transport: str = "grpc"):
92519251

92529252

92539253
@pytest.mark.asyncio
9254-
async def test_get_operation_async(transport: str = "grpc"):
9254+
async def test_get_operation_async(transport: str = "grpc_asyncio"):
92559255
client = ConfigServiceV2AsyncClient(
92569256
credentials=ga_credentials.AnonymousCredentials(),
92579257
transport=transport,
@@ -9396,7 +9396,7 @@ def test_list_operations(transport: str = "grpc"):
93969396

93979397

93989398
@pytest.mark.asyncio
9399-
async def test_list_operations_async(transport: str = "grpc"):
9399+
async def test_list_operations_async(transport: str = "grpc_asyncio"):
94009400
client = ConfigServiceV2AsyncClient(
94019401
credentials=ga_credentials.AnonymousCredentials(),
94029402
transport=transport,

tests/unit/gapic/logging_v2/test_logging_service_v2.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3013,7 +3013,7 @@ def test_cancel_operation(transport: str = "grpc"):
30133013

30143014

30153015
@pytest.mark.asyncio
3016-
async def test_cancel_operation_async(transport: str = "grpc"):
3016+
async def test_cancel_operation_async(transport: str = "grpc_asyncio"):
30173017
client = LoggingServiceV2AsyncClient(
30183018
credentials=ga_credentials.AnonymousCredentials(),
30193019
transport=transport,
@@ -3152,7 +3152,7 @@ def test_get_operation(transport: str = "grpc"):
31523152

31533153

31543154
@pytest.mark.asyncio
3155-
async def test_get_operation_async(transport: str = "grpc"):
3155+
async def test_get_operation_async(transport: str = "grpc_asyncio"):
31563156
client = LoggingServiceV2AsyncClient(
31573157
credentials=ga_credentials.AnonymousCredentials(),
31583158
transport=transport,
@@ -3297,7 +3297,7 @@ def test_list_operations(transport: str = "grpc"):
32973297

32983298

32993299
@pytest.mark.asyncio
3300-
async def test_list_operations_async(transport: str = "grpc"):
3300+
async def test_list_operations_async(transport: str = "grpc_asyncio"):
33013301
client = LoggingServiceV2AsyncClient(
33023302
credentials=ga_credentials.AnonymousCredentials(),
33033303
transport=transport,

0 commit comments

Comments
 (0)