Skip to content

Commit

Permalink
fix: use retry_async instead of retry in async client (#816)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed Nov 30, 2023
1 parent 6591b53 commit c79f7f5
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 97 deletions.
96 changes: 48 additions & 48 deletions google/cloud/logging_v2/services/config_service_v2/async_client.py

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions google/cloud/logging_v2/services/logging_service_v2/async_client.py
Expand Up @@ -36,14 +36,14 @@
from google.api_core.client_options import ClientOptions
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry as retries
from google.api_core import retry_async as retries
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault]
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object] # type: ignore
OptionalRetry = Union[retries.AsyncRetry, object] # type: ignore

from google.api import monitored_resource_pb2 # type: ignore
from google.cloud.logging_v2.services.logging_service_v2 import pagers
Expand Down Expand Up @@ -278,7 +278,7 @@ async def sample_delete_log():
This corresponds to the ``log_name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand All @@ -305,7 +305,7 @@ async def sample_delete_log():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.delete_log,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -472,7 +472,7 @@ async def sample_write_log_entries():
This corresponds to the ``entries`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand Down Expand Up @@ -510,7 +510,7 @@ async def sample_write_log_entries():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.write_log_entries,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -629,7 +629,7 @@ async def sample_list_log_entries():
This corresponds to the ``order_by`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand Down Expand Up @@ -668,7 +668,7 @@ async def sample_list_log_entries():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.list_log_entries,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -746,7 +746,7 @@ async def sample_list_monitored_resource_descriptors():
request (Optional[Union[google.cloud.logging_v2.types.ListMonitoredResourceDescriptorsRequest, dict]]):
The request object. The parameters to
ListMonitoredResourceDescriptors
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand All @@ -768,7 +768,7 @@ async def sample_list_monitored_resource_descriptors():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.list_monitored_resource_descriptors,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -857,7 +857,7 @@ async def sample_list_logs():
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand Down Expand Up @@ -893,7 +893,7 @@ async def sample_list_logs():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.list_logs,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -986,7 +986,7 @@ def request_generator():
Args:
requests (AsyncIterator[`google.cloud.logging_v2.types.TailLogEntriesRequest`]):
The request object AsyncIterator. The parameters to ``TailLogEntries``.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand All @@ -1001,7 +1001,7 @@ def request_generator():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.tail_log_entries,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -1041,7 +1041,7 @@ async def list_operations(
request (:class:`~.operations_pb2.ListOperationsRequest`):
The request object. Request message for
`ListOperations` method.
retry (google.api_core.retry.Retry): Designation of what errors,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand All @@ -1058,7 +1058,7 @@ async def list_operations(

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

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

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method.wrap_method(
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.cancel_operation,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
Expand Down
36 changes: 18 additions & 18 deletions google/cloud/logging_v2/services/metrics_service_v2/async_client.py
Expand Up @@ -33,14 +33,14 @@
from google.api_core.client_options import ClientOptions
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry as retries
from google.api_core import retry_async as retries
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault]
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object] # type: ignore
OptionalRetry = Union[retries.AsyncRetry, object] # type: ignore

from google.api import distribution_pb2 # type: ignore
from google.api import metric_pb2 # type: ignore
Expand Down Expand Up @@ -269,7 +269,7 @@ async def sample_list_log_metrics():
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand Down Expand Up @@ -305,7 +305,7 @@ async def sample_list_log_metrics():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.list_log_metrics,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -396,7 +396,7 @@ async def sample_get_log_metric():
This corresponds to the ``metric_name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand Down Expand Up @@ -439,7 +439,7 @@ async def sample_get_log_metric():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.get_log_metric,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -540,7 +540,7 @@ async def sample_create_log_metric():
This corresponds to the ``metric`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand Down Expand Up @@ -672,7 +672,7 @@ async def sample_update_log_metric():
This corresponds to the ``metric`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand Down Expand Up @@ -717,7 +717,7 @@ async def sample_update_log_metric():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.update_log_metric,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -798,7 +798,7 @@ async def sample_delete_log_metric():
This corresponds to the ``metric_name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand All @@ -825,7 +825,7 @@ async def sample_delete_log_metric():
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.delete_log_metric,
default_retry=retries.Retry(
default_retry=retries.AsyncRetry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
Expand Down Expand Up @@ -870,7 +870,7 @@ async def list_operations(
request (:class:`~.operations_pb2.ListOperationsRequest`):
The request object. Request message for
`ListOperations` method.
retry (google.api_core.retry.Retry): Designation of what errors,
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
Expand All @@ -887,7 +887,7 @@ async def list_operations(

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

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

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method.wrap_method(
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.cancel_operation,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
Expand Down
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-logging",
"version": "3.8.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/gapic/logging_v2/test_config_service_v2.py
Expand Up @@ -9112,7 +9112,7 @@ def test_cancel_operation(transport: str = "grpc"):


@pytest.mark.asyncio
async def test_cancel_operation_async(transport: str = "grpc"):
async def test_cancel_operation_async(transport: str = "grpc_asyncio"):
client = ConfigServiceV2AsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
Expand Down Expand Up @@ -9251,7 +9251,7 @@ def test_get_operation(transport: str = "grpc"):


@pytest.mark.asyncio
async def test_get_operation_async(transport: str = "grpc"):
async def test_get_operation_async(transport: str = "grpc_asyncio"):
client = ConfigServiceV2AsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
Expand Down Expand Up @@ -9396,7 +9396,7 @@ def test_list_operations(transport: str = "grpc"):


@pytest.mark.asyncio
async def test_list_operations_async(transport: str = "grpc"):
async def test_list_operations_async(transport: str = "grpc_asyncio"):
client = ConfigServiceV2AsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/gapic/logging_v2/test_logging_service_v2.py
Expand Up @@ -3013,7 +3013,7 @@ def test_cancel_operation(transport: str = "grpc"):


@pytest.mark.asyncio
async def test_cancel_operation_async(transport: str = "grpc"):
async def test_cancel_operation_async(transport: str = "grpc_asyncio"):
client = LoggingServiceV2AsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
Expand Down Expand Up @@ -3152,7 +3152,7 @@ def test_get_operation(transport: str = "grpc"):


@pytest.mark.asyncio
async def test_get_operation_async(transport: str = "grpc"):
async def test_get_operation_async(transport: str = "grpc_asyncio"):
client = LoggingServiceV2AsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
Expand Down Expand Up @@ -3297,7 +3297,7 @@ def test_list_operations(transport: str = "grpc"):


@pytest.mark.asyncio
async def test_list_operations_async(transport: str = "grpc"):
async def test_list_operations_async(transport: str = "grpc_asyncio"):
client = LoggingServiceV2AsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
Expand Down

0 comments on commit c79f7f5

Please sign in to comment.