Skip to content

Commit b9ca8a5

Browse files
fix(deps): Require google-api-core >=1.34.0, >=2.11.0 (#239)
* fix(deps): Require google-api-core >=1.34.0, >=2.11.0 fix: Drop usage of pkg_resources fix: Fix timeout default values docs(samples): Snippetgen should call await on the operation coroutine before calling result PiperOrigin-RevId: 493260409 Source-Link: googleapis/googleapis@fea4387 Source-Link: googleapis/googleapis-gen@387b734 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzg3YjczNDRjNzUyOWVlNDRiZTg0ZTYxM2IxOWE4MjA1MDhjNjEyYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * add gapic_version.py Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
1 parent d029062 commit b9ca8a5

28 files changed

+140
-137
lines changed

packages/google-cloud-redis/.coveragerc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,3 @@ exclude_lines =
1010
pragma: NO COVER
1111
# Ignore debug-only repr
1212
def __repr__
13-
# Ignore pkg_resources exceptions.
14-
# This is added at the module level as a safeguard for if someone
15-
# generates the code and tries to run it without pip installing. This
16-
# makes it virtually impossible to test properly.
17-
except pkg_resources.DistributionNotFound
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2022 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
__version__ = "2.9.3" # {x-release-please-version}

packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/async_client.py

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
from google.api_core.client_options import ClientOptions
3535
from google.auth import credentials as ga_credentials # type: ignore
3636
from google.oauth2 import service_account # type: ignore
37-
import pkg_resources
37+
38+
from google.cloud.redis_v1 import gapic_version as package_version
3839

3940
try:
4041
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
@@ -240,7 +241,7 @@ async def list_instances(
240241
*,
241242
parent: Optional[str] = None,
242243
retry: OptionalRetry = gapic_v1.method.DEFAULT,
243-
timeout: Optional[float] = None,
244+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
244245
metadata: Sequence[Tuple[str, str]] = (),
245246
) -> pagers.ListInstancesAsyncPager:
246247
r"""Lists all Redis instances owned by a project in either the
@@ -366,7 +367,7 @@ async def get_instance(
366367
*,
367368
name: Optional[str] = None,
368369
retry: OptionalRetry = gapic_v1.method.DEFAULT,
369-
timeout: Optional[float] = None,
370+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
370371
metadata: Sequence[Tuple[str, str]] = (),
371372
) -> cloud_redis.Instance:
372373
r"""Gets the details of a specific Redis instance.
@@ -467,7 +468,7 @@ async def get_instance_auth_string(
467468
*,
468469
name: Optional[str] = None,
469470
retry: OptionalRetry = gapic_v1.method.DEFAULT,
470-
timeout: Optional[float] = None,
471+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
471472
metadata: Sequence[Tuple[str, str]] = (),
472473
) -> cloud_redis.InstanceAuthString:
473474
r"""Gets the AUTH string for a Redis instance. If AUTH is
@@ -573,7 +574,7 @@ async def create_instance(
573574
instance_id: Optional[str] = None,
574575
instance: Optional[cloud_redis.Instance] = None,
575576
retry: OptionalRetry = gapic_v1.method.DEFAULT,
576-
timeout: Optional[float] = None,
577+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
577578
metadata: Sequence[Tuple[str, str]] = (),
578579
) -> operation_async.AsyncOperation:
579580
r"""Creates a Redis instance based on the specified tier and memory
@@ -623,7 +624,7 @@ async def sample_create_instance():
623624
624625
print("Waiting for operation to complete...")
625626
626-
response = await operation.result()
627+
response = (await operation).result()
627628
628629
# Handle the response
629630
print(response)
@@ -736,7 +737,7 @@ async def update_instance(
736737
update_mask: Optional[field_mask_pb2.FieldMask] = None,
737738
instance: Optional[cloud_redis.Instance] = None,
738739
retry: OptionalRetry = gapic_v1.method.DEFAULT,
739-
timeout: Optional[float] = None,
740+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
740741
metadata: Sequence[Tuple[str, str]] = (),
741742
) -> operation_async.AsyncOperation:
742743
r"""Updates the metadata and configuration of a specific
@@ -776,7 +777,7 @@ async def sample_update_instance():
776777
777778
print("Waiting for operation to complete...")
778779
779-
response = await operation.result()
780+
response = (await operation).result()
780781
781782
# Handle the response
782783
print(response)
@@ -883,7 +884,7 @@ async def upgrade_instance(
883884
name: Optional[str] = None,
884885
redis_version: Optional[str] = None,
885886
retry: OptionalRetry = gapic_v1.method.DEFAULT,
886-
timeout: Optional[float] = None,
887+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
887888
metadata: Sequence[Tuple[str, str]] = (),
888889
) -> operation_async.AsyncOperation:
889890
r"""Upgrades Redis instance to the newer Redis version
@@ -915,7 +916,7 @@ async def sample_upgrade_instance():
915916
916917
print("Waiting for operation to complete...")
917918
918-
response = await operation.result()
919+
response = (await operation).result()
919920
920921
# Handle the response
921922
print(response)
@@ -1013,7 +1014,7 @@ async def import_instance(
10131014
name: Optional[str] = None,
10141015
input_config: Optional[cloud_redis.InputConfig] = None,
10151016
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1016-
timeout: Optional[float] = None,
1017+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
10171018
metadata: Sequence[Tuple[str, str]] = (),
10181019
) -> operation_async.AsyncOperation:
10191020
r"""Import a Redis RDB snapshot file from Cloud Storage
@@ -1055,7 +1056,7 @@ async def sample_import_instance():
10551056
10561057
print("Waiting for operation to complete...")
10571058
1058-
response = await operation.result()
1059+
response = (await operation).result()
10591060
10601061
# Handle the response
10611062
print(response)
@@ -1153,7 +1154,7 @@ async def export_instance(
11531154
name: Optional[str] = None,
11541155
output_config: Optional[cloud_redis.OutputConfig] = None,
11551156
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1156-
timeout: Optional[float] = None,
1157+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
11571158
metadata: Sequence[Tuple[str, str]] = (),
11581159
) -> operation_async.AsyncOperation:
11591160
r"""Export Redis instance data into a Redis RDB format
@@ -1191,7 +1192,7 @@ async def sample_export_instance():
11911192
11921193
print("Waiting for operation to complete...")
11931194
1194-
response = await operation.result()
1195+
response = (await operation).result()
11951196
11961197
# Handle the response
11971198
print(response)
@@ -1291,7 +1292,7 @@ async def failover_instance(
12911292
cloud_redis.FailoverInstanceRequest.DataProtectionMode
12921293
] = None,
12931294
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1294-
timeout: Optional[float] = None,
1295+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
12951296
metadata: Sequence[Tuple[str, str]] = (),
12961297
) -> operation_async.AsyncOperation:
12971298
r"""Initiates a failover of the primary node to current
@@ -1323,7 +1324,7 @@ async def sample_failover_instance():
13231324
13241325
print("Waiting for operation to complete...")
13251326
1326-
response = await operation.result()
1327+
response = (await operation).result()
13271328
13281329
# Handle the response
13291330
print(response)
@@ -1421,7 +1422,7 @@ async def delete_instance(
14211422
*,
14221423
name: Optional[str] = None,
14231424
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1424-
timeout: Optional[float] = None,
1425+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
14251426
metadata: Sequence[Tuple[str, str]] = (),
14261427
) -> operation_async.AsyncOperation:
14271428
r"""Deletes a specific Redis instance. Instance stops
@@ -1452,7 +1453,7 @@ async def sample_delete_instance():
14521453
14531454
print("Waiting for operation to complete...")
14541455
1455-
response = await operation.result()
1456+
response = (await operation).result()
14561457
14571458
# Handle the response
14581459
print(response)
@@ -1551,7 +1552,7 @@ async def reschedule_maintenance(
15511552
] = None,
15521553
schedule_time: Optional[timestamp_pb2.Timestamp] = None,
15531554
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1554-
timeout: Optional[float] = None,
1555+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
15551556
metadata: Sequence[Tuple[str, str]] = (),
15561557
) -> operation_async.AsyncOperation:
15571558
r"""Reschedule maintenance for a given instance in a
@@ -1583,7 +1584,7 @@ async def sample_reschedule_maintenance():
15831584
15841585
print("Waiting for operation to complete...")
15851586
1586-
response = await operation.result()
1587+
response = (await operation).result()
15871588
15881589
# Handle the response
15891590
print(response)
@@ -1691,14 +1692,9 @@ async def __aexit__(self, exc_type, exc, tb):
16911692
await self.transport.close()
16921693

16931694

1694-
try:
1695-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1696-
gapic_version=pkg_resources.get_distribution(
1697-
"google-cloud-redis",
1698-
).version,
1699-
)
1700-
except pkg_resources.DistributionNotFound:
1701-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
1695+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1696+
gapic_version=package_version.__version__
1697+
)
17021698

17031699

17041700
__all__ = ("CloudRedisAsyncClient",)

packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/client.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
from google.auth.transport import mtls # type: ignore
3939
from google.auth.transport.grpc import SslCredentials # type: ignore
4040
from google.oauth2 import service_account # type: ignore
41-
import pkg_resources
41+
42+
from google.cloud.redis_v1 import gapic_version as package_version
4243

4344
try:
4445
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
@@ -471,7 +472,7 @@ def list_instances(
471472
*,
472473
parent: Optional[str] = None,
473474
retry: OptionalRetry = gapic_v1.method.DEFAULT,
474-
timeout: Optional[float] = None,
475+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
475476
metadata: Sequence[Tuple[str, str]] = (),
476477
) -> pagers.ListInstancesPager:
477478
r"""Lists all Redis instances owned by a project in either the
@@ -597,7 +598,7 @@ def get_instance(
597598
*,
598599
name: Optional[str] = None,
599600
retry: OptionalRetry = gapic_v1.method.DEFAULT,
600-
timeout: Optional[float] = None,
601+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
601602
metadata: Sequence[Tuple[str, str]] = (),
602603
) -> cloud_redis.Instance:
603604
r"""Gets the details of a specific Redis instance.
@@ -698,7 +699,7 @@ def get_instance_auth_string(
698699
*,
699700
name: Optional[str] = None,
700701
retry: OptionalRetry = gapic_v1.method.DEFAULT,
701-
timeout: Optional[float] = None,
702+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
702703
metadata: Sequence[Tuple[str, str]] = (),
703704
) -> cloud_redis.InstanceAuthString:
704705
r"""Gets the AUTH string for a Redis instance. If AUTH is
@@ -804,7 +805,7 @@ def create_instance(
804805
instance_id: Optional[str] = None,
805806
instance: Optional[cloud_redis.Instance] = None,
806807
retry: OptionalRetry = gapic_v1.method.DEFAULT,
807-
timeout: Optional[float] = None,
808+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
808809
metadata: Sequence[Tuple[str, str]] = (),
809810
) -> operation.Operation:
810811
r"""Creates a Redis instance based on the specified tier and memory
@@ -967,7 +968,7 @@ def update_instance(
967968
update_mask: Optional[field_mask_pb2.FieldMask] = None,
968969
instance: Optional[cloud_redis.Instance] = None,
969970
retry: OptionalRetry = gapic_v1.method.DEFAULT,
970-
timeout: Optional[float] = None,
971+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
971972
metadata: Sequence[Tuple[str, str]] = (),
972973
) -> operation.Operation:
973974
r"""Updates the metadata and configuration of a specific
@@ -1114,7 +1115,7 @@ def upgrade_instance(
11141115
name: Optional[str] = None,
11151116
redis_version: Optional[str] = None,
11161117
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1117-
timeout: Optional[float] = None,
1118+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
11181119
metadata: Sequence[Tuple[str, str]] = (),
11191120
) -> operation.Operation:
11201121
r"""Upgrades Redis instance to the newer Redis version
@@ -1244,7 +1245,7 @@ def import_instance(
12441245
name: Optional[str] = None,
12451246
input_config: Optional[cloud_redis.InputConfig] = None,
12461247
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1247-
timeout: Optional[float] = None,
1248+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
12481249
metadata: Sequence[Tuple[str, str]] = (),
12491250
) -> operation.Operation:
12501251
r"""Import a Redis RDB snapshot file from Cloud Storage
@@ -1384,7 +1385,7 @@ def export_instance(
13841385
name: Optional[str] = None,
13851386
output_config: Optional[cloud_redis.OutputConfig] = None,
13861387
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1387-
timeout: Optional[float] = None,
1388+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
13881389
metadata: Sequence[Tuple[str, str]] = (),
13891390
) -> operation.Operation:
13901391
r"""Export Redis instance data into a Redis RDB format
@@ -1522,7 +1523,7 @@ def failover_instance(
15221523
cloud_redis.FailoverInstanceRequest.DataProtectionMode
15231524
] = None,
15241525
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1525-
timeout: Optional[float] = None,
1526+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
15261527
metadata: Sequence[Tuple[str, str]] = (),
15271528
) -> operation.Operation:
15281529
r"""Initiates a failover of the primary node to current
@@ -1652,7 +1653,7 @@ def delete_instance(
16521653
*,
16531654
name: Optional[str] = None,
16541655
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1655-
timeout: Optional[float] = None,
1656+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
16561657
metadata: Sequence[Tuple[str, str]] = (),
16571658
) -> operation.Operation:
16581659
r"""Deletes a specific Redis instance. Instance stops
@@ -1782,7 +1783,7 @@ def reschedule_maintenance(
17821783
] = None,
17831784
schedule_time: Optional[timestamp_pb2.Timestamp] = None,
17841785
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1785-
timeout: Optional[float] = None,
1786+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
17861787
metadata: Sequence[Tuple[str, str]] = (),
17871788
) -> operation.Operation:
17881789
r"""Reschedule maintenance for a given instance in a
@@ -1929,14 +1930,9 @@ def __exit__(self, type, value, traceback):
19291930
self.transport.close()
19301931

