From 7b7172df6ccaaa8d2ca0e64d2f45c670d1873386 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 9 Nov 2021 17:48:00 -0500 Subject: [PATCH 01/10] chore: use gapic-generator-python 0.56.2 (#138) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: update Java and Python dependencies PiperOrigin-RevId: 408420890 Source-Link: https://github.com/googleapis/googleapis/commit/2921f9fb3bfbd16f6b2da0104373e2b47a80a65e Source-Link: https://github.com/googleapis/googleapis-gen/commit/6598ca8cbbf5226733a099c4506518a5af6ff74c Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNjU5OGNhOGNiYmY1MjI2NzMzYTA5OWM0NTA2NTE4YTVhZjZmZjc0YyJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .../services/cloud_redis/async_client.py | 13 +- .../redis_v1/services/cloud_redis/client.py | 25 ++-- .../services/cloud_redis/transports/base.py | 10 +- .../services/cloud_redis/transports/grpc.py | 6 +- .../cloud_redis/transports/grpc_asyncio.py | 6 +- google/cloud/redis_v1/types/cloud_redis.py | 2 + .../services/cloud_redis/async_client.py | 13 +- .../services/cloud_redis/client.py | 25 ++-- .../services/cloud_redis/transports/base.py | 10 +- .../services/cloud_redis/transports/grpc.py | 6 +- .../cloud_redis/transports/grpc_asyncio.py | 6 +- .../cloud/redis_v1beta1/types/cloud_redis.py | 2 + tests/unit/gapic/redis_v1/test_cloud_redis.py | 134 +++++++++++++----- .../gapic/redis_v1beta1/test_cloud_redis.py | 134 +++++++++++++----- 14 files changed, 272 insertions(+), 120 deletions(-) diff --git a/google/cloud/redis_v1/services/cloud_redis/async_client.py b/google/cloud/redis_v1/services/cloud_redis/async_client.py index b6d31c7..82812c0 100644 --- a/google/cloud/redis_v1/services/cloud_redis/async_client.py +++ b/google/cloud/redis_v1/services/cloud_redis/async_client.py @@ -19,14 +19,17 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -from google.api_core.client_options import ClientOptions # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore +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.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore -OptionalRetry = Union[retries.Retry, object] +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore diff --git a/google/cloud/redis_v1/services/cloud_redis/client.py b/google/cloud/redis_v1/services/cloud_redis/client.py index a69af50..59465f5 100644 --- a/google/cloud/redis_v1/services/cloud_redis/client.py +++ b/google/cloud/redis_v1/services/cloud_redis/client.py @@ -14,23 +14,25 @@ # limitations under the License. # from collections import OrderedDict -from distutils import util import os import re from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore +from google.api_core import client_options as client_options_lib +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.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore -OptionalRetry = Union[retries.Retry, object] +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -307,8 +309,15 @@ def __init__( client_options = client_options_lib.ClientOptions() # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool( - util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) + if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( + "true", + "false", + ): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + use_client_cert = ( + os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" ) client_cert_source_func = None diff --git a/google/cloud/redis_v1/services/cloud_redis/transports/base.py b/google/cloud/redis_v1/services/cloud_redis/transports/base.py index 3199d98..3743056 100644 --- a/google/cloud/redis_v1/services/cloud_redis/transports/base.py +++ b/google/cloud/redis_v1/services/cloud_redis/transports/base.py @@ -18,11 +18,11 @@ import pkg_resources import google.auth # type: ignore -import google.api_core # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.api_core import operations_v1 # type: ignore +import google.api_core +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 operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore diff --git a/google/cloud/redis_v1/services/cloud_redis/transports/grpc.py b/google/cloud/redis_v1/services/cloud_redis/transports/grpc.py index 3c69418..5f8c011 100644 --- a/google/cloud/redis_v1/services/cloud_redis/transports/grpc.py +++ b/google/cloud/redis_v1/services/cloud_redis/transports/grpc.py @@ -16,9 +16,9 @@ import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import grpc_helpers # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers +from google.api_core import operations_v1 +from google.api_core import gapic_v1 import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore diff --git a/google/cloud/redis_v1/services/cloud_redis/transports/grpc_asyncio.py b/google/cloud/redis_v1/services/cloud_redis/transports/grpc_asyncio.py index daac696..bd7ef77 100644 --- a/google/cloud/redis_v1/services/cloud_redis/transports/grpc_asyncio.py +++ b/google/cloud/redis_v1/services/cloud_redis/transports/grpc_asyncio.py @@ -16,9 +16,9 @@ import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.api_core import operations_v1 # type: ignore +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.api_core import operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore diff --git a/google/cloud/redis_v1/types/cloud_redis.py b/google/cloud/redis_v1/types/cloud_redis.py index cd3325c..ac90de6 100644 --- a/google/cloud/redis_v1/types/cloud_redis.py +++ b/google/cloud/redis_v1/types/cloud_redis.py @@ -444,6 +444,7 @@ class InputConfig(proto.Message): gcs_source (google.cloud.redis_v1.types.GcsSource): Google Cloud Storage location where input content is located. + This field is a member of `oneof`_ ``source``. """ @@ -491,6 +492,7 @@ class OutputConfig(proto.Message): gcs_destination (google.cloud.redis_v1.types.GcsDestination): Google Cloud Storage destination for output content. + This field is a member of `oneof`_ ``destination``. """ diff --git a/google/cloud/redis_v1beta1/services/cloud_redis/async_client.py b/google/cloud/redis_v1beta1/services/cloud_redis/async_client.py index 8c93b09..7f80aca 100644 --- a/google/cloud/redis_v1beta1/services/cloud_redis/async_client.py +++ b/google/cloud/redis_v1beta1/services/cloud_redis/async_client.py @@ -19,14 +19,17 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -from google.api_core.client_options import ClientOptions # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore +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.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore -OptionalRetry = Union[retries.Retry, object] +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore diff --git a/google/cloud/redis_v1beta1/services/cloud_redis/client.py b/google/cloud/redis_v1beta1/services/cloud_redis/client.py index 532263e..2d3fb4f 100644 --- a/google/cloud/redis_v1beta1/services/cloud_redis/client.py +++ b/google/cloud/redis_v1beta1/services/cloud_redis/client.py @@ -14,23 +14,25 @@ # limitations under the License. # from collections import OrderedDict -from distutils import util import os import re from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore +from google.api_core import client_options as client_options_lib +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.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore -OptionalRetry = Union[retries.Retry, object] +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -308,8 +310,15 @@ def __init__( client_options = client_options_lib.ClientOptions() # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool( - util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) + if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( + "true", + "false", + ): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + use_client_cert = ( + os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" ) client_cert_source_func = None diff --git a/google/cloud/redis_v1beta1/services/cloud_redis/transports/base.py b/google/cloud/redis_v1beta1/services/cloud_redis/transports/base.py index d2d6c4c..d589bbe 100644 --- a/google/cloud/redis_v1beta1/services/cloud_redis/transports/base.py +++ b/google/cloud/redis_v1beta1/services/cloud_redis/transports/base.py @@ -18,11 +18,11 @@ import pkg_resources import google.auth # type: ignore -import google.api_core # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.api_core import operations_v1 # type: ignore +import google.api_core +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 operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore diff --git a/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc.py b/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc.py index 816fc2a..baf7655 100644 --- a/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc.py +++ b/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc.py @@ -16,9 +16,9 @@ import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import grpc_helpers # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers +from google.api_core import operations_v1 +from google.api_core import gapic_v1 import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore diff --git a/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc_asyncio.py b/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc_asyncio.py index c3ec320..797106f 100644 --- a/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc_asyncio.py +++ b/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc_asyncio.py @@ -16,9 +16,9 @@ import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.api_core import operations_v1 # type: ignore +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.api_core import operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore diff --git a/google/cloud/redis_v1beta1/types/cloud_redis.py b/google/cloud/redis_v1beta1/types/cloud_redis.py index f21d25e..5505e19 100644 --- a/google/cloud/redis_v1beta1/types/cloud_redis.py +++ b/google/cloud/redis_v1beta1/types/cloud_redis.py @@ -443,6 +443,7 @@ class InputConfig(proto.Message): gcs_source (google.cloud.redis_v1beta1.types.GcsSource): Google Cloud Storage location where input content is located. + This field is a member of `oneof`_ ``source``. """ @@ -490,6 +491,7 @@ class OutputConfig(proto.Message): gcs_destination (google.cloud.redis_v1beta1.types.GcsDestination): Google Cloud Storage destination for output content. + This field is a member of `oneof`_ ``destination``. """ diff --git a/tests/unit/gapic/redis_v1/test_cloud_redis.py b/tests/unit/gapic/redis_v1/test_cloud_redis.py index c00c1a2..603cda4 100644 --- a/tests/unit/gapic/redis_v1/test_cloud_redis.py +++ b/tests/unit/gapic/redis_v1/test_cloud_redis.py @@ -624,7 +624,9 @@ def test_list_instances_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val def test_list_instances_flattened_error(): @@ -658,7 +660,9 @@ async def test_list_instances_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1044,7 +1048,9 @@ def test_get_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_get_instance_flattened_error(): @@ -1078,7 +1084,9 @@ async def test_get_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1242,9 +1250,15 @@ def test_create_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].instance_id == "instance_id_value" - assert args[0].instance == cloud_redis.Instance(name="name_value") + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].instance_id + mock_val = "instance_id_value" + assert arg == mock_val + arg = args[0].instance + mock_val = cloud_redis.Instance(name="name_value") + assert arg == mock_val def test_create_instance_flattened_error(): @@ -1285,9 +1299,15 @@ async def test_create_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].instance_id == "instance_id_value" - assert args[0].instance == cloud_redis.Instance(name="name_value") + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].instance_id + mock_val = "instance_id_value" + assert arg == mock_val + arg = args[0].instance + mock_val = cloud_redis.Instance(name="name_value") + assert arg == mock_val @pytest.mark.asyncio @@ -1457,8 +1477,12 @@ def test_update_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) - assert args[0].instance == cloud_redis.Instance(name="name_value") + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + arg = args[0].instance + mock_val = cloud_redis.Instance(name="name_value") + assert arg == mock_val def test_update_instance_flattened_error(): @@ -1497,8 +1521,12 @@ async def test_update_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) - assert args[0].instance == cloud_redis.Instance(name="name_value") + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + arg = args[0].instance + mock_val = cloud_redis.Instance(name="name_value") + assert arg == mock_val @pytest.mark.asyncio @@ -1662,8 +1690,12 @@ def test_upgrade_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].redis_version == "redis_version_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].redis_version + mock_val = "redis_version_value" + assert arg == mock_val def test_upgrade_instance_flattened_error(): @@ -1701,8 +1733,12 @@ async def test_upgrade_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].redis_version == "redis_version_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].redis_version + mock_val = "redis_version_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1869,10 +1905,14 @@ def test_import_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].input_config == cloud_redis.InputConfig( + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].input_config + mock_val = cloud_redis.InputConfig( gcs_source=cloud_redis.GcsSource(uri="uri_value") ) + assert arg == mock_val def test_import_instance_flattened_error(): @@ -1915,10 +1955,14 @@ async def test_import_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].input_config == cloud_redis.InputConfig( + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].input_config + mock_val = cloud_redis.InputConfig( gcs_source=cloud_redis.GcsSource(uri="uri_value") ) + assert arg == mock_val @pytest.mark.asyncio @@ -2087,10 +2131,14 @@ def test_export_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].output_config == cloud_redis.OutputConfig( + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].output_config + mock_val = cloud_redis.OutputConfig( gcs_destination=cloud_redis.GcsDestination(uri="uri_value") ) + assert arg == mock_val def test_export_instance_flattened_error(): @@ -2133,10 +2181,14 @@ async def test_export_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].output_config == cloud_redis.OutputConfig( + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].output_config + mock_val = cloud_redis.OutputConfig( gcs_destination=cloud_redis.GcsDestination(uri="uri_value") ) + assert arg == mock_val @pytest.mark.asyncio @@ -2315,11 +2367,14 @@ def test_failover_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert ( - args[0].data_protection_mode - == cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].data_protection_mode + mock_val = ( + cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS ) + assert arg == mock_val def test_failover_instance_flattened_error(): @@ -2360,11 +2415,14 @@ async def test_failover_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert ( - args[0].data_protection_mode - == cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].data_protection_mode + mock_val = ( + cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS ) + assert arg == mock_val @pytest.mark.asyncio @@ -2526,7 +2584,9 @@ def test_delete_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_delete_instance_flattened_error(): @@ -2560,7 +2620,9 @@ async def test_delete_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio diff --git a/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py b/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py index f0d5179..4d827ef 100644 --- a/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py +++ b/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py @@ -625,7 +625,9 @@ def test_list_instances_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val def test_list_instances_flattened_error(): @@ -659,7 +661,9 @@ async def test_list_instances_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1045,7 +1049,9 @@ def test_get_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_get_instance_flattened_error(): @@ -1079,7 +1085,9 @@ async def test_get_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1243,9 +1251,15 @@ def test_create_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].instance_id == "instance_id_value" - assert args[0].instance == cloud_redis.Instance(name="name_value") + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].instance_id + mock_val = "instance_id_value" + assert arg == mock_val + arg = args[0].instance + mock_val = cloud_redis.Instance(name="name_value") + assert arg == mock_val def test_create_instance_flattened_error(): @@ -1286,9 +1300,15 @@ async def test_create_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].instance_id == "instance_id_value" - assert args[0].instance == cloud_redis.Instance(name="name_value") + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].instance_id + mock_val = "instance_id_value" + assert arg == mock_val + arg = args[0].instance + mock_val = cloud_redis.Instance(name="name_value") + assert arg == mock_val @pytest.mark.asyncio @@ -1458,8 +1478,12 @@ def test_update_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) - assert args[0].instance == cloud_redis.Instance(name="name_value") + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + arg = args[0].instance + mock_val = cloud_redis.Instance(name="name_value") + assert arg == mock_val def test_update_instance_flattened_error(): @@ -1498,8 +1522,12 @@ async def test_update_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) - assert args[0].instance == cloud_redis.Instance(name="name_value") + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + arg = args[0].instance + mock_val = cloud_redis.Instance(name="name_value") + assert arg == mock_val @pytest.mark.asyncio @@ -1663,8 +1691,12 @@ def test_upgrade_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].redis_version == "redis_version_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].redis_version + mock_val = "redis_version_value" + assert arg == mock_val def test_upgrade_instance_flattened_error(): @@ -1702,8 +1734,12 @@ async def test_upgrade_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].redis_version == "redis_version_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].redis_version + mock_val = "redis_version_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1870,10 +1906,14 @@ def test_import_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].input_config == cloud_redis.InputConfig( + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].input_config + mock_val = cloud_redis.InputConfig( gcs_source=cloud_redis.GcsSource(uri="uri_value") ) + assert arg == mock_val def test_import_instance_flattened_error(): @@ -1916,10 +1956,14 @@ async def test_import_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].input_config == cloud_redis.InputConfig( + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].input_config + mock_val = cloud_redis.InputConfig( gcs_source=cloud_redis.GcsSource(uri="uri_value") ) + assert arg == mock_val @pytest.mark.asyncio @@ -2088,10 +2132,14 @@ def test_export_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].output_config == cloud_redis.OutputConfig( + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].output_config + mock_val = cloud_redis.OutputConfig( gcs_destination=cloud_redis.GcsDestination(uri="uri_value") ) + assert arg == mock_val def test_export_instance_flattened_error(): @@ -2134,10 +2182,14 @@ async def test_export_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].output_config == cloud_redis.OutputConfig( + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].output_config + mock_val = cloud_redis.OutputConfig( gcs_destination=cloud_redis.GcsDestination(uri="uri_value") ) + assert arg == mock_val @pytest.mark.asyncio @@ -2316,11 +2368,14 @@ def test_failover_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert ( - args[0].data_protection_mode - == cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].data_protection_mode + mock_val = ( + cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS ) + assert arg == mock_val def test_failover_instance_flattened_error(): @@ -2361,11 +2416,14 @@ async def test_failover_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert ( - args[0].data_protection_mode - == cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].data_protection_mode + mock_val = ( + cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS ) + assert arg == mock_val @pytest.mark.asyncio @@ -2527,7 +2585,9 @@ def test_delete_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_delete_instance_flattened_error(): @@ -2561,7 +2621,9 @@ async def test_delete_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio From 44bfc1ba358c21979b656af015dbbcb7075559fb Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 11 Nov 2021 12:18:48 -0500 Subject: [PATCH 02/10] chore(python): add .github/CODEOWNERS as a templated file (#139) Source-Link: https://github.com/googleapis/synthtool/commit/c5026b3217973a8db55db8ee85feee0e9a65e295 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:0e18b9475fbeb12d9ad4302283171edebb6baf2dfca1bd215ee3b34ed79d95d7 Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 2 +- .github/CODEOWNERS | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 108063d..7519fa3 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:4ee57a76a176ede9087c14330c625a71553cf9c72828b2c0ca12f5338171ba60 + digest: sha256:0e18b9475fbeb12d9ad4302283171edebb6baf2dfca1bd215ee3b34ed79d95d7 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 30c3973..44cc868 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -3,9 +3,10 @@ # # For syntax help see: # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax +# Note: This file is autogenerated. To make changes to the codeowner team, please update .repo-metadata.json. -# The @googleapis/yoshi-python is the default owner for changes in this repo -* @googleapis/yoshi-python +# @googleapis/yoshi-python is the default owner for changes in this repo +* @googleapis/yoshi-python -# The python-samples-reviewers team is the default owner for samples changes -/samples/ @googleapis/python-samples-owners \ No newline at end of file +# @googleapis/python-samples-owners is the default owner for samples changes +/samples/ @googleapis/python-samples-owners From 443ca03e5418f4740692bb81ba82edb5afc690fb Mon Sep 17 00:00:00 2001 From: Dan Lee <71398022+dandhlee@users.noreply.github.com> Date: Tue, 16 Nov 2021 11:05:35 -0500 Subject: [PATCH 03/10] chore: update doc links from googleapis.dev to cloud.google.com (#140) --- .repo-metadata.json | 2 +- README.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.repo-metadata.json b/.repo-metadata.json index 65f0a08..ca1e988 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -2,7 +2,7 @@ "name": "redis", "name_pretty": "Cloud Redis", "product_documentation": "https://cloud.google.com/memorystore/docs/redis/", - "client_documentation": "https://googleapis.dev/python/redis/latest", + "client_documentation": "https://cloud.google.com/python/docs/reference/redis/latest", "issue_tracker": "https://issuetracker.google.com/savedsearches/5169231", "release_level": "ga", "language": "python", diff --git a/README.rst b/README.rst index 06588d1..d906d31 100644 --- a/README.rst +++ b/README.rst @@ -17,7 +17,7 @@ Cloud Platform. .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-redis.svg :target: https://pypi.org/project/google-cloud-redis/ .. _Google Cloud Memorystore for Redis API: https://cloud.google.com/memorystore/ -.. _Client Library Documentation: https://googleapis.dev/python/redis/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/redis/latest .. _Product Documentation: https://cloud.google.com/memorystore/ Quick Start From 9c0cd3dc619557e6f73e418f0af16f38cfdcfc44 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 28 Dec 2021 13:15:40 -0500 Subject: [PATCH 04/10] chore: update .repo-metadata.json (#143) --- .repo-metadata.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.repo-metadata.json b/.repo-metadata.json index ca1e988..93d229a 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -4,7 +4,7 @@ "product_documentation": "https://cloud.google.com/memorystore/docs/redis/", "client_documentation": "https://cloud.google.com/python/docs/reference/redis/latest", "issue_tracker": "https://issuetracker.google.com/savedsearches/5169231", - "release_level": "ga", + "release_level": "stable", "language": "python", "library_type": "GAPIC_AUTO", "repo": "googleapis/python-redis", @@ -12,5 +12,6 @@ "api_id": "redis.googleapis.com", "requires_billing": true, "default_version": "v1", - "codeowner_team": "" + "codeowner_team": "", + "api_shortname": "redis" } From 6e91a3c2543f8de9c6aa4f3c6f45e842aa4decd5 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 6 Jan 2022 17:20:14 +0000 Subject: [PATCH 05/10] chore: use python-samples-reviewers (#145) --- .github/.OwlBot.lock.yaml | 2 +- .github/CODEOWNERS | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 7519fa3..f33299d 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:0e18b9475fbeb12d9ad4302283171edebb6baf2dfca1bd215ee3b34ed79d95d7 + digest: sha256:899d5d7cc340fa8ef9d8ae1a8cfba362c6898584f779e156f25ee828ba824610 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 44cc868..e446644 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -8,5 +8,5 @@ # @googleapis/yoshi-python is the default owner for changes in this repo * @googleapis/yoshi-python -# @googleapis/python-samples-owners is the default owner for samples changes -/samples/ @googleapis/python-samples-owners +# @googleapis/python-samples-reviewers is the default owner for samples changes +/samples/ @googleapis/python-samples-reviewers From 15511591bb36835da68e0135b74ffe957a0e08fd Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 8 Jan 2022 05:31:26 -0500 Subject: [PATCH 06/10] chore: use gapic-generator-python 0.58.4 (#144) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: use gapic-generator-python 0.58.4 fix: provide appropriate mock values for message body fields committer: dovs PiperOrigin-RevId: 419025932 Source-Link: https://github.com/googleapis/googleapis/commit/73da6697f598f1ba30618924936a59f8e457ec89 Source-Link: https://github.com/googleapis/googleapis-gen/commit/46df624a54b9ed47c1a7eefb7a49413cf7b82f98 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDZkZjYyNGE1NGI5ZWQ0N2MxYTdlZWZiN2E0OTQxM2NmN2I4MmY5OCJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .../services/cloud_redis/transports/base.py | 1 - .../services/cloud_redis/transports/base.py | 1 - tests/unit/gapic/redis_v1/test_cloud_redis.py | 107 ++++++------------ .../gapic/redis_v1beta1/test_cloud_redis.py | 107 ++++++------------ 4 files changed, 66 insertions(+), 150 deletions(-) diff --git a/google/cloud/redis_v1/services/cloud_redis/transports/base.py b/google/cloud/redis_v1/services/cloud_redis/transports/base.py index 3743056..9bca155 100644 --- a/google/cloud/redis_v1/services/cloud_redis/transports/base.py +++ b/google/cloud/redis_v1/services/cloud_redis/transports/base.py @@ -101,7 +101,6 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id diff --git a/google/cloud/redis_v1beta1/services/cloud_redis/transports/base.py b/google/cloud/redis_v1beta1/services/cloud_redis/transports/base.py index d589bbe..11a1f97 100644 --- a/google/cloud/redis_v1beta1/services/cloud_redis/transports/base.py +++ b/google/cloud/redis_v1beta1/services/cloud_redis/transports/base.py @@ -101,7 +101,6 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id diff --git a/tests/unit/gapic/redis_v1/test_cloud_redis.py b/tests/unit/gapic/redis_v1/test_cloud_redis.py index 603cda4..0bb24ae 100644 --- a/tests/unit/gapic/redis_v1/test_cloud_redis.py +++ b/tests/unit/gapic/redis_v1/test_cloud_redis.py @@ -243,20 +243,20 @@ def test_cloud_redis_client_client_options( # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -313,7 +313,7 @@ def test_cloud_redis_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -408,7 +408,7 @@ def test_cloud_redis_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -439,7 +439,7 @@ def test_cloud_redis_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -470,9 +470,8 @@ def test_cloud_redis_client_client_options_from_dict(): ) -def test_list_instances( - transport: str = "grpc", request_type=cloud_redis.ListInstancesRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.ListInstancesRequest, dict,]) +def test_list_instances(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -500,10 +499,6 @@ def test_list_instances( assert response.unreachable == ["unreachable_value"] -def test_list_instances_from_dict(): - test_list_instances(request_type=dict) - - def test_list_instances_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -677,8 +672,10 @@ async def test_list_instances_flattened_error_async(): ) -def test_list_instances_pager(): - client = CloudRedisClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_instances_pager(transport_name: str = "grpc"): + client = CloudRedisClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_instances), "__call__") as call: @@ -715,8 +712,10 @@ def test_list_instances_pager(): assert all(isinstance(i, cloud_redis.Instance) for i in results) -def test_list_instances_pages(): - client = CloudRedisClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_instances_pages(transport_name: str = "grpc"): + client = CloudRedisClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_instances), "__call__") as call: @@ -815,9 +814,8 @@ async def test_list_instances_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_instance( - transport: str = "grpc", request_type=cloud_redis.GetInstanceRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.GetInstanceRequest, dict,]) +def test_get_instance(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -885,10 +883,6 @@ def test_get_instance( ) -def test_get_instance_from_dict(): - test_get_instance(request_type=dict) - - def test_get_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1101,9 +1095,8 @@ async def test_get_instance_flattened_error_async(): ) -def test_create_instance( - transport: str = "grpc", request_type=cloud_redis.CreateInstanceRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.CreateInstanceRequest, dict,]) +def test_create_instance(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1127,10 +1120,6 @@ def test_create_instance( assert isinstance(response, future.Future) -def test_create_instance_from_dict(): - test_create_instance(request_type=dict) - - def test_create_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1325,9 +1314,8 @@ async def test_create_instance_flattened_error_async(): ) -def test_update_instance( - transport: str = "grpc", request_type=cloud_redis.UpdateInstanceRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.UpdateInstanceRequest, dict,]) +def test_update_instance(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1351,10 +1339,6 @@ def test_update_instance( assert isinstance(response, future.Future) -def test_update_instance_from_dict(): - test_update_instance(request_type=dict) - - def test_update_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1543,9 +1527,8 @@ async def test_update_instance_flattened_error_async(): ) -def test_upgrade_instance( - transport: str = "grpc", request_type=cloud_redis.UpgradeInstanceRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.UpgradeInstanceRequest, dict,]) +def test_upgrade_instance(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1569,10 +1552,6 @@ def test_upgrade_instance( assert isinstance(response, future.Future) -def test_upgrade_instance_from_dict(): - test_upgrade_instance(request_type=dict) - - def test_upgrade_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1755,9 +1734,8 @@ async def test_upgrade_instance_flattened_error_async(): ) -def test_import_instance( - transport: str = "grpc", request_type=cloud_redis.ImportInstanceRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.ImportInstanceRequest, dict,]) +def test_import_instance(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1781,10 +1759,6 @@ def test_import_instance( assert isinstance(response, future.Future) -def test_import_instance_from_dict(): - test_import_instance(request_type=dict) - - def test_import_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1981,9 +1955,8 @@ async def test_import_instance_flattened_error_async(): ) -def test_export_instance( - transport: str = "grpc", request_type=cloud_redis.ExportInstanceRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.ExportInstanceRequest, dict,]) +def test_export_instance(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2007,10 +1980,6 @@ def test_export_instance( assert isinstance(response, future.Future) -def test_export_instance_from_dict(): - test_export_instance(request_type=dict) - - def test_export_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2207,9 +2176,8 @@ async def test_export_instance_flattened_error_async(): ) -def test_failover_instance( - transport: str = "grpc", request_type=cloud_redis.FailoverInstanceRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.FailoverInstanceRequest, dict,]) +def test_failover_instance(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2235,10 +2203,6 @@ def test_failover_instance( assert isinstance(response, future.Future) -def test_failover_instance_from_dict(): - test_failover_instance(request_type=dict) - - def test_failover_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2439,9 +2403,8 @@ async def test_failover_instance_flattened_error_async(): ) -def test_delete_instance( - transport: str = "grpc", request_type=cloud_redis.DeleteInstanceRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.DeleteInstanceRequest, dict,]) +def test_delete_instance(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2465,10 +2428,6 @@ def test_delete_instance( assert isinstance(response, future.Future) -def test_delete_instance_from_dict(): - test_delete_instance(request_type=dict) - - def test_delete_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -3173,7 +3132,7 @@ def test_parse_common_location_path(): assert expected == actual -def test_client_withDEFAULT_CLIENT_INFO(): +def test_client_with_default_client_info(): client_info = gapic_v1.client_info.ClientInfo() with mock.patch.object( diff --git a/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py b/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py index 4d827ef..cc0f921 100644 --- a/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py +++ b/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py @@ -244,20 +244,20 @@ def test_cloud_redis_client_client_options( # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -314,7 +314,7 @@ def test_cloud_redis_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -409,7 +409,7 @@ def test_cloud_redis_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -440,7 +440,7 @@ def test_cloud_redis_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -471,9 +471,8 @@ def test_cloud_redis_client_client_options_from_dict(): ) -def test_list_instances( - transport: str = "grpc", request_type=cloud_redis.ListInstancesRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.ListInstancesRequest, dict,]) +def test_list_instances(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -501,10 +500,6 @@ def test_list_instances( assert response.unreachable == ["unreachable_value"] -def test_list_instances_from_dict(): - test_list_instances(request_type=dict) - - def test_list_instances_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -678,8 +673,10 @@ async def test_list_instances_flattened_error_async(): ) -def test_list_instances_pager(): - client = CloudRedisClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_instances_pager(transport_name: str = "grpc"): + client = CloudRedisClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_instances), "__call__") as call: @@ -716,8 +713,10 @@ def test_list_instances_pager(): assert all(isinstance(i, cloud_redis.Instance) for i in results) -def test_list_instances_pages(): - client = CloudRedisClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_instances_pages(transport_name: str = "grpc"): + client = CloudRedisClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_instances), "__call__") as call: @@ -816,9 +815,8 @@ async def test_list_instances_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_instance( - transport: str = "grpc", request_type=cloud_redis.GetInstanceRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.GetInstanceRequest, dict,]) +def test_get_instance(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -886,10 +884,6 @@ def test_get_instance( ) -def test_get_instance_from_dict(): - test_get_instance(request_type=dict) - - def test_get_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1102,9 +1096,8 @@ async def test_get_instance_flattened_error_async(): ) -def test_create_instance( - transport: str = "grpc", request_type=cloud_redis.CreateInstanceRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.CreateInstanceRequest, dict,]) +def test_create_instance(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1128,10 +1121,6 @@ def test_create_instance( assert isinstance(response, future.Future) -def test_create_instance_from_dict(): - test_create_instance(request_type=dict) - - def test_create_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1326,9 +1315,8 @@ async def test_create_instance_flattened_error_async(): ) -def test_update_instance( - transport: str = "grpc", request_type=cloud_redis.UpdateInstanceRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.UpdateInstanceRequest, dict,]) +def test_update_instance(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1352,10 +1340,6 @@ def test_update_instance( assert isinstance(response, future.Future) -def test_update_instance_from_dict(): - test_update_instance(request_type=dict) - - def test_update_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1544,9 +1528,8 @@ async def test_update_instance_flattened_error_async(): ) -def test_upgrade_instance( - transport: str = "grpc", request_type=cloud_redis.UpgradeInstanceRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.UpgradeInstanceRequest, dict,]) +def test_upgrade_instance(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1570,10 +1553,6 @@ def test_upgrade_instance( assert isinstance(response, future.Future) -def test_upgrade_instance_from_dict(): - test_upgrade_instance(request_type=dict) - - def test_upgrade_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1756,9 +1735,8 @@ async def test_upgrade_instance_flattened_error_async(): ) -def test_import_instance( - transport: str = "grpc", request_type=cloud_redis.ImportInstanceRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.ImportInstanceRequest, dict,]) +def test_import_instance(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1782,10 +1760,6 @@ def test_import_instance( assert isinstance(response, future.Future) -def test_import_instance_from_dict(): - test_import_instance(request_type=dict) - - def test_import_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1982,9 +1956,8 @@ async def test_import_instance_flattened_error_async(): ) -def test_export_instance( - transport: str = "grpc", request_type=cloud_redis.ExportInstanceRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.ExportInstanceRequest, dict,]) +def test_export_instance(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2008,10 +1981,6 @@ def test_export_instance( assert isinstance(response, future.Future) -def test_export_instance_from_dict(): - test_export_instance(request_type=dict) - - def test_export_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2208,9 +2177,8 @@ async def test_export_instance_flattened_error_async(): ) -def test_failover_instance( - transport: str = "grpc", request_type=cloud_redis.FailoverInstanceRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.FailoverInstanceRequest, dict,]) +def test_failover_instance(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2236,10 +2204,6 @@ def test_failover_instance( assert isinstance(response, future.Future) -def test_failover_instance_from_dict(): - test_failover_instance(request_type=dict) - - def test_failover_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2440,9 +2404,8 @@ async def test_failover_instance_flattened_error_async(): ) -def test_delete_instance( - transport: str = "grpc", request_type=cloud_redis.DeleteInstanceRequest -): +@pytest.mark.parametrize("request_type", [cloud_redis.DeleteInstanceRequest, dict,]) +def test_delete_instance(request_type, transport: str = "grpc"): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2466,10 +2429,6 @@ def test_delete_instance( assert isinstance(response, future.Future) -def test_delete_instance_from_dict(): - test_delete_instance(request_type=dict) - - def test_delete_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -3174,7 +3133,7 @@ def test_parse_common_location_path(): assert expected == actual -def test_client_withDEFAULT_CLIENT_INFO(): +def test_client_with_default_client_info(): client_info = gapic_v1.client_info.ClientInfo() with mock.patch.object( From f04a02e81a8a449bdcf07f5725778425242fe16e Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 13 Jan 2022 19:31:29 -0500 Subject: [PATCH 07/10] fix: Add missing fields for TLS and Maintenance Window features (#147) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: [Cloud Memorystore for Redis] Add missing fields for TLS and Maintenance Window features PiperOrigin-RevId: 421360191 Source-Link: https://github.com/googleapis/googleapis/commit/3e958c3640b2b1ca7a4e369ea0b88c9e1e765687 Source-Link: https://github.com/googleapis/googleapis-gen/commit/f6580f02343d8adb49c170f8e9160113bfbbd2b3 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZjY1ODBmMDIzNDNkOGFkYjQ5YzE3MGY4ZTkxNjAxMTNiZmJiZDJiMyJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- google/cloud/redis_v1beta1/__init__.py | 14 + .../cloud/redis_v1beta1/gapic_metadata.json | 20 + .../services/cloud_redis/async_client.py | 180 ++++++- .../services/cloud_redis/client.py | 180 ++++++- .../services/cloud_redis/transports/base.py | 30 ++ .../services/cloud_redis/transports/grpc.py | 58 +++ .../cloud_redis/transports/grpc_asyncio.py | 61 +++ google/cloud/redis_v1beta1/types/__init__.py | 14 + .../cloud/redis_v1beta1/types/cloud_redis.py | 222 ++++++++- scripts/fixup_redis_v1beta1_keywords.py | 2 + .../gapic/redis_v1beta1/test_cloud_redis.py | 469 ++++++++++++++++++ 11 files changed, 1244 insertions(+), 6 deletions(-) diff --git a/google/cloud/redis_v1beta1/__init__.py b/google/cloud/redis_v1beta1/__init__.py index 03305e4..e1bb903 100644 --- a/google/cloud/redis_v1beta1/__init__.py +++ b/google/cloud/redis_v1beta1/__init__.py @@ -23,17 +23,24 @@ from .types.cloud_redis import FailoverInstanceRequest from .types.cloud_redis import GcsDestination from .types.cloud_redis import GcsSource +from .types.cloud_redis import GetInstanceAuthStringRequest from .types.cloud_redis import GetInstanceRequest from .types.cloud_redis import ImportInstanceRequest from .types.cloud_redis import InputConfig from .types.cloud_redis import Instance +from .types.cloud_redis import InstanceAuthString from .types.cloud_redis import ListInstancesRequest from .types.cloud_redis import ListInstancesResponse from .types.cloud_redis import LocationMetadata +from .types.cloud_redis import MaintenancePolicy +from .types.cloud_redis import MaintenanceSchedule from .types.cloud_redis import NodeInfo from .types.cloud_redis import OutputConfig +from .types.cloud_redis import RescheduleMaintenanceRequest +from .types.cloud_redis import TlsCertificate from .types.cloud_redis import UpdateInstanceRequest from .types.cloud_redis import UpgradeInstanceRequest +from .types.cloud_redis import WeeklyMaintenanceWindow from .types.cloud_redis import ZoneMetadata __all__ = ( @@ -45,16 +52,23 @@ "FailoverInstanceRequest", "GcsDestination", "GcsSource", + "GetInstanceAuthStringRequest", "GetInstanceRequest", "ImportInstanceRequest", "InputConfig", "Instance", + "InstanceAuthString", "ListInstancesRequest", "ListInstancesResponse", "LocationMetadata", + "MaintenancePolicy", + "MaintenanceSchedule", "NodeInfo", "OutputConfig", + "RescheduleMaintenanceRequest", + "TlsCertificate", "UpdateInstanceRequest", "UpgradeInstanceRequest", + "WeeklyMaintenanceWindow", "ZoneMetadata", ) diff --git a/google/cloud/redis_v1beta1/gapic_metadata.json b/google/cloud/redis_v1beta1/gapic_metadata.json index 5bb1784..32db0d6 100644 --- a/google/cloud/redis_v1beta1/gapic_metadata.json +++ b/google/cloud/redis_v1beta1/gapic_metadata.json @@ -35,6 +35,11 @@ "get_instance" ] }, + "GetInstanceAuthString": { + "methods": [ + "get_instance_auth_string" + ] + }, "ImportInstance": { "methods": [ "import_instance" @@ -45,6 +50,11 @@ "list_instances" ] }, + "RescheduleMaintenance": { + "methods": [ + "reschedule_maintenance" + ] + }, "UpdateInstance": { "methods": [ "update_instance" @@ -85,6 +95,11 @@ "get_instance" ] }, + "GetInstanceAuthString": { + "methods": [ + "get_instance_auth_string" + ] + }, "ImportInstance": { "methods": [ "import_instance" @@ -95,6 +110,11 @@ "list_instances" ] }, + "RescheduleMaintenance": { + "methods": [ + "reschedule_maintenance" + ] + }, "UpdateInstance": { "methods": [ "update_instance" diff --git a/google/cloud/redis_v1beta1/services/cloud_redis/async_client.py b/google/cloud/redis_v1beta1/services/cloud_redis/async_client.py index 7f80aca..0337505 100644 --- a/google/cloud/redis_v1beta1/services/cloud_redis/async_client.py +++ b/google/cloud/redis_v1beta1/services/cloud_redis/async_client.py @@ -229,7 +229,7 @@ async def list_instances( Returns: google.cloud.redis_v1beta1.services.cloud_redis.pagers.ListInstancesAsyncPager: Response for - [ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances]. + [ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances]. Iterating over this object will yield results and resolve additional pages automatically. @@ -348,6 +348,79 @@ async def get_instance( # Done; return the response. return response + async def get_instance_auth_string( + self, + request: Union[cloud_redis.GetInstanceAuthStringRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> cloud_redis.InstanceAuthString: + r"""Gets the AUTH string for a Redis instance. If AUTH is + not enabled for the instance the response will be empty. + This information is not included in the details returned + to GetInstance. + + Args: + request (Union[google.cloud.redis_v1beta1.types.GetInstanceAuthStringRequest, dict]): + The request object. Request for + [GetInstanceAuthString][google.cloud.redis.v1beta1.CloudRedis.GetInstanceAuthString]. + name (:class:`str`): + Required. Redis instance resource name using the form: + ``projects/{project_id}/locations/{location_id}/instances/{instance_id}`` + where ``location_id`` refers to a GCP region. + + This corresponds to the ``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, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.redis_v1beta1.types.InstanceAuthString: + Instance AUTH string details. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = cloud_redis.GetInstanceAuthStringRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_instance_auth_string, + default_timeout=600.0, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + async def create_instance( self, request: Union[cloud_redis.CreateInstanceRequest, dict] = None, @@ -1059,6 +1132,111 @@ async def delete_instance( # Done; return the response. return response + async def reschedule_maintenance( + self, + request: Union[cloud_redis.RescheduleMaintenanceRequest, dict] = None, + *, + name: str = None, + reschedule_type: cloud_redis.RescheduleMaintenanceRequest.RescheduleType = None, + schedule_time: timestamp_pb2.Timestamp = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Reschedule maintenance for a given instance in a + given project and location. + + Args: + request (Union[google.cloud.redis_v1beta1.types.RescheduleMaintenanceRequest, dict]): + The request object. Request for + [RescheduleMaintenance][google.cloud.redis.v1beta1.CloudRedis.RescheduleMaintenance]. + name (:class:`str`): + Required. Redis instance resource name using the form: + ``projects/{project_id}/locations/{location_id}/instances/{instance_id}`` + where ``location_id`` refers to a GCP region. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + reschedule_type (:class:`google.cloud.redis_v1beta1.types.RescheduleMaintenanceRequest.RescheduleType`): + Required. If reschedule type is SPECIFIC_TIME, must set + up schedule_time as well. + + This corresponds to the ``reschedule_type`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + schedule_time (:class:`google.protobuf.timestamp_pb2.Timestamp`): + Optional. Timestamp when the maintenance shall be + rescheduled to if reschedule_type=SPECIFIC_TIME, in RFC + 3339 format, for example ``2012-11-15T16:19:00.094Z``. + + This corresponds to the ``schedule_time`` 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, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.redis_v1beta1.types.Instance` A + Google Cloud Redis instance. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name, reschedule_type, schedule_time]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = cloud_redis.RescheduleMaintenanceRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + if reschedule_type is not None: + request.reschedule_type = reschedule_type + if schedule_time is not None: + request.schedule_time = schedule_time + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.reschedule_maintenance, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + cloud_redis.Instance, + metadata_type=any_pb2.Any, + ) + + # Done; return the response. + return response + async def __aenter__(self): return self diff --git a/google/cloud/redis_v1beta1/services/cloud_redis/client.py b/google/cloud/redis_v1beta1/services/cloud_redis/client.py index 2d3fb4f..0a0236d 100644 --- a/google/cloud/redis_v1beta1/services/cloud_redis/client.py +++ b/google/cloud/redis_v1beta1/services/cloud_redis/client.py @@ -425,7 +425,7 @@ def list_instances( Returns: google.cloud.redis_v1beta1.services.cloud_redis.pagers.ListInstancesPager: Response for - [ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances]. + [ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances]. Iterating over this object will yield results and resolve additional pages automatically. @@ -544,6 +544,79 @@ def get_instance( # Done; return the response. return response + def get_instance_auth_string( + self, + request: Union[cloud_redis.GetInstanceAuthStringRequest, dict] = None, + *, + name: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> cloud_redis.InstanceAuthString: + r"""Gets the AUTH string for a Redis instance. If AUTH is + not enabled for the instance the response will be empty. + This information is not included in the details returned + to GetInstance. + + Args: + request (Union[google.cloud.redis_v1beta1.types.GetInstanceAuthStringRequest, dict]): + The request object. Request for + [GetInstanceAuthString][google.cloud.redis.v1beta1.CloudRedis.GetInstanceAuthString]. + name (str): + Required. Redis instance resource name using the form: + ``projects/{project_id}/locations/{location_id}/instances/{instance_id}`` + where ``location_id`` refers to a GCP region. + + This corresponds to the ``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, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.redis_v1beta1.types.InstanceAuthString: + Instance AUTH string details. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a cloud_redis.GetInstanceAuthStringRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, cloud_redis.GetInstanceAuthStringRequest): + request = cloud_redis.GetInstanceAuthStringRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_instance_auth_string] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + def create_instance( self, request: Union[cloud_redis.CreateInstanceRequest, dict] = None, @@ -1255,6 +1328,111 @@ def delete_instance( # Done; return the response. return response + def reschedule_maintenance( + self, + request: Union[cloud_redis.RescheduleMaintenanceRequest, dict] = None, + *, + name: str = None, + reschedule_type: cloud_redis.RescheduleMaintenanceRequest.RescheduleType = None, + schedule_time: timestamp_pb2.Timestamp = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Reschedule maintenance for a given instance in a + given project and location. + + Args: + request (Union[google.cloud.redis_v1beta1.types.RescheduleMaintenanceRequest, dict]): + The request object. Request for + [RescheduleMaintenance][google.cloud.redis.v1beta1.CloudRedis.RescheduleMaintenance]. + name (str): + Required. Redis instance resource name using the form: + ``projects/{project_id}/locations/{location_id}/instances/{instance_id}`` + where ``location_id`` refers to a GCP region. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + reschedule_type (google.cloud.redis_v1beta1.types.RescheduleMaintenanceRequest.RescheduleType): + Required. If reschedule type is SPECIFIC_TIME, must set + up schedule_time as well. + + This corresponds to the ``reschedule_type`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + schedule_time (google.protobuf.timestamp_pb2.Timestamp): + Optional. Timestamp when the maintenance shall be + rescheduled to if reschedule_type=SPECIFIC_TIME, in RFC + 3339 format, for example ``2012-11-15T16:19:00.094Z``. + + This corresponds to the ``schedule_time`` 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, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.redis_v1beta1.types.Instance` A + Google Cloud Redis instance. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name, reschedule_type, schedule_time]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a cloud_redis.RescheduleMaintenanceRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, cloud_redis.RescheduleMaintenanceRequest): + request = cloud_redis.RescheduleMaintenanceRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + if reschedule_type is not None: + request.reschedule_type = reschedule_type + if schedule_time is not None: + request.schedule_time = schedule_time + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.reschedule_maintenance] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + cloud_redis.Instance, + metadata_type=any_pb2.Any, + ) + + # Done; return the response. + return response + def __enter__(self): return self diff --git a/google/cloud/redis_v1beta1/services/cloud_redis/transports/base.py b/google/cloud/redis_v1beta1/services/cloud_redis/transports/base.py index 11a1f97..afa65b6 100644 --- a/google/cloud/redis_v1beta1/services/cloud_redis/transports/base.py +++ b/google/cloud/redis_v1beta1/services/cloud_redis/transports/base.py @@ -126,6 +126,11 @@ def _prep_wrapped_messages(self, client_info): self.get_instance: gapic_v1.method.wrap_method( self.get_instance, default_timeout=600.0, client_info=client_info, ), + self.get_instance_auth_string: gapic_v1.method.wrap_method( + self.get_instance_auth_string, + default_timeout=600.0, + client_info=client_info, + ), self.create_instance: gapic_v1.method.wrap_method( self.create_instance, default_timeout=600.0, client_info=client_info, ), @@ -147,6 +152,11 @@ def _prep_wrapped_messages(self, client_info): self.delete_instance: gapic_v1.method.wrap_method( self.delete_instance, default_timeout=600.0, client_info=client_info, ), + self.reschedule_maintenance: gapic_v1.method.wrap_method( + self.reschedule_maintenance, + default_timeout=None, + client_info=client_info, + ), } def close(self): @@ -184,6 +194,17 @@ def get_instance( ]: raise NotImplementedError() + @property + def get_instance_auth_string( + self, + ) -> Callable[ + [cloud_redis.GetInstanceAuthStringRequest], + Union[ + cloud_redis.InstanceAuthString, Awaitable[cloud_redis.InstanceAuthString] + ], + ]: + raise NotImplementedError() + @property def create_instance( self, @@ -247,5 +268,14 @@ def delete_instance( ]: raise NotImplementedError() + @property + def reschedule_maintenance( + self, + ) -> Callable[ + [cloud_redis.RescheduleMaintenanceRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + __all__ = ("CloudRedisTransport",) diff --git a/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc.py b/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc.py index baf7655..cf71661 100644 --- a/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc.py +++ b/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc.py @@ -325,6 +325,37 @@ def get_instance( ) return self._stubs["get_instance"] + @property + def get_instance_auth_string( + self, + ) -> Callable[ + [cloud_redis.GetInstanceAuthStringRequest], cloud_redis.InstanceAuthString + ]: + r"""Return a callable for the get instance auth string method over gRPC. + + Gets the AUTH string for a Redis instance. If AUTH is + not enabled for the instance the response will be empty. + This information is not included in the details returned + to GetInstance. + + Returns: + Callable[[~.GetInstanceAuthStringRequest], + ~.InstanceAuthString]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_instance_auth_string" not in self._stubs: + self._stubs["get_instance_auth_string"] = self.grpc_channel.unary_unary( + "/google.cloud.redis.v1beta1.CloudRedis/GetInstanceAuthString", + request_serializer=cloud_redis.GetInstanceAuthStringRequest.serialize, + response_deserializer=cloud_redis.InstanceAuthString.deserialize, + ) + return self._stubs["get_instance_auth_string"] + @property def create_instance( self, @@ -541,6 +572,33 @@ def delete_instance( ) return self._stubs["delete_instance"] + @property + def reschedule_maintenance( + self, + ) -> Callable[[cloud_redis.RescheduleMaintenanceRequest], operations_pb2.Operation]: + r"""Return a callable for the reschedule maintenance method over gRPC. + + Reschedule maintenance for a given instance in a + given project and location. + + Returns: + Callable[[~.RescheduleMaintenanceRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "reschedule_maintenance" not in self._stubs: + self._stubs["reschedule_maintenance"] = self.grpc_channel.unary_unary( + "/google.cloud.redis.v1beta1.CloudRedis/RescheduleMaintenance", + request_serializer=cloud_redis.RescheduleMaintenanceRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["reschedule_maintenance"] + def close(self): self.grpc_channel.close() diff --git a/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc_asyncio.py b/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc_asyncio.py index 797106f..df23fdb 100644 --- a/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc_asyncio.py +++ b/google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc_asyncio.py @@ -329,6 +329,38 @@ def get_instance( ) return self._stubs["get_instance"] + @property + def get_instance_auth_string( + self, + ) -> Callable[ + [cloud_redis.GetInstanceAuthStringRequest], + Awaitable[cloud_redis.InstanceAuthString], + ]: + r"""Return a callable for the get instance auth string method over gRPC. + + Gets the AUTH string for a Redis instance. If AUTH is + not enabled for the instance the response will be empty. + This information is not included in the details returned + to GetInstance. + + Returns: + Callable[[~.GetInstanceAuthStringRequest], + Awaitable[~.InstanceAuthString]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_instance_auth_string" not in self._stubs: + self._stubs["get_instance_auth_string"] = self.grpc_channel.unary_unary( + "/google.cloud.redis.v1beta1.CloudRedis/GetInstanceAuthString", + request_serializer=cloud_redis.GetInstanceAuthStringRequest.serialize, + response_deserializer=cloud_redis.InstanceAuthString.deserialize, + ) + return self._stubs["get_instance_auth_string"] + @property def create_instance( self, @@ -559,6 +591,35 @@ def delete_instance( ) return self._stubs["delete_instance"] + @property + def reschedule_maintenance( + self, + ) -> Callable[ + [cloud_redis.RescheduleMaintenanceRequest], Awaitable[operations_pb2.Operation] + ]: + r"""Return a callable for the reschedule maintenance method over gRPC. + + Reschedule maintenance for a given instance in a + given project and location. + + Returns: + Callable[[~.RescheduleMaintenanceRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "reschedule_maintenance" not in self._stubs: + self._stubs["reschedule_maintenance"] = self.grpc_channel.unary_unary( + "/google.cloud.redis.v1beta1.CloudRedis/RescheduleMaintenance", + request_serializer=cloud_redis.RescheduleMaintenanceRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["reschedule_maintenance"] + def close(self): return self.grpc_channel.close() diff --git a/google/cloud/redis_v1beta1/types/__init__.py b/google/cloud/redis_v1beta1/types/__init__.py index 23c4999..da5800f 100644 --- a/google/cloud/redis_v1beta1/types/__init__.py +++ b/google/cloud/redis_v1beta1/types/__init__.py @@ -20,17 +20,24 @@ FailoverInstanceRequest, GcsDestination, GcsSource, + GetInstanceAuthStringRequest, GetInstanceRequest, ImportInstanceRequest, InputConfig, Instance, + InstanceAuthString, ListInstancesRequest, ListInstancesResponse, LocationMetadata, + MaintenancePolicy, + MaintenanceSchedule, NodeInfo, OutputConfig, + RescheduleMaintenanceRequest, + TlsCertificate, UpdateInstanceRequest, UpgradeInstanceRequest, + WeeklyMaintenanceWindow, ZoneMetadata, ) @@ -41,16 +48,23 @@ "FailoverInstanceRequest", "GcsDestination", "GcsSource", + "GetInstanceAuthStringRequest", "GetInstanceRequest", "ImportInstanceRequest", "InputConfig", "Instance", + "InstanceAuthString", "ListInstancesRequest", "ListInstancesResponse", "LocationMetadata", + "MaintenancePolicy", + "MaintenanceSchedule", "NodeInfo", "OutputConfig", + "RescheduleMaintenanceRequest", + "TlsCertificate", "UpdateInstanceRequest", "UpgradeInstanceRequest", + "WeeklyMaintenanceWindow", "ZoneMetadata", ) diff --git a/google/cloud/redis_v1beta1/types/cloud_redis.py b/google/cloud/redis_v1beta1/types/cloud_redis.py index 5505e19..e71345a 100644 --- a/google/cloud/redis_v1beta1/types/cloud_redis.py +++ b/google/cloud/redis_v1beta1/types/cloud_redis.py @@ -15,8 +15,11 @@ # import proto # type: ignore +from google.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore +from google.type import dayofweek_pb2 # type: ignore +from google.type import timeofday_pb2 # type: ignore __protobuf__ = proto.module( @@ -24,9 +27,15 @@ manifest={ "NodeInfo", "Instance", + "RescheduleMaintenanceRequest", + "MaintenancePolicy", + "WeeklyMaintenanceWindow", + "MaintenanceSchedule", "ListInstancesRequest", "ListInstancesResponse", "GetInstanceRequest", + "GetInstanceAuthStringRequest", + "InstanceAuthString", "CreateInstanceRequest", "UpdateInstanceRequest", "UpgradeInstanceRequest", @@ -40,6 +49,7 @@ "FailoverInstanceRequest", "LocationMetadata", "ZoneMetadata", + "TlsCertificate", }, ) @@ -178,10 +188,32 @@ class Instance(proto.Message): connect_mode (google.cloud.redis_v1beta1.types.Instance.ConnectMode): Optional. The network connect mode of the Redis instance. If not provided, the connect mode defaults to DIRECT_PEERING. + auth_enabled (bool): + Optional. Indicates whether OSS Redis AUTH is + enabled for the instance. If set to "true" AUTH + is enabled on the instance. Default value is + "false" meaning AUTH is disabled. + server_ca_certs (Sequence[google.cloud.redis_v1beta1.types.TlsCertificate]): + Output only. List of server CA certificates + for the instance. + transit_encryption_mode (google.cloud.redis_v1beta1.types.Instance.TransitEncryptionMode): + Optional. The TLS mode of the Redis instance. + If not provided, TLS is disabled for the + instance. + maintenance_policy (google.cloud.redis_v1beta1.types.MaintenancePolicy): + Optional. The maintenance policy for the + instance. If not provided, maintenance events + can be performed at any time. + maintenance_schedule (google.cloud.redis_v1beta1.types.MaintenanceSchedule): + Output only. Date and time of upcoming + maintenance events which have been scheduled. replica_count (int): - Optional. The number of replica nodes. Valid range for - standard tier is [1-5] and defaults to 1. Valid value for - basic tier is 0 and defaults to 0. + Optional. The number of replica nodes. The valid range for + the Standard Tier with read replicas enabled is [1-5] and + defaults to 2. If read replicas are not enabled for a + Standard Tier instance, the only valid value is 1 and the + default is 1. The valid value for basic tier is 0 and the + default is also 0. nodes (Sequence[google.cloud.redis_v1beta1.types.NodeInfo]): Output only. Info per node. read_endpoint (str): @@ -196,7 +228,8 @@ class Instance(proto.Message): readonly redis endpoint. Standard tier only. Write requests should target 'port'. read_replicas_mode (google.cloud.redis_v1beta1.types.Instance.ReadReplicasMode): - Optional. Read replica mode. + Optional. Read replica mode. Can only be + specified when trying to create the instance. """ class State(proto.Enum): @@ -223,6 +256,12 @@ class ConnectMode(proto.Enum): DIRECT_PEERING = 1 PRIVATE_SERVICE_ACCESS = 2 + class TransitEncryptionMode(proto.Enum): + r"""Available TLS modes.""" + TRANSIT_ENCRYPTION_MODE_UNSPECIFIED = 0 + SERVER_AUTHENTICATION = 1 + DISABLED = 2 + class ReadReplicasMode(proto.Enum): r"""Read replicas mode.""" READ_REPLICAS_MODE_UNSPECIFIED = 0 @@ -250,6 +289,19 @@ class ReadReplicasMode(proto.Enum): authorized_network = proto.Field(proto.STRING, number=20,) persistence_iam_identity = proto.Field(proto.STRING, number=21,) connect_mode = proto.Field(proto.ENUM, number=22, enum=ConnectMode,) + auth_enabled = proto.Field(proto.BOOL, number=23,) + server_ca_certs = proto.RepeatedField( + proto.MESSAGE, number=25, message="TlsCertificate", + ) + transit_encryption_mode = proto.Field( + proto.ENUM, number=26, enum=TransitEncryptionMode, + ) + maintenance_policy = proto.Field( + proto.MESSAGE, number=27, message="MaintenancePolicy", + ) + maintenance_schedule = proto.Field( + proto.MESSAGE, number=28, message="MaintenanceSchedule", + ) replica_count = proto.Field(proto.INT32, number=31,) nodes = proto.RepeatedField(proto.MESSAGE, number=32, message="NodeInfo",) read_endpoint = proto.Field(proto.STRING, number=33,) @@ -257,6 +309,115 @@ class ReadReplicasMode(proto.Enum): read_replicas_mode = proto.Field(proto.ENUM, number=35, enum=ReadReplicasMode,) +class RescheduleMaintenanceRequest(proto.Message): + r"""Request for + [RescheduleMaintenance][google.cloud.redis.v1beta1.CloudRedis.RescheduleMaintenance]. + + Attributes: + name (str): + Required. Redis instance resource name using the form: + ``projects/{project_id}/locations/{location_id}/instances/{instance_id}`` + where ``location_id`` refers to a GCP region. + reschedule_type (google.cloud.redis_v1beta1.types.RescheduleMaintenanceRequest.RescheduleType): + Required. If reschedule type is SPECIFIC_TIME, must set up + schedule_time as well. + schedule_time (google.protobuf.timestamp_pb2.Timestamp): + Optional. Timestamp when the maintenance shall be + rescheduled to if reschedule_type=SPECIFIC_TIME, in RFC 3339 + format, for example ``2012-11-15T16:19:00.094Z``. + """ + + class RescheduleType(proto.Enum): + r"""Reschedule options.""" + RESCHEDULE_TYPE_UNSPECIFIED = 0 + IMMEDIATE = 1 + NEXT_AVAILABLE_WINDOW = 2 + SPECIFIC_TIME = 3 + + name = proto.Field(proto.STRING, number=1,) + reschedule_type = proto.Field(proto.ENUM, number=2, enum=RescheduleType,) + schedule_time = proto.Field( + proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp, + ) + + +class MaintenancePolicy(proto.Message): + r"""Maintenance policy for an instance. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time when the policy was + created. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time when the policy was + last updated. + description (str): + Optional. Description of what this policy is for. + Create/Update methods return INVALID_ARGUMENT if the length + is greater than 512. + weekly_maintenance_window (Sequence[google.cloud.redis_v1beta1.types.WeeklyMaintenanceWindow]): + Optional. Maintenance window that is applied to resources + covered by this policy. Minimum 1. For the current version, + the maximum number of weekly_window is expected to be one. + """ + + create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + description = proto.Field(proto.STRING, number=3,) + weekly_maintenance_window = proto.RepeatedField( + proto.MESSAGE, number=4, message="WeeklyMaintenanceWindow", + ) + + +class WeeklyMaintenanceWindow(proto.Message): + r"""Time window in which disruptive maintenance updates occur. + Non-disruptive updates can occur inside or outside this window. + + Attributes: + day (google.type.dayofweek_pb2.DayOfWeek): + Required. The day of week that maintenance + updates occur. + start_time (google.type.timeofday_pb2.TimeOfDay): + Required. Start time of the window in UTC + time. + duration (google.protobuf.duration_pb2.Duration): + Output only. Duration of the maintenance + window. The current window is fixed at 1 hour. + """ + + day = proto.Field(proto.ENUM, number=1, enum=dayofweek_pb2.DayOfWeek,) + start_time = proto.Field(proto.MESSAGE, number=2, message=timeofday_pb2.TimeOfDay,) + duration = proto.Field(proto.MESSAGE, number=3, message=duration_pb2.Duration,) + + +class MaintenanceSchedule(proto.Message): + r"""Upcoming maintenance schedule. If no maintenance is + scheduled, fields are not populated. + + Attributes: + start_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The start time of any upcoming + scheduled maintenance for this instance. + end_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The end time of any upcoming + scheduled maintenance for this instance. + can_reschedule (bool): + If the scheduled maintenance can be + rescheduled, default is true. + schedule_deadline_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The deadline that the + maintenance schedule start time can not go + beyond, including reschedule. + """ + + start_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + can_reschedule = proto.Field(proto.BOOL, number=3,) + schedule_deadline_time = proto.Field( + proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp, + ) + + class ListInstancesRequest(proto.Message): r"""Request for [ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances]. @@ -335,6 +496,31 @@ class GetInstanceRequest(proto.Message): name = proto.Field(proto.STRING, number=1,) +class GetInstanceAuthStringRequest(proto.Message): + r"""Request for + [GetInstanceAuthString][google.cloud.redis.v1beta1.CloudRedis.GetInstanceAuthString]. + + Attributes: + name (str): + Required. Redis instance resource name using the form: + ``projects/{project_id}/locations/{location_id}/instances/{instance_id}`` + where ``location_id`` refers to a GCP region. + """ + + name = proto.Field(proto.STRING, number=1,) + + +class InstanceAuthString(proto.Message): + r"""Instance AUTH string details. + + Attributes: + auth_string (str): + AUTH string set on the instance. + """ + + auth_string = proto.Field(proto.STRING, number=1,) + + class CreateInstanceRequest(proto.Message): r"""Request for [CreateInstance][google.cloud.redis.v1beta1.CloudRedis.CreateInstance]. @@ -571,4 +757,32 @@ class ZoneMetadata(proto.Message): """ +class TlsCertificate(proto.Message): + r"""TlsCertificate Resource + + Attributes: + serial_number (str): + Serial number, as extracted from the + certificate. + cert (str): + PEM representation. + create_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time when the certificate was created in + `RFC 3339 `__ format, + for example ``2020-05-18T00:00:00.094Z``. + expire_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time when the certificate expires in `RFC + 3339 `__ format, for + example ``2020-05-18T00:00:00.094Z``. + sha1_fingerprint (str): + Sha1 Fingerprint of the certificate. + """ + + serial_number = proto.Field(proto.STRING, number=1,) + cert = proto.Field(proto.STRING, number=2,) + create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + expire_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + sha1_fingerprint = proto.Field(proto.STRING, number=5,) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/scripts/fixup_redis_v1beta1_keywords.py b/scripts/fixup_redis_v1beta1_keywords.py index a8415f0..5cee6f8 100644 --- a/scripts/fixup_redis_v1beta1_keywords.py +++ b/scripts/fixup_redis_v1beta1_keywords.py @@ -44,8 +44,10 @@ class redisCallTransformer(cst.CSTTransformer): 'export_instance': ('name', 'output_config', ), 'failover_instance': ('name', 'data_protection_mode', ), 'get_instance': ('name', ), + 'get_instance_auth_string': ('name', ), 'import_instance': ('name', 'input_config', ), 'list_instances': ('parent', 'page_size', 'page_token', ), + 'reschedule_maintenance': ('name', 'reschedule_type', 'schedule_time', ), 'update_instance': ('update_mask', 'instance', ), 'upgrade_instance': ('name', 'redis_version', ), } diff --git a/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py b/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py index cc0f921..1fc37c6 100644 --- a/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py +++ b/tests/unit/gapic/redis_v1beta1/test_cloud_redis.py @@ -42,8 +42,11 @@ from google.longrunning import operations_pb2 from google.oauth2 import service_account from google.protobuf import any_pb2 # type: ignore +from google.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore +from google.type import dayofweek_pb2 # type: ignore +from google.type import timeofday_pb2 # type: ignore import google.auth @@ -845,6 +848,8 @@ def test_get_instance(request_type, transport: str = "grpc"): authorized_network="authorized_network_value", persistence_iam_identity="persistence_iam_identity_value", connect_mode=cloud_redis.Instance.ConnectMode.DIRECT_PEERING, + auth_enabled=True, + transit_encryption_mode=cloud_redis.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION, replica_count=1384, read_endpoint="read_endpoint_value", read_endpoint_port=1920, @@ -875,6 +880,11 @@ def test_get_instance(request_type, transport: str = "grpc"): assert response.authorized_network == "authorized_network_value" assert response.persistence_iam_identity == "persistence_iam_identity_value" assert response.connect_mode == cloud_redis.Instance.ConnectMode.DIRECT_PEERING + assert response.auth_enabled is True + assert ( + response.transit_encryption_mode + == cloud_redis.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION + ) assert response.replica_count == 1384 assert response.read_endpoint == "read_endpoint_value" assert response.read_endpoint_port == 1920 @@ -932,6 +942,8 @@ async def test_get_instance_async( authorized_network="authorized_network_value", persistence_iam_identity="persistence_iam_identity_value", connect_mode=cloud_redis.Instance.ConnectMode.DIRECT_PEERING, + auth_enabled=True, + transit_encryption_mode=cloud_redis.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION, replica_count=1384, read_endpoint="read_endpoint_value", read_endpoint_port=1920, @@ -963,6 +975,11 @@ async def test_get_instance_async( assert response.authorized_network == "authorized_network_value" assert response.persistence_iam_identity == "persistence_iam_identity_value" assert response.connect_mode == cloud_redis.Instance.ConnectMode.DIRECT_PEERING + assert response.auth_enabled is True + assert ( + response.transit_encryption_mode + == cloud_redis.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION + ) assert response.replica_count == 1384 assert response.read_endpoint == "read_endpoint_value" assert response.read_endpoint_port == 1920 @@ -1096,6 +1113,220 @@ async def test_get_instance_flattened_error_async(): ) +@pytest.mark.parametrize( + "request_type", [cloud_redis.GetInstanceAuthStringRequest, dict,] +) +def test_get_instance_auth_string(request_type, transport: str = "grpc"): + client = CloudRedisClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_instance_auth_string), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = cloud_redis.InstanceAuthString( + auth_string="auth_string_value", + ) + response = client.get_instance_auth_string(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == cloud_redis.GetInstanceAuthStringRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, cloud_redis.InstanceAuthString) + assert response.auth_string == "auth_string_value" + + +def test_get_instance_auth_string_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudRedisClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_instance_auth_string), "__call__" + ) as call: + client.get_instance_auth_string() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == cloud_redis.GetInstanceAuthStringRequest() + + +@pytest.mark.asyncio +async def test_get_instance_auth_string_async( + transport: str = "grpc_asyncio", + request_type=cloud_redis.GetInstanceAuthStringRequest, +): + client = CloudRedisAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_instance_auth_string), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + cloud_redis.InstanceAuthString(auth_string="auth_string_value",) + ) + response = await client.get_instance_auth_string(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == cloud_redis.GetInstanceAuthStringRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, cloud_redis.InstanceAuthString) + assert response.auth_string == "auth_string_value" + + +@pytest.mark.asyncio +async def test_get_instance_auth_string_async_from_dict(): + await test_get_instance_auth_string_async(request_type=dict) + + +def test_get_instance_auth_string_field_headers(): + client = CloudRedisClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloud_redis.GetInstanceAuthStringRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_instance_auth_string), "__call__" + ) as call: + call.return_value = cloud_redis.InstanceAuthString() + client.get_instance_auth_string(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_instance_auth_string_field_headers_async(): + client = CloudRedisAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloud_redis.GetInstanceAuthStringRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_instance_auth_string), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + cloud_redis.InstanceAuthString() + ) + await client.get_instance_auth_string(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_get_instance_auth_string_flattened(): + client = CloudRedisClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_instance_auth_string), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = cloud_redis.InstanceAuthString() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_instance_auth_string(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_get_instance_auth_string_flattened_error(): + client = CloudRedisClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_instance_auth_string( + cloud_redis.GetInstanceAuthStringRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_instance_auth_string_flattened_async(): + client = CloudRedisAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_instance_auth_string), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = cloud_redis.InstanceAuthString() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + cloud_redis.InstanceAuthString() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_instance_auth_string(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_instance_auth_string_flattened_error_async(): + client = CloudRedisAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_instance_auth_string( + cloud_redis.GetInstanceAuthStringRequest(), name="name_value", + ) + + @pytest.mark.parametrize("request_type", [cloud_redis.CreateInstanceRequest, dict,]) def test_create_instance(request_type, transport: str = "grpc"): client = CloudRedisClient( @@ -2597,6 +2828,242 @@ async def test_delete_instance_flattened_error_async(): ) +@pytest.mark.parametrize( + "request_type", [cloud_redis.RescheduleMaintenanceRequest, dict,] +) +def test_reschedule_maintenance(request_type, transport: str = "grpc"): + client = CloudRedisClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.reschedule_maintenance), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.reschedule_maintenance(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == cloud_redis.RescheduleMaintenanceRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_reschedule_maintenance_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = CloudRedisClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.reschedule_maintenance), "__call__" + ) as call: + client.reschedule_maintenance() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == cloud_redis.RescheduleMaintenanceRequest() + + +@pytest.mark.asyncio +async def test_reschedule_maintenance_async( + transport: str = "grpc_asyncio", + request_type=cloud_redis.RescheduleMaintenanceRequest, +): + client = CloudRedisAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.reschedule_maintenance), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.reschedule_maintenance(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == cloud_redis.RescheduleMaintenanceRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_reschedule_maintenance_async_from_dict(): + await test_reschedule_maintenance_async(request_type=dict) + + +def test_reschedule_maintenance_field_headers(): + client = CloudRedisClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloud_redis.RescheduleMaintenanceRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.reschedule_maintenance), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.reschedule_maintenance(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_reschedule_maintenance_field_headers_async(): + client = CloudRedisAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloud_redis.RescheduleMaintenanceRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.reschedule_maintenance), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.reschedule_maintenance(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_reschedule_maintenance_flattened(): + client = CloudRedisClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.reschedule_maintenance), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.reschedule_maintenance( + name="name_value", + reschedule_type=cloud_redis.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE, + schedule_time=timestamp_pb2.Timestamp(seconds=751), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].reschedule_type + mock_val = cloud_redis.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE + assert arg == mock_val + assert TimestampRule().to_proto( + args[0].schedule_time + ) == timestamp_pb2.Timestamp(seconds=751) + + +def test_reschedule_maintenance_flattened_error(): + client = CloudRedisClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.reschedule_maintenance( + cloud_redis.RescheduleMaintenanceRequest(), + name="name_value", + reschedule_type=cloud_redis.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE, + schedule_time=timestamp_pb2.Timestamp(seconds=751), + ) + + +@pytest.mark.asyncio +async def test_reschedule_maintenance_flattened_async(): + client = CloudRedisAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.reschedule_maintenance), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.reschedule_maintenance( + name="name_value", + reschedule_type=cloud_redis.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE, + schedule_time=timestamp_pb2.Timestamp(seconds=751), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].reschedule_type + mock_val = cloud_redis.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE + assert arg == mock_val + assert TimestampRule().to_proto( + args[0].schedule_time + ) == timestamp_pb2.Timestamp(seconds=751) + + +@pytest.mark.asyncio +async def test_reschedule_maintenance_flattened_error_async(): + client = CloudRedisAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.reschedule_maintenance( + cloud_redis.RescheduleMaintenanceRequest(), + name="name_value", + reschedule_type=cloud_redis.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE, + schedule_time=timestamp_pb2.Timestamp(seconds=751), + ) + + def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.CloudRedisGrpcTransport( @@ -2693,6 +3160,7 @@ def test_cloud_redis_base_transport(): methods = ( "list_instances", "get_instance", + "get_instance_auth_string", "create_instance", "update_instance", "upgrade_instance", @@ -2700,6 +3168,7 @@ def test_cloud_redis_base_transport(): "export_instance", "failover_instance", "delete_instance", + "reschedule_maintenance", ) for method in methods: with pytest.raises(NotImplementedError): From 003832e0fec00947feb543c9a869b4606dd0cdf4 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 14 Jan 2022 00:42:15 +0000 Subject: [PATCH 08/10] build: switch to release-please for tagging (#146) --- .github/.OwlBot.lock.yaml | 2 +- .github/release-please.yml | 1 + .github/release-trigger.yml | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 .github/release-trigger.yml diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index f33299d..ff5126c 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:899d5d7cc340fa8ef9d8ae1a8cfba362c6898584f779e156f25ee828ba824610 + digest: sha256:dfa9b663b32de8b5b327e32c1da665a80de48876558dd58091d8160c60ad7355 diff --git a/.github/release-please.yml b/.github/release-please.yml index 4507ad0..466597e 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1 +1,2 @@ releaseType: python +handleGHRelease: true diff --git a/.github/release-trigger.yml b/.github/release-trigger.yml new file mode 100644 index 0000000..d4ca941 --- /dev/null +++ b/.github/release-trigger.yml @@ -0,0 +1 @@ +enabled: true From 7841ff394f4fb3b901395da923544d45011d35cc Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 14 Jan 2022 11:11:32 -0500 Subject: [PATCH 09/10] chore(python): update release.sh to use keystore (#149) Source-Link: https://github.com/googleapis/synthtool/commit/69fda12e2994f0b595a397e8bb6e3e9f380524eb Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:ae600f36b6bc972b368367b6f83a1d91ec2c82a4a116b383d67d547c56fe6de3 Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 2 +- .kokoro/release.sh | 2 +- .kokoro/release/common.cfg | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index ff5126c..eecb84c 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:dfa9b663b32de8b5b327e32c1da665a80de48876558dd58091d8160c60ad7355 + digest: sha256:ae600f36b6bc972b368367b6f83a1d91ec2c82a4a116b383d67d547c56fe6de3 diff --git a/.kokoro/release.sh b/.kokoro/release.sh index 28620ea..4c83f48 100755 --- a/.kokoro/release.sh +++ b/.kokoro/release.sh @@ -26,7 +26,7 @@ python3 -m pip install --upgrade twine wheel setuptools export PYTHONUNBUFFERED=1 # Move into the package, build the distribution and upload. -TWINE_PASSWORD=$(cat "${KOKORO_GFILE_DIR}/secret_manager/google-cloud-pypi-token") +TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google-cloud-pypi-token-keystore-1") cd github/python-redis python3 setup.py sdist bdist_wheel twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/* diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg index 4f3dd19..6ba93c3 100644 --- a/.kokoro/release/common.cfg +++ b/.kokoro/release/common.cfg @@ -23,8 +23,18 @@ env_vars: { value: "github/python-redis/.kokoro/release.sh" } +# Fetch PyPI password +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "google-cloud-pypi-token-keystore-1" + } + } +} + # Tokens needed to report release status back to GitHub env_vars: { key: "SECRET_MANAGER_KEYS" - value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem,google-cloud-pypi-token" + value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem" } From 41c67b6a4346a21156838f048be49df595a200fb Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 18 Jan 2022 08:57:27 -0700 Subject: [PATCH 10/10] chore(main): release 2.5.1 (#148) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou --- CHANGELOG.md | 7 +++++++ setup.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c54d640..26734ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://pypi.org/project/google-cloud-redis/#history +### [2.5.1](https://github.com/googleapis/python-redis/compare/v2.5.0...v2.5.1) (2022-01-14) + + +### Bug Fixes + +* Add missing fields for TLS and Maintenance Window features ([#147](https://github.com/googleapis/python-redis/issues/147)) ([f04a02e](https://github.com/googleapis/python-redis/commit/f04a02e81a8a449bdcf07f5725778425242fe16e)) + ## [2.5.0](https://www.github.com/googleapis/python-redis/compare/v2.4.1...v2.5.0) (2021-11-09) diff --git a/setup.py b/setup.py index ab04917..aa5fc9e 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ name = "google-cloud-redis" description = "Google Cloud Memorystore for Redis API client library" -version = "2.5.0" +version = "2.5.1" # Should be one of: # 'Development Status :: 3 - Alpha' # 'Development Status :: 4 - Beta'