Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
fix(deps): Require google-api-core >=1.34.0, >=2.11.0 (#239)
Browse files Browse the repository at this point in the history
* 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 <partheniou@google.com>
  • Loading branch information
3 people committed Dec 6, 2022
1 parent 6572d29 commit f9d3238
Show file tree
Hide file tree
Showing 28 changed files with 140 additions and 137 deletions.
5 changes: 0 additions & 5 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,3 @@ exclude_lines =
pragma: NO COVER
# Ignore debug-only repr
def __repr__
# Ignore pkg_resources exceptions.
# This is added at the module level as a safeguard for if someone
# generates the code and tries to run it without pip installing. This
# makes it virtually impossible to test properly.
except pkg_resources.DistributionNotFound
16 changes: 16 additions & 0 deletions google/cloud/redis_v1/gapic_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.9.3" # {x-release-please-version}
52 changes: 24 additions & 28 deletions google/cloud/redis_v1/services/cloud_redis/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
from google.api_core.client_options import ClientOptions
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore
import pkg_resources

from google.cloud.redis_v1 import gapic_version as package_version

try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
Expand Down Expand Up @@ -240,7 +241,7 @@ async def list_instances(
*,
parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListInstancesAsyncPager:
r"""Lists all Redis instances owned by a project in either the
Expand Down Expand Up @@ -366,7 +367,7 @@ async def get_instance(
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_redis.Instance:
r"""Gets the details of a specific Redis instance.
Expand Down Expand Up @@ -467,7 +468,7 @@ async def get_instance_auth_string(
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_redis.InstanceAuthString:
r"""Gets the AUTH string for a Redis instance. If AUTH is
Expand Down Expand Up @@ -573,7 +574,7 @@ async def create_instance(
instance_id: Optional[str] = None,
instance: Optional[cloud_redis.Instance] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Creates a Redis instance based on the specified tier and memory
Expand Down Expand Up @@ -623,7 +624,7 @@ async def sample_create_instance():
print("Waiting for operation to complete...")
response = await operation.result()
response = (await operation).result()
# Handle the response
print(response)
Expand Down Expand Up @@ -736,7 +737,7 @@ async def update_instance(
update_mask: Optional[field_mask_pb2.FieldMask] = None,
instance: Optional[cloud_redis.Instance] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Updates the metadata and configuration of a specific
Expand Down Expand Up @@ -776,7 +777,7 @@ async def sample_update_instance():
print("Waiting for operation to complete...")
response = await operation.result()
response = (await operation).result()
# Handle the response
print(response)
Expand Down Expand Up @@ -883,7 +884,7 @@ async def upgrade_instance(
name: Optional[str] = None,
redis_version: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Upgrades Redis instance to the newer Redis version
Expand Down Expand Up @@ -915,7 +916,7 @@ async def sample_upgrade_instance():
print("Waiting for operation to complete...")
response = await operation.result()
response = (await operation).result()
# Handle the response
print(response)
Expand Down Expand Up @@ -1013,7 +1014,7 @@ async def import_instance(
name: Optional[str] = None,
input_config: Optional[cloud_redis.InputConfig] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Import a Redis RDB snapshot file from Cloud Storage
Expand Down Expand Up @@ -1055,7 +1056,7 @@ async def sample_import_instance():
print("Waiting for operation to complete...")
response = await operation.result()
response = (await operation).result()
# Handle the response
print(response)
Expand Down Expand Up @@ -1153,7 +1154,7 @@ async def export_instance(
name: Optional[str] = None,
output_config: Optional[cloud_redis.OutputConfig] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Export Redis instance data into a Redis RDB format
Expand Down Expand Up @@ -1191,7 +1192,7 @@ async def sample_export_instance():
print("Waiting for operation to complete...")
response = await operation.result()
response = (await operation).result()
# Handle the response
print(response)
Expand Down Expand Up @@ -1291,7 +1292,7 @@ async def failover_instance(
cloud_redis.FailoverInstanceRequest.DataProtectionMode
] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Initiates a failover of the primary node to current
Expand Down Expand Up @@ -1323,7 +1324,7 @@ async def sample_failover_instance():
print("Waiting for operation to complete...")
response = await operation.result()
response = (await operation).result()
# Handle the response
print(response)
Expand Down Expand Up @@ -1421,7 +1422,7 @@ async def delete_instance(
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Deletes a specific Redis instance. Instance stops
Expand Down Expand Up @@ -1452,7 +1453,7 @@ async def sample_delete_instance():
print("Waiting for operation to complete...")
response = await operation.result()
response = (await operation).result()
# Handle the response
print(response)
Expand Down Expand Up @@ -1551,7 +1552,7 @@ async def reschedule_maintenance(
] = None,
schedule_time: Optional[timestamp_pb2.Timestamp] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Reschedule maintenance for a given instance in a
Expand Down Expand Up @@ -1583,7 +1584,7 @@ async def sample_reschedule_maintenance():
print("Waiting for operation to complete...")
response = await operation.result()
response = (await operation).result()
# Handle the response
print(response)
Expand Down Expand Up @@ -1691,14 +1692,9 @@ async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-redis",
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=package_version.__version__
)


__all__ = ("CloudRedisAsyncClient",)
36 changes: 16 additions & 20 deletions google/cloud/redis_v1/services/cloud_redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
from google.auth.transport import mtls # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
from google.oauth2 import service_account # type: ignore
import pkg_resources

from google.cloud.redis_v1 import gapic_version as package_version

try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
Expand Down Expand Up @@ -471,7 +472,7 @@ def list_instances(
*,
parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListInstancesPager:
r"""Lists all Redis instances owned by a project in either the
Expand Down Expand Up @@ -597,7 +598,7 @@ def get_instance(
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_redis.Instance:
r"""Gets the details of a specific Redis instance.
Expand Down Expand Up @@ -698,7 +699,7 @@ def get_instance_auth_string(
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_redis.InstanceAuthString:
r"""Gets the AUTH string for a Redis instance. If AUTH is
Expand Down Expand Up @@ -804,7 +805,7 @@ def create_instance(
instance_id: Optional[str] = None,
instance: Optional[cloud_redis.Instance] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Creates a Redis instance based on the specified tier and memory
Expand Down Expand Up @@ -967,7 +968,7 @@ def update_instance(
update_mask: Optional[field_mask_pb2.FieldMask] = None,
instance: Optional[cloud_redis.Instance] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Updates the metadata and configuration of a specific
Expand Down Expand Up @@ -1114,7 +1115,7 @@ def upgrade_instance(
name: Optional[str] = None,
redis_version: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Upgrades Redis instance to the newer Redis version
Expand Down Expand Up @@ -1244,7 +1245,7 @@ def import_instance(
name: Optional[str] = None,
input_config: Optional[cloud_redis.InputConfig] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Import a Redis RDB snapshot file from Cloud Storage
Expand Down Expand Up @@ -1384,7 +1385,7 @@ def export_instance(
name: Optional[str] = None,
output_config: Optional[cloud_redis.OutputConfig] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Export Redis instance data into a Redis RDB format
Expand Down Expand Up @@ -1522,7 +1523,7 @@ def failover_instance(
cloud_redis.FailoverInstanceRequest.DataProtectionMode
] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Initiates a failover of the primary node to current
Expand Down Expand Up @@ -1652,7 +1653,7 @@ def delete_instance(
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Deletes a specific Redis instance. Instance stops
Expand Down Expand Up @@ -1782,7 +1783,7 @@ def reschedule_maintenance(
] = None,
schedule_time: Optional[timestamp_pb2.Timestamp] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Reschedule maintenance for a given instance in a
Expand Down Expand Up @@ -1929,14 +1930,9 @@ def __exit__(self, type, value, traceback):
self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-redis",
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=package_version.__version__
)


__all__ = ("CloudRedisClient",)
13 changes: 4 additions & 9 deletions google/cloud/redis_v1/services/cloud_redis/transports/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,13 @@
from google.auth import credentials as ga_credentials # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from google.oauth2 import service_account # type: ignore
import pkg_resources

from google.cloud.redis_v1 import gapic_version as package_version
from google.cloud.redis_v1.types import cloud_redis

try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-redis",
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=package_version.__version__
)


class CloudRedisTransport(abc.ABC):
Expand Down
16 changes: 16 additions & 0 deletions google/cloud/redis_v1beta1/gapic_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.9.3" # {x-release-please-version}
Loading

0 comments on commit f9d3238

Please sign in to comment.