19311932

1932-
try:
1933-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1934-
gapic_version=pkg_resources.get_distribution(
1935-
"google-cloud-redis",
1936-
).version,
1937-
)
1938-
except pkg_resources.DistributionNotFound:
1939-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
1933+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1934+
gapic_version=package_version.__version__
1935+
)
19401936

19411937

19421938
__all__ = ("CloudRedisClient",)

packages/google-cloud-redis/google/cloud/redis_v1/services/cloud_redis/transports/base.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,13 @@
2424
from google.auth import credentials as ga_credentials # type: ignore
2525
from google.longrunning import operations_pb2 # type: ignore
2626
from google.oauth2 import service_account # type: ignore
27-
import pkg_resources
2827

28+
from google.cloud.redis_v1 import gapic_version as package_version
2929
from google.cloud.redis_v1.types import cloud_redis
3030

31-
try:
32-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
33-
gapic_version=pkg_resources.get_distribution(
34-
"google-cloud-redis",
35-
).version,
36-
)
37-
except pkg_resources.DistributionNotFound:
38-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
31+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
32+
gapic_version=package_version.__version__
33+
)
3934

4035

4136
class CloudRedisTransport(abc.ABC):
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2022 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
__version__ = "2.9.3" # {x-release-please-version}

0 commit comments

Comments
 (0)