From e05e4de2f22206c1c34135ad580b6303e5f9900a Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 14 Nov 2024 21:46:21 +0000 Subject: [PATCH 01/11] WIP prototype --- gapic/generator/generator.py | 2 + gapic/schema/metadata.py | 11 +- gapic/schema/naming.py | 14 +- .../templates/%namespace/%name/__init__.py.j2 | 5 +- .../%name_%version/%sub/__init__.py.j2 | 5 +- .../%sub/services/%service/_client_macros.j2 | 16 +- .../%sub/services/%service/async_client.py.j2 | 57 +- .../%sub/services/%service/pagers.py.j2 | 9 + .../%name_%version/%sub/types/__init__.py.j2 | 6 + .../gapic/%name_%version/%sub/test_macros.j2 | 8 +- noxfile.py | 3 +- .../redis/google/cloud/redis_v1/__init__.py | 54 +- .../services/cloud_redis/async_client.py | 336 ++--- .../redis_v1/services/cloud_redis/client.py | 277 ++-- .../redis_v1/services/cloud_redis/pagers.py | 42 +- .../services/cloud_redis/transports/base.py | 36 +- .../services/cloud_redis/transports/grpc.py | 58 +- .../cloud_redis/transports/grpc_asyncio.py | 58 +- .../services/cloud_redis/transports/rest.py | 126 +- .../cloud_redis/transports/rest_asyncio.py | 126 +- .../cloud_redis/transports/rest_base.py | 24 +- .../google/cloud/redis_v1/types/__init__.py | 59 - .../cloud/redis_v1/types/cloud_redis.py | 1343 ----------------- .../cloud/redis_v1/types/cloud_redis_pb2.py | 300 ++++ .../cloud/redis_v1/types/cloud_redis_pb2.pyi | 433 ++++++ ...nippet_metadata_google.cloud.redis.v1.json | 76 +- .../unit/gapic/redis_v1/test_cloud_redis.py | 1270 ++++++---------- tests/integration/redis_v1.yaml | 1 + 28 files changed, 1945 insertions(+), 2810 deletions(-) delete mode 100755 tests/integration/goldens/redis/google/cloud/redis_v1/types/cloud_redis.py create mode 100644 tests/integration/goldens/redis/google/cloud/redis_v1/types/cloud_redis_pb2.py create mode 100755 tests/integration/goldens/redis/google/cloud/redis_v1/types/cloud_redis_pb2.pyi diff --git a/gapic/generator/generator.py b/gapic/generator/generator.py index 27ad4b7ff2..6288d4cd85 100644 --- a/gapic/generator/generator.py +++ b/gapic/generator/generator.py @@ -274,6 +274,8 @@ def _render_template( and proto.meta.address.subpackage != api_schema.subpackage_view ): continue + if api_schema.all_library_settings[api_schema.naming.proto_package].python_settings.experimental_features.protobuf_pythonic_types_enabled: + continue answer.update( self._get_file( diff --git a/gapic/schema/metadata.py b/gapic/schema/metadata.py index dc9389e8f5..6df7cc816c 100644 --- a/gapic/schema/metadata.py +++ b/gapic/schema/metadata.py @@ -115,6 +115,9 @@ def is_proto_plus_type(self) -> bool: Returns: bool: Whether the given package uses proto-plus types or not. """ + if self.proto_package.startswith(self.api_naming.proto_package) and hasattr(self.api_naming, "protobuf_pythonic_types_enabled") and self.api_naming.protobuf_pythonic_types_enabled: + return False + return self.proto_package.startswith(self.api_naming.proto_package) or ( hasattr(self.api_naming, "proto_plus_deps") and self.proto_package in self.api_naming.proto_plus_deps @@ -204,6 +207,7 @@ def python_import(self) -> imp.Import: alias=self.module_alias, ) + use_protobuf_types = hasattr(self.api_naming, "protobuf_pythonic_types_enabled") and self.api_naming.protobuf_pythonic_types_enabled # If this is part of the proto package that we are generating, # rewrite the package to our structure. if self.proto_package.startswith(self.api_naming.proto_package): @@ -211,8 +215,8 @@ def python_import(self) -> imp.Import: package=self.api_naming.module_namespace + ( self.api_naming.versioned_module_name, ) + self.subpackage + ('types',), - module=self.module, - alias=self.module_alias, + module= self.module + ('_pb2' if use_protobuf_types else ''), + alias='' if use_protobuf_types else self.module_alias, ) if self.is_proto_plus_type: @@ -240,10 +244,11 @@ def sphinx(self) -> str: # Check if this is a generated type # Use the original module name rather than the module_alias + use_protobuf_types = hasattr(self.api_naming, "protobuf_pythonic_types_enabled") and self.api_naming.protobuf_pythonic_types_enabled if self.proto_package.startswith(self.api_naming.proto_package): return '.'.join(self.api_naming.module_namespace + ( self.api_naming.versioned_module_name, - ) + self.subpackage + ('types',) + self.parent + (self.name, )) + ) + self.subpackage + ('types',) + self.parent + (self.name + ("_pb2" if use_protobuf_types else ""), )) elif self.is_proto_plus_type: return ".".join( self.convert_to_versioned_package() diff --git a/gapic/schema/naming.py b/gapic/schema/naming.py index 1d055490ff..7ae942eaae 100644 --- a/gapic/schema/naming.py +++ b/gapic/schema/naming.py @@ -44,6 +44,7 @@ class Naming(abc.ABC): proto_package: str = '' _warehouse_package_name: str = '' proto_plus_deps: Tuple[str, ...] = dataclasses.field(default_factory=tuple) + protobuf_pythonic_types_enabled: bool = False def __post_init__(self): if not self.product_name: @@ -152,7 +153,18 @@ def build( package_info, proto_plus_deps=opts.proto_plus_deps, ) - + package = ".".join(package_info.module_namespace) + f".{package_info.module_name}.{package_info.version}" + + if "publishing" in opts.service_yaml_config: + if "library_settings" in opts.service_yaml_config["publishing"]: + for setting in opts.service_yaml_config["publishing"]["library_settings"]: + if package == setting["version"]: + if "protobuf_pythonic_types_enabled" in setting["python_settings"]["experimental_features"]: + package_info = dataclasses.replace( + package_info, + protobuf_pythonic_types_enabled = setting["python_settings"]["experimental_features"]["protobuf_pythonic_types_enabled"] + ) + # Done; return the naming information. return package_info diff --git a/gapic/templates/%namespace/%name/__init__.py.j2 b/gapic/templates/%namespace/%name/__init__.py.j2 index a5e61f219a..0299a9151c 100644 --- a/gapic/templates/%namespace/%name/__init__.py.j2 +++ b/gapic/templates/%namespace/%name/__init__.py.j2 @@ -1,6 +1,7 @@ {% extends '_base.py.j2' %} {% block content %} +{% set protobuf_pythonic_types_enabled = api.all_library_settings[api.naming.proto_package].python_settings.experimental_features.protobuf_pythonic_types_enabled %} {% set package_path = api.naming.module_namespace|join('.') + "." + api.naming.module_name %} from {{package_path}} import gapic_version as package_version @@ -37,11 +38,11 @@ from {% if api.naming.module_namespace %}{{ api.naming.module_namespace|join('.' if proto.meta.address.subpackage == api.subpackage_view %} {% for message in proto.messages.values()|sort(attribute='name') %} from {% if api.naming.module_namespace %}{{ api.naming.module_namespace|join('.') }}.{% endif %} - {{- api.naming.versioned_module_name }}.types.{{ proto.module_name }} import {{ message.name }} + {{- api.naming.versioned_module_name }}.types.{{ proto.module_name }}{%if protobuf_pythonic_types_enabled %}_pb2{% endif %} import {{ message.name }} {% endfor %} {% for enum in proto.enums.values()|sort(attribute='name') %} from {% if api.naming.module_namespace %}{{ api.naming.module_namespace|join('.') }}.{% endif %} - {{- api.naming.versioned_module_name }}.types.{{ proto.module_name }} import {{ enum.name }} + {{- api.naming.versioned_module_name }}.types.{{ proto.module_name }}{%if protobuf_pythonic_types_enabled %}_pb2{% endif %} import {{ enum.name }} {% endfor %}{% endfor %} {# Define __all__. This requires the full set of imported names, so we iterate over diff --git a/gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2 b/gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2 index 8ee1670431..c2766e9396 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2 @@ -2,6 +2,7 @@ {% block content %} +{% set protobuf_pythonic_types_enabled = api.all_library_settings[api.naming.proto_package].python_settings.experimental_features.protobuf_pythonic_types_enabled %} {% set package_path = api.naming.module_namespace|join('.') + "." + api.naming.versioned_module_name %} from {{package_path}} import gapic_version as package_version @@ -29,10 +30,10 @@ from .services.{{ service.name|snake_case }} import {{ service.async_client_name {% for proto in api.protos.values()|sort(attribute='name') if proto.meta.address.subpackage == api.subpackage_view %} {% for message in proto.messages.values()|sort(attribute='name') %} -from .types.{{ proto.module_name }} import {{ message.name }} +from .types.{{ proto.module_name }}{%if protobuf_pythonic_types_enabled %}_pb2{% endif %} import {{ message.name }} {% endfor %} {% for enum in proto.enums.values()|sort(attribute='name') %} -from .types.{{ proto.module_name }} import {{ enum.name }} +from .types.{{ proto.module_name }}{%if protobuf_pythonic_types_enabled %}_pb2{% endif %} import {{ enum.name }} {% endfor %} {% endfor %} diff --git a/gapic/templates/%namespace/%name_%version/%sub/services/%service/_client_macros.j2 b/gapic/templates/%namespace/%name_%version/%sub/services/%service/_client_macros.j2 index 7eeda037b7..6b6b1143fa 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/services/%service/_client_macros.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/services/%service/_client_macros.j2 @@ -17,6 +17,8 @@ {% import "%namespace/%name_%version/%sub/services/%service/_shared_macros.j2" as shared_macros %} {% macro client_method(method, name, snippet_index, api, service, full_extended_lro=False) %} + {% set protobuf_pythonic_types_enabled = api.all_library_settings[api.naming.proto_package].python_settings.experimental_features.protobuf_pythonic_types_enabled %} + def {{ name }}(self, {% if not method.client_streaming %} request: Optional[Union[{{ method.input.ident }}, dict]] = None, @@ -97,7 +99,7 @@ 'the individual field arguments should be set.') {% endif %} - {% if method.input.ident.package != method.ident.package %}{# request lives in a different package, so there is no proto wrapper #} + {% if protobuf_pythonic_types_enabled or method.input.ident.package != method.ident.package %}{# request lives in a different package, so there is no proto wrapper #} if isinstance(request, dict): # - The request isn't a proto-plus wrapped type, # so it must be constructed via keyword expansion. @@ -113,22 +115,26 @@ {% endif %}{# different request package #} {#- Vanilla python protobuf wrapper types cannot _set_ repeated fields #} - {% if method.flattened_fields and method.input.ident.package == method.ident.package %} + {% if not protobuf_pythonic_types_enabled and method.flattened_fields and method.input.ident.package == method.ident.package %} # If we have keyword arguments corresponding to fields on the # request, apply these. {% endif %} - {% for key, field in method.flattened_fields.items() if not field.repeated or method.input.ident.package == method.ident.package %} + {% for key, field in method.flattened_fields.items() if not field.repeated or (not protobuf_pythonic_types_enabled and method.input.ident.package == method.ident.package) %} if {{ field.name }} is not None: {# Repeated values is a special case, because values can be lists. #} {# In order to not confuse the marshalling logic, extend these fields instead of assigning #} {% if field.ident.ident|string() == "struct_pb2.Value" and field.repeated %} request.{{ key }}.extend({{ field.name }}) {% else %} + {% if protobuf_pythonic_types_enabled and field.message %} + request.{{ key }}.MergeFrom({{ key }}) + {% else %} request.{{ key }} = {{ field.name }} + {% endif %} {% endif %}{# struct_pb2.Value #} {% endfor %} {# Map-y fields can be _updated_, however #} - {% for key, field in method.flattened_fields.items() if field.repeated and method.input.ident.package != method.ident.package %} + {% for key, field in method.flattened_fields.items() if field.repeated and (protobuf_pythonic_types_enabled or method.input.ident.package != method.ident.package) %} {% if field.map %} {# map implies repeated, but repeated does NOT imply map#} if {{ field.name }}: request.{{ key }}.update({{ field.name }}) @@ -138,7 +144,7 @@ request.{{ key }}.extend({{ field.name }}) {% endif %} {# field.map #} {% endfor %} {# method.flattened_fields.items() #} - {% endif %} {# method.client_streaming #} + {% endif %} {# method.client_streaming #} # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. diff --git a/gapic/templates/%namespace/%name_%version/%sub/services/%service/async_client.py.j2 b/gapic/templates/%namespace/%name_%version/%sub/services/%service/async_client.py.j2 index 1abddd198e..56ae32a288 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/services/%service/async_client.py.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/services/%service/async_client.py.j2 @@ -4,6 +4,8 @@ {% import "%namespace/%name_%version/%sub/services/%service/_client_macros.j2" as macros %} {% import "%namespace/%name_%version/%sub/services/%service/_shared_macros.j2" as shared_macros %} +{% set protobuf_pythonic_types_enabled = api.all_library_settings[api.naming.proto_package].python_settings.experimental_features.protobuf_pythonic_types_enabled %} + from collections import OrderedDict import re from typing import Dict, Callable, Mapping, MutableMapping, MutableSequence, Optional, {% if service.any_server_streaming %}AsyncIterable, Awaitable, {% endif %}{% if service.any_client_streaming %}AsyncIterator, {% endif %}Sequence, Tuple, Type, Union @@ -52,7 +54,6 @@ from .transports.base import {{ service.name }}Transport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import {{ service.grpc_asyncio_transport_name }} from .client import {{ service.client_name }} - {# TODO(yon-mg): handle rest transport async client interaction #} class {{ service.async_client_name }}: """{{ service.meta.doc|rst(width=72, indent=4) }}{% if service.version|length %} @@ -324,7 +325,7 @@ class {{ service.async_client_name }}: "the individual field arguments should be set.") {% endif %} - {% if method.input.ident.package != method.ident.package %} {# request lives in a different package, so there is no proto wrapper #} + {% if protobuf_pythonic_types_enabled or method.input.ident.package != method.ident.package %} {# request lives in a different package, so there is no proto wrapper #} # - The request isn't a proto-plus wrapped type, # so it must be constructed via keyword expansion. if isinstance(request, dict): @@ -338,27 +339,37 @@ class {{ service.async_client_name }}: request = {{ method.input.ident }}(request) {% endif %} {# different request package #} - {# Vanilla python protobuf wrapper types cannot _set_ repeated fields #} - {% if method.flattened_fields and method.input.ident.package == method.ident.package %} - # If we have keyword arguments corresponding to fields on the - # request, apply these. - {% endif %} - {% for key, field in method.flattened_fields.items() if not field.repeated and method.input.ident.package == method.ident.package %} - if {{ field.name }} is not None: - request.{{ key }} = {{ field.name }} - {% endfor %} - {# Map-y fields can be _updated_, however #} - {% for key, field in method.flattened_fields.items() if field.map and method.input.ident.package == method.ident.package %} - - if {{ field.name }}: - request.{{ key }}.update({{ field.name }}) - {% endfor %} - {# And list-y fields can be _extended_ #} - {% for key, field in method.flattened_fields.items() if field.repeated and not field.map and method.input.ident.package == method.ident.package %} - if {{ field.name }}: - request.{{ key }}.extend({{ field.name }}) - {% endfor %} - {% endif %} + {# Vanilla python protobuf wrapper types cannot _set_ repeated fields #} + {% if not protobuf_pythonic_types_enabled and method.flattened_fields and method.input.ident.package == method.ident.package %} + # If we have keyword arguments corresponding to fields on the + # request, apply these. + {% endif %} + {% for key, field in method.flattened_fields.items() if not field.repeated or (not protobuf_pythonic_types_enabled and method.input.ident.package == method.ident.package) %} + if {{ field.name }} is not None: + {# Repeated values is a special case, because values can be lists. #} + {# In order to not confuse the marshalling logic, extend these fields instead of assigning #} + {% if field.ident.ident|string() == "struct_pb2.Value" and field.repeated %} + request.{{ key }}.extend({{ field.name }}) + {% else %} + {% if protobuf_pythonic_types_enabled and field.message %} + request.{{ key }}.MergeFrom({{ key }}) + {% else %} + request.{{ key }} = {{ field.name }} + {% endif %} + {% endif %}{# struct_pb2.Value #} + {% endfor %} + {# Map-y fields can be _updated_, however #} + {% for key, field in method.flattened_fields.items() if field.repeated and (protobuf_pythonic_types_enabled or method.input.ident.package != method.ident.package) %} + {% if field.map %} {# map implies repeated, but repeated does NOT imply map#} + if {{ field.name }}: + request.{{ key }}.update({{ field.name }}) + {% else %} + {# And list-y fields can be _extended_ #} + if {{ field.name }}: + request.{{ key }}.extend({{ field.name }}) + {% endif %} {# field.map #} + {% endfor %} {# method.flattened_fields.items() #} + {% endif %} {# method.client_streaming #} # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. diff --git a/gapic/templates/%namespace/%name_%version/%sub/services/%service/pagers.py.j2 b/gapic/templates/%namespace/%name_%version/%sub/services/%service/pagers.py.j2 index 796cefe48c..0e53f9d11a 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/services/%service/pagers.py.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/services/%service/pagers.py.j2 @@ -1,6 +1,7 @@ {% extends '_base.py.j2' %} {% block content %} +{% set protobuf_pythonic_types_enabled = api.all_library_settings[api.naming.proto_package].python_settings.experimental_features.protobuf_pythonic_types_enabled %} {% for method in service.methods.values() | selectattr('paged_result_field') %} {% if loop.first %} @@ -71,7 +72,11 @@ class {{ method.name }}Pager: sent along with the request as metadata. """ self._method = method + {% if protobuf_pythonic_types_enabled %} + self._request = request + {% else %} self._request = {{ method.input.ident }}(request) + {% endif %} self._response = response self._retry = retry self._timeout = timeout @@ -148,7 +153,11 @@ class {{ method.name }}AsyncPager: sent along with the request as metadata. """ self._method = method + {% if protobuf_pythonic_types_enabled %} + self._request = request + {% else %} self._request = {{ method.input.ident }}(request) + {% endif %} self._response = response self._retry = retry self._timeout = timeout diff --git a/gapic/templates/%namespace/%name_%version/%sub/types/__init__.py.j2 b/gapic/templates/%namespace/%name_%version/%sub/types/__init__.py.j2 index bec74ebf90..c02a338fcb 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/types/__init__.py.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/types/__init__.py.j2 @@ -2,6 +2,9 @@ {% block content %} +{% set protobuf_pythonic_types_enabled = api.all_library_settings[api.naming.proto_package].python_settings.experimental_features.protobuf_pythonic_types_enabled %} + +{% if not protobuf_pythonic_types_enabled %} {% for _, proto in api.protos|dictsort if proto.file_to_generate and proto.messages or proto.enums %} from .{{proto.module_name }} import ( {% for _, message in proto.messages|dictsort %} @@ -23,4 +26,7 @@ __all__ = ( {% endfor %} {% endfor %} ) + +{% endif %}{# not protobuf_pythonic_types_enabled #} + {% endblock %} diff --git a/gapic/templates/tests/unit/gapic/%name_%version/%sub/test_macros.j2 b/gapic/templates/tests/unit/gapic/%name_%version/%sub/test_macros.j2 index 38c43b0bad..24ef97164f 100644 --- a/gapic/templates/tests/unit/gapic/%name_%version/%sub/test_macros.j2 +++ b/gapic/templates/tests/unit/gapic/%name_%version/%sub/test_macros.j2 @@ -1690,7 +1690,7 @@ def test_unsupported_parameter_rest_asyncio(): {% else %} {% if 'rest' in transport %} {{ bad_request_test(service, method, transport, is_async) }} -{{ call_success_test(service, method, transport, is_async) }} +{{ call_success_test(service, method, api, transport, is_async) }} {{ inteceptor_class_test(service, method, transport, is_async) }} {% endif %}{# if 'rest' in transport #} {% endif %}{# is_rest_unsupported_method(method, is_async) == 'False' and method.http_options #} @@ -1857,7 +1857,9 @@ def test_initialize_client_w_{{transport_name}}(): # As support is added for the above methods, the relevant guard can be removed from within the macro # TODO(https://github.com/googleapis/gapic-generator-python/issues/2142): Clean up `rest_required_tests` as we add support for each of the method types metioned above. #} -{% macro call_success_test(service, method, transport, is_async) %} +{% macro call_success_test(service, method, api, transport, is_async) %} +{% set protobuf_pythonic_types_enabled = api.all_library_settings[api.naming.proto_package].python_settings.experimental_features.protobuf_pythonic_types_enabled %} + {% set await_prefix = get_await_prefix(is_async) %} {% set async_prefix = get_async_prefix(is_async) %} {% set async_decorator = get_async_decorator(is_async) %} @@ -1899,6 +1901,7 @@ def test_initialize_client_w_{{transport_name}}(): # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 + {% if not protobuf_pythonic_types_enabled %} # Determine if the message type is proto-plus or protobuf test_field = {{ method.input.ident }}.meta.fields["{{ field.name }}"] @@ -1959,6 +1962,7 @@ def test_initialize_client_w_{{transport_name}}(): else: del request_init["{{ field.name }}"][field][subfield] {% endif %} + {% endif %} {% endfor %} request = request_type(**request_init) diff --git a/noxfile.py b/noxfile.py index 69af653873..bbbe8e5fc4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -251,7 +251,8 @@ def showcase_library( 'version': 'google.showcase.v1beta1', 'python_settings': { 'experimental_features': { - 'rest_async_io_enabled': True + 'rest_async_io_enabled': True, + 'protobuf_pythonic_types_enabled': True } } } diff --git a/tests/integration/goldens/redis/google/cloud/redis_v1/__init__.py b/tests/integration/goldens/redis/google/cloud/redis_v1/__init__.py index e89fe0cc8a..03e1bd1f38 100755 --- a/tests/integration/goldens/redis/google/cloud/redis_v1/__init__.py +++ b/tests/integration/goldens/redis/google/cloud/redis_v1/__init__.py @@ -21,33 +21,33 @@ from .services.cloud_redis import CloudRedisClient from .services.cloud_redis import CloudRedisAsyncClient -from .types.cloud_redis import CreateInstanceRequest -from .types.cloud_redis import DeleteInstanceRequest -from .types.cloud_redis import ExportInstanceRequest -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 OperationMetadata -from .types.cloud_redis import OutputConfig -from .types.cloud_redis import PersistenceConfig -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 +from .types.cloud_redis_pb2 import CreateInstanceRequest +from .types.cloud_redis_pb2 import DeleteInstanceRequest +from .types.cloud_redis_pb2 import ExportInstanceRequest +from .types.cloud_redis_pb2 import FailoverInstanceRequest +from .types.cloud_redis_pb2 import GcsDestination +from .types.cloud_redis_pb2 import GcsSource +from .types.cloud_redis_pb2 import GetInstanceAuthStringRequest +from .types.cloud_redis_pb2 import GetInstanceRequest +from .types.cloud_redis_pb2 import ImportInstanceRequest +from .types.cloud_redis_pb2 import InputConfig +from .types.cloud_redis_pb2 import Instance +from .types.cloud_redis_pb2 import InstanceAuthString +from .types.cloud_redis_pb2 import ListInstancesRequest +from .types.cloud_redis_pb2 import ListInstancesResponse +from .types.cloud_redis_pb2 import LocationMetadata +from .types.cloud_redis_pb2 import MaintenancePolicy +from .types.cloud_redis_pb2 import MaintenanceSchedule +from .types.cloud_redis_pb2 import NodeInfo +from .types.cloud_redis_pb2 import OperationMetadata +from .types.cloud_redis_pb2 import OutputConfig +from .types.cloud_redis_pb2 import PersistenceConfig +from .types.cloud_redis_pb2 import RescheduleMaintenanceRequest +from .types.cloud_redis_pb2 import TlsCertificate +from .types.cloud_redis_pb2 import UpdateInstanceRequest +from .types.cloud_redis_pb2 import UpgradeInstanceRequest +from .types.cloud_redis_pb2 import WeeklyMaintenanceWindow +from .types.cloud_redis_pb2 import ZoneMetadata __all__ = ( 'CloudRedisAsyncClient', diff --git a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/async_client.py b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/async_client.py index 24aa303c89..7ba9c666b5 100755 --- a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/async_client.py +++ b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/async_client.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + from collections import OrderedDict import re from typing import Dict, Callable, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union @@ -36,7 +37,7 @@ from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.cloud.redis_v1.services.cloud_redis import pagers -from google.cloud.redis_v1.types import cloud_redis +from google.cloud.redis_v1.types import cloud_redis_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -45,7 +46,6 @@ from .transports.grpc_asyncio import CloudRedisGrpcAsyncIOTransport from .client import CloudRedisClient - class CloudRedisAsyncClient: """Configures and manages Cloud Memorystore for Redis instances @@ -256,7 +256,7 @@ def __init__(self, *, ) async def list_instances(self, - request: Optional[Union[cloud_redis.ListInstancesRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.ListInstancesRequest, dict]] = None, *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, @@ -302,7 +302,7 @@ async def sample_list_instances(): print(response) Args: - request (Optional[Union[google.cloud.redis_v1.types.ListInstancesRequest, dict]]): + request (Optional[Union[google.cloud.redis_v1.types.ListInstancesRequest_pb2, dict]]): The request object. Request for [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances]. parent (:class:`str`): @@ -337,15 +337,15 @@ async def sample_list_instances(): raise ValueError("If the `request` argument is set, then none of " "the individual field arguments should be set.") - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.ListInstancesRequest): - request = cloud_redis.ListInstancesRequest(request) + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = cloud_redis_pb2.ListInstancesRequest(**request) + elif not request: + request = cloud_redis_pb2.ListInstancesRequest(parent=parent) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent + if parent is not None: + request.parent = parent # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -385,13 +385,13 @@ async def sample_list_instances(): return response async def get_instance(self, - request: Optional[Union[cloud_redis.GetInstanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.GetInstanceRequest, dict]] = None, *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> cloud_redis.Instance: + ) -> cloud_redis_pb2.Instance: r"""Gets the details of a specific Redis instance. .. code-block:: python @@ -421,7 +421,7 @@ async def sample_get_instance(): print(response) Args: - request (Optional[Union[google.cloud.redis_v1.types.GetInstanceRequest, dict]]): + request (Optional[Union[google.cloud.redis_v1.types.GetInstanceRequest_pb2, dict]]): The request object. Request for [GetInstance][google.cloud.redis.v1.CloudRedis.GetInstance]. name (:class:`str`): @@ -439,7 +439,7 @@ async def sample_get_instance(): sent along with the request as metadata. Returns: - google.cloud.redis_v1.types.Instance: + google.cloud.redis_v1.types.Instance_pb2: A Memorystore for Redis instance. """ # Create or coerce a protobuf request object. @@ -450,15 +450,15 @@ async def sample_get_instance(): raise ValueError("If the `request` argument is set, then none of " "the individual field arguments should be set.") - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.GetInstanceRequest): - request = cloud_redis.GetInstanceRequest(request) + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = cloud_redis_pb2.GetInstanceRequest(**request) + elif not request: + request = cloud_redis_pb2.GetInstanceRequest(name=name) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name + if name is not None: + request.name = name # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -487,13 +487,13 @@ async def sample_get_instance(): return response async def get_instance_auth_string(self, - request: Optional[Union[cloud_redis.GetInstanceAuthStringRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.GetInstanceAuthStringRequest, dict]] = None, *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> cloud_redis.InstanceAuthString: + ) -> cloud_redis_pb2.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 @@ -526,7 +526,7 @@ async def sample_get_instance_auth_string(): print(response) Args: - request (Optional[Union[google.cloud.redis_v1.types.GetInstanceAuthStringRequest, dict]]): + request (Optional[Union[google.cloud.redis_v1.types.GetInstanceAuthStringRequest_pb2, dict]]): The request object. Request for [GetInstanceAuthString][google.cloud.redis.v1.CloudRedis.GetInstanceAuthString]. name (:class:`str`): @@ -544,7 +544,7 @@ async def sample_get_instance_auth_string(): sent along with the request as metadata. Returns: - google.cloud.redis_v1.types.InstanceAuthString: + google.cloud.redis_v1.types.InstanceAuthString_pb2: Instance AUTH string details. """ # Create or coerce a protobuf request object. @@ -555,15 +555,15 @@ async def sample_get_instance_auth_string(): raise ValueError("If the `request` argument is set, then none of " "the individual field arguments should be set.") - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.GetInstanceAuthStringRequest): - request = cloud_redis.GetInstanceAuthStringRequest(request) + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = cloud_redis_pb2.GetInstanceAuthStringRequest(**request) + elif not request: + request = cloud_redis_pb2.GetInstanceAuthStringRequest(name=name) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name + if name is not None: + request.name = name # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -592,11 +592,11 @@ async def sample_get_instance_auth_string(): return response async def create_instance(self, - request: Optional[Union[cloud_redis.CreateInstanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.CreateInstanceRequest, dict]] = None, *, parent: Optional[str] = None, instance_id: Optional[str] = None, - instance: Optional[cloud_redis.Instance] = None, + instance: Optional[cloud_redis_pb2.Instance] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), @@ -654,7 +654,7 @@ async def sample_create_instance(): print(response) Args: - request (Optional[Union[google.cloud.redis_v1.types.CreateInstanceRequest, dict]]): + request (Optional[Union[google.cloud.redis_v1.types.CreateInstanceRequest_pb2, dict]]): The request object. Request for [CreateInstance][google.cloud.redis.v1.CloudRedis.CreateInstance]. parent (:class:`str`): @@ -680,7 +680,7 @@ async def sample_create_instance(): This corresponds to the ``instance_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - instance (:class:`google.cloud.redis_v1.types.Instance`): + instance (:class:`google.cloud.redis_v1.types.Instance_pb2`): Required. A Redis [Instance] resource This corresponds to the ``instance`` field on the ``request`` instance; if ``request`` is provided, this @@ -696,7 +696,7 @@ async def sample_create_instance(): An object representing a long-running operation. The result type for the operation will be - :class:`google.cloud.redis_v1.types.Instance` A + :class:`google.cloud.redis_v1.types.Instance_pb2` A Memorystore for Redis instance. """ @@ -708,19 +708,19 @@ async def sample_create_instance(): raise ValueError("If the `request` argument is set, then none of " "the individual field arguments should be set.") - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.CreateInstanceRequest): - request = cloud_redis.CreateInstanceRequest(request) + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = cloud_redis_pb2.CreateInstanceRequest(**request) + elif not request: + request = cloud_redis_pb2.CreateInstanceRequest(parent=parent, instance_id=instance_id, instance=instance) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if instance_id is not None: - request.instance_id = instance_id - if instance is not None: - request.instance = instance + if parent is not None: + request.parent = parent + if instance_id is not None: + request.instance_id = instance_id + if instance is not None: + request.instance.MergeFrom(instance) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -749,18 +749,18 @@ async def sample_create_instance(): response = operation_async.from_gapic( response, self._client._transport.operations_client, - cloud_redis.Instance, - metadata_type=cloud_redis.OperationMetadata, + cloud_redis_pb2.Instance, + metadata_type=cloud_redis_pb2.OperationMetadata, ) # Done; return the response. return response async def update_instance(self, - request: Optional[Union[cloud_redis.UpdateInstanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.UpdateInstanceRequest, dict]] = None, *, update_mask: Optional[field_mask_pb2.FieldMask] = None, - instance: Optional[cloud_redis.Instance] = None, + instance: Optional[cloud_redis_pb2.Instance] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), @@ -808,7 +808,7 @@ async def sample_update_instance(): print(response) Args: - request (Optional[Union[google.cloud.redis_v1.types.UpdateInstanceRequest, dict]]): + request (Optional[Union[google.cloud.redis_v1.types.UpdateInstanceRequest_pb2, dict]]): The request object. Request for [UpdateInstance][google.cloud.redis.v1.CloudRedis.UpdateInstance]. update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): @@ -826,7 +826,7 @@ async def sample_update_instance(): This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - instance (:class:`google.cloud.redis_v1.types.Instance`): + instance (:class:`google.cloud.redis_v1.types.Instance_pb2`): Required. Update description. Only fields specified in update_mask are updated. @@ -844,7 +844,7 @@ async def sample_update_instance(): An object representing a long-running operation. The result type for the operation will be - :class:`google.cloud.redis_v1.types.Instance` A + :class:`google.cloud.redis_v1.types.Instance_pb2` A Memorystore for Redis instance. """ @@ -856,17 +856,17 @@ async def sample_update_instance(): raise ValueError("If the `request` argument is set, then none of " "the individual field arguments should be set.") - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.UpdateInstanceRequest): - request = cloud_redis.UpdateInstanceRequest(request) + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = cloud_redis_pb2.UpdateInstanceRequest(**request) + elif not request: + request = cloud_redis_pb2.UpdateInstanceRequest(update_mask=update_mask, instance=instance) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if update_mask is not None: - request.update_mask = update_mask - if instance is not None: - request.instance = instance + if update_mask is not None: + request.update_mask.MergeFrom(update_mask) + if instance is not None: + request.instance.MergeFrom(instance) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -895,15 +895,15 @@ async def sample_update_instance(): response = operation_async.from_gapic( response, self._client._transport.operations_client, - cloud_redis.Instance, - metadata_type=cloud_redis.OperationMetadata, + cloud_redis_pb2.Instance, + metadata_type=cloud_redis_pb2.OperationMetadata, ) # Done; return the response. return response async def upgrade_instance(self, - request: Optional[Union[cloud_redis.UpgradeInstanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.UpgradeInstanceRequest, dict]] = None, *, name: Optional[str] = None, redis_version: Optional[str] = None, @@ -946,7 +946,7 @@ async def sample_upgrade_instance(): print(response) Args: - request (Optional[Union[google.cloud.redis_v1.types.UpgradeInstanceRequest, dict]]): + request (Optional[Union[google.cloud.redis_v1.types.UpgradeInstanceRequest_pb2, dict]]): The request object. Request for [UpgradeInstance][google.cloud.redis.v1.CloudRedis.UpgradeInstance]. name (:class:`str`): @@ -975,7 +975,7 @@ async def sample_upgrade_instance(): An object representing a long-running operation. The result type for the operation will be - :class:`google.cloud.redis_v1.types.Instance` A + :class:`google.cloud.redis_v1.types.Instance_pb2` A Memorystore for Redis instance. """ @@ -987,17 +987,17 @@ async def sample_upgrade_instance(): raise ValueError("If the `request` argument is set, then none of " "the individual field arguments should be set.") - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.UpgradeInstanceRequest): - request = cloud_redis.UpgradeInstanceRequest(request) + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = cloud_redis_pb2.UpgradeInstanceRequest(**request) + elif not request: + request = cloud_redis_pb2.UpgradeInstanceRequest(name=name, redis_version=redis_version) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - if redis_version is not None: - request.redis_version = redis_version + if name is not None: + request.name = name + if redis_version is not None: + request.redis_version = redis_version # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1026,18 +1026,18 @@ async def sample_upgrade_instance(): response = operation_async.from_gapic( response, self._client._transport.operations_client, - cloud_redis.Instance, - metadata_type=cloud_redis.OperationMetadata, + cloud_redis_pb2.Instance, + metadata_type=cloud_redis_pb2.OperationMetadata, ) # Done; return the response. return response async def import_instance(self, - request: Optional[Union[cloud_redis.ImportInstanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.ImportInstanceRequest, dict]] = None, *, name: Optional[str] = None, - input_config: Optional[cloud_redis.InputConfig] = None, + input_config: Optional[cloud_redis_pb2.InputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), @@ -1087,7 +1087,7 @@ async def sample_import_instance(): print(response) Args: - request (Optional[Union[google.cloud.redis_v1.types.ImportInstanceRequest, dict]]): + request (Optional[Union[google.cloud.redis_v1.types.ImportInstanceRequest_pb2, dict]]): The request object. Request for [Import][google.cloud.redis.v1.CloudRedis.ImportInstance]. name (:class:`str`): @@ -1098,7 +1098,7 @@ async def sample_import_instance(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - input_config (:class:`google.cloud.redis_v1.types.InputConfig`): + input_config (:class:`google.cloud.redis_v1.types.InputConfig_pb2`): Required. Specify data to be imported. @@ -1116,7 +1116,7 @@ async def sample_import_instance(): An object representing a long-running operation. The result type for the operation will be - :class:`google.cloud.redis_v1.types.Instance` A + :class:`google.cloud.redis_v1.types.Instance_pb2` A Memorystore for Redis instance. """ @@ -1128,17 +1128,17 @@ async def sample_import_instance(): raise ValueError("If the `request` argument is set, then none of " "the individual field arguments should be set.") - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.ImportInstanceRequest): - request = cloud_redis.ImportInstanceRequest(request) + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = cloud_redis_pb2.ImportInstanceRequest(**request) + elif not request: + request = cloud_redis_pb2.ImportInstanceRequest(name=name, input_config=input_config) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - if input_config is not None: - request.input_config = input_config + if name is not None: + request.name = name + if input_config is not None: + request.input_config.MergeFrom(input_config) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1167,18 +1167,18 @@ async def sample_import_instance(): response = operation_async.from_gapic( response, self._client._transport.operations_client, - cloud_redis.Instance, - metadata_type=cloud_redis.OperationMetadata, + cloud_redis_pb2.Instance, + metadata_type=cloud_redis_pb2.OperationMetadata, ) # Done; return the response. return response async def export_instance(self, - request: Optional[Union[cloud_redis.ExportInstanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.ExportInstanceRequest, dict]] = None, *, name: Optional[str] = None, - output_config: Optional[cloud_redis.OutputConfig] = None, + output_config: Optional[cloud_redis_pb2.OutputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), @@ -1225,7 +1225,7 @@ async def sample_export_instance(): print(response) Args: - request (Optional[Union[google.cloud.redis_v1.types.ExportInstanceRequest, dict]]): + request (Optional[Union[google.cloud.redis_v1.types.ExportInstanceRequest_pb2, dict]]): The request object. Request for [Export][google.cloud.redis.v1.CloudRedis.ExportInstance]. name (:class:`str`): @@ -1236,7 +1236,7 @@ async def sample_export_instance(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - output_config (:class:`google.cloud.redis_v1.types.OutputConfig`): + output_config (:class:`google.cloud.redis_v1.types.OutputConfig_pb2`): Required. Specify data to be exported. @@ -1254,7 +1254,7 @@ async def sample_export_instance(): An object representing a long-running operation. The result type for the operation will be - :class:`google.cloud.redis_v1.types.Instance` A + :class:`google.cloud.redis_v1.types.Instance_pb2` A Memorystore for Redis instance. """ @@ -1266,17 +1266,17 @@ async def sample_export_instance(): raise ValueError("If the `request` argument is set, then none of " "the individual field arguments should be set.") - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.ExportInstanceRequest): - request = cloud_redis.ExportInstanceRequest(request) + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = cloud_redis_pb2.ExportInstanceRequest(**request) + elif not request: + request = cloud_redis_pb2.ExportInstanceRequest(name=name, output_config=output_config) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - if output_config is not None: - request.output_config = output_config + if name is not None: + request.name = name + if output_config is not None: + request.output_config.MergeFrom(output_config) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1305,18 +1305,18 @@ async def sample_export_instance(): response = operation_async.from_gapic( response, self._client._transport.operations_client, - cloud_redis.Instance, - metadata_type=cloud_redis.OperationMetadata, + cloud_redis_pb2.Instance, + metadata_type=cloud_redis_pb2.OperationMetadata, ) # Done; return the response. return response async def failover_instance(self, - request: Optional[Union[cloud_redis.FailoverInstanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.FailoverInstanceRequest, dict]] = None, *, name: Optional[str] = None, - data_protection_mode: Optional[cloud_redis.FailoverInstanceRequest.DataProtectionMode] = None, + data_protection_mode: Optional[cloud_redis_pb2.FailoverInstanceRequest.DataProtectionMode] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), @@ -1356,7 +1356,7 @@ async def sample_failover_instance(): print(response) Args: - request (Optional[Union[google.cloud.redis_v1.types.FailoverInstanceRequest, dict]]): + request (Optional[Union[google.cloud.redis_v1.types.FailoverInstanceRequest_pb2, dict]]): The request object. Request for [Failover][google.cloud.redis.v1.CloudRedis.FailoverInstance]. name (:class:`str`): @@ -1367,7 +1367,7 @@ async def sample_failover_instance(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - data_protection_mode (:class:`google.cloud.redis_v1.types.FailoverInstanceRequest.DataProtectionMode`): + data_protection_mode (:class:`google.cloud.redis_v1.types.FailoverInstanceRequest.DataProtectionMode_pb2`): Optional. Available data protection modes that the user can choose. If it's unspecified, data protection mode will be LIMITED_DATA_LOSS by default. @@ -1386,7 +1386,7 @@ async def sample_failover_instance(): An object representing a long-running operation. The result type for the operation will be - :class:`google.cloud.redis_v1.types.Instance` A + :class:`google.cloud.redis_v1.types.Instance_pb2` A Memorystore for Redis instance. """ @@ -1398,17 +1398,17 @@ async def sample_failover_instance(): raise ValueError("If the `request` argument is set, then none of " "the individual field arguments should be set.") - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.FailoverInstanceRequest): - request = cloud_redis.FailoverInstanceRequest(request) + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = cloud_redis_pb2.FailoverInstanceRequest(**request) + elif not request: + request = cloud_redis_pb2.FailoverInstanceRequest(name=name, data_protection_mode=data_protection_mode) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name - if data_protection_mode is not None: - request.data_protection_mode = data_protection_mode + if name is not None: + request.name = name + if data_protection_mode is not None: + request.data_protection_mode = data_protection_mode # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1437,15 +1437,15 @@ async def sample_failover_instance(): response = operation_async.from_gapic( response, self._client._transport.operations_client, - cloud_redis.Instance, - metadata_type=cloud_redis.OperationMetadata, + cloud_redis_pb2.Instance, + metadata_type=cloud_redis_pb2.OperationMetadata, ) # Done; return the response. return response async def delete_instance(self, - request: Optional[Union[cloud_redis.DeleteInstanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.DeleteInstanceRequest, dict]] = None, *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, @@ -1486,7 +1486,7 @@ async def sample_delete_instance(): print(response) Args: - request (Optional[Union[google.cloud.redis_v1.types.DeleteInstanceRequest, dict]]): + request (Optional[Union[google.cloud.redis_v1.types.DeleteInstanceRequest_pb2, dict]]): The request object. Request for [DeleteInstance][google.cloud.redis.v1.CloudRedis.DeleteInstance]. name (:class:`str`): @@ -1527,15 +1527,15 @@ async def sample_delete_instance(): raise ValueError("If the `request` argument is set, then none of " "the individual field arguments should be set.") - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.DeleteInstanceRequest): - request = cloud_redis.DeleteInstanceRequest(request) + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = cloud_redis_pb2.DeleteInstanceRequest(**request) + elif not request: + request = cloud_redis_pb2.DeleteInstanceRequest(name=name) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if name is not None: - request.name = name + if name is not None: + request.name = name # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1565,17 +1565,17 @@ async def sample_delete_instance(): response, self._client._transport.operations_client, empty_pb2.Empty, - metadata_type=cloud_redis.OperationMetadata, + metadata_type=cloud_redis_pb2.OperationMetadata, ) # Done; return the response. return response async def reschedule_maintenance(self, - request: Optional[Union[cloud_redis.RescheduleMaintenanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.RescheduleMaintenanceRequest, dict]] = None, *, name: Optional[str] = None, - reschedule_type: Optional[cloud_redis.RescheduleMaintenanceRequest.RescheduleType] = None, + reschedule_type: Optional[cloud_redis_pb2.RescheduleMaintenanceRequest.RescheduleType] = None, schedule_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, @@ -1616,7 +1616,7 @@ async def sample_reschedule_maintenance(): print(response) Args: - request (Optional[Union[google.cloud.redis_v1.types.RescheduleMaintenanceRequest, dict]]): + request (Optional[Union[google.cloud.redis_v1.types.RescheduleMaintenanceRequest_pb2, dict]]): The request object. Request for [RescheduleMaintenance][google.cloud.redis.v1.CloudRedis.RescheduleMaintenance]. name (:class:`str`): @@ -1627,7 +1627,7 @@ async def sample_reschedule_maintenance(): 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_v1.types.RescheduleMaintenanceRequest.RescheduleType`): + reschedule_type (:class:`google.cloud.redis_v1.types.RescheduleMaintenanceRequest.RescheduleType_pb2`): Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. @@ -1653,7 +1653,7 @@ async def sample_reschedule_maintenance(): An object representing a long-running operation. The result type for the operation will be - :class:`google.cloud.redis_v1.types.Instance` A + :class:`google.cloud.redis_v1.types.Instance_pb2` A Memorystore for Redis instance. """ @@ -1665,19 +1665,19 @@ async def sample_reschedule_maintenance(): raise ValueError("If the `request` argument is set, then none of " "the individual field arguments should be set.") - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.RescheduleMaintenanceRequest): - request = cloud_redis.RescheduleMaintenanceRequest(request) + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = cloud_redis_pb2.RescheduleMaintenanceRequest(**request) + elif not request: + request = cloud_redis_pb2.RescheduleMaintenanceRequest(name=name, reschedule_type=reschedule_type, schedule_time=schedule_time) - # 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 + 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.MergeFrom(schedule_time) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1706,8 +1706,8 @@ async def sample_reschedule_maintenance(): response = operation_async.from_gapic( response, self._client._transport.operations_client, - cloud_redis.Instance, - metadata_type=cloud_redis.OperationMetadata, + cloud_redis_pb2.Instance, + metadata_type=cloud_redis_pb2.OperationMetadata, ) # Done; return the response. diff --git a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/client.py b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/client.py index 80d28b6d9a..ebf9aac3c1 100755 --- a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/client.py +++ b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/client.py @@ -40,7 +40,7 @@ from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.cloud.redis_v1.services.cloud_redis import pagers -from google.cloud.redis_v1.types import cloud_redis +from google.cloud.redis_v1.types import cloud_redis_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -605,7 +605,7 @@ def __init__(self, *, ) def list_instances(self, - request: Optional[Union[cloud_redis.ListInstancesRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.ListInstancesRequest, dict]] = None, *, parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, @@ -651,7 +651,7 @@ def sample_list_instances(): print(response) Args: - request (Union[google.cloud.redis_v1.types.ListInstancesRequest, dict]): + request (Union[google.cloud.redis_v1.types.ListInstancesRequest_pb2, dict]): The request object. Request for [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances]. parent (str): @@ -686,12 +686,13 @@ def sample_list_instances(): raise ValueError('If the `request` argument is set, then none of ' 'the individual field arguments should be set.') - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.ListInstancesRequest): - request = cloud_redis.ListInstancesRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. + if isinstance(request, dict): + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + request = cloud_redis_pb2.ListInstancesRequest(**request) + elif not request: + # Null request, just make one. + request = cloud_redis_pb2.ListInstancesRequest() if parent is not None: request.parent = parent @@ -733,13 +734,13 @@ def sample_list_instances(): return response def get_instance(self, - request: Optional[Union[cloud_redis.GetInstanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.GetInstanceRequest, dict]] = None, *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> cloud_redis.Instance: + ) -> cloud_redis_pb2.Instance: r"""Gets the details of a specific Redis instance. .. code-block:: python @@ -769,7 +770,7 @@ def sample_get_instance(): print(response) Args: - request (Union[google.cloud.redis_v1.types.GetInstanceRequest, dict]): + request (Union[google.cloud.redis_v1.types.GetInstanceRequest_pb2, dict]): The request object. Request for [GetInstance][google.cloud.redis.v1.CloudRedis.GetInstance]. name (str): @@ -787,7 +788,7 @@ def sample_get_instance(): sent along with the request as metadata. Returns: - google.cloud.redis_v1.types.Instance: + google.cloud.redis_v1.types.Instance_pb2: A Memorystore for Redis instance. """ # Create or coerce a protobuf request object. @@ -798,12 +799,13 @@ def sample_get_instance(): raise ValueError('If the `request` argument is set, then none of ' 'the individual field arguments should be set.') - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.GetInstanceRequest): - request = cloud_redis.GetInstanceRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. + if isinstance(request, dict): + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + request = cloud_redis_pb2.GetInstanceRequest(**request) + elif not request: + # Null request, just make one. + request = cloud_redis_pb2.GetInstanceRequest() if name is not None: request.name = name @@ -834,13 +836,13 @@ def sample_get_instance(): return response def get_instance_auth_string(self, - request: Optional[Union[cloud_redis.GetInstanceAuthStringRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.GetInstanceAuthStringRequest, dict]] = None, *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), - ) -> cloud_redis.InstanceAuthString: + ) -> cloud_redis_pb2.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 @@ -873,7 +875,7 @@ def sample_get_instance_auth_string(): print(response) Args: - request (Union[google.cloud.redis_v1.types.GetInstanceAuthStringRequest, dict]): + request (Union[google.cloud.redis_v1.types.GetInstanceAuthStringRequest_pb2, dict]): The request object. Request for [GetInstanceAuthString][google.cloud.redis.v1.CloudRedis.GetInstanceAuthString]. name (str): @@ -891,7 +893,7 @@ def sample_get_instance_auth_string(): sent along with the request as metadata. Returns: - google.cloud.redis_v1.types.InstanceAuthString: + google.cloud.redis_v1.types.InstanceAuthString_pb2: Instance AUTH string details. """ # Create or coerce a protobuf request object. @@ -902,12 +904,13 @@ def sample_get_instance_auth_string(): raise ValueError('If the `request` argument is set, then none of ' 'the individual field arguments should be set.') - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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 isinstance(request, dict): + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + request = cloud_redis_pb2.GetInstanceAuthStringRequest(**request) + elif not request: + # Null request, just make one. + request = cloud_redis_pb2.GetInstanceAuthStringRequest() if name is not None: request.name = name @@ -938,11 +941,11 @@ def sample_get_instance_auth_string(): return response def create_instance(self, - request: Optional[Union[cloud_redis.CreateInstanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.CreateInstanceRequest, dict]] = None, *, parent: Optional[str] = None, instance_id: Optional[str] = None, - instance: Optional[cloud_redis.Instance] = None, + instance: Optional[cloud_redis_pb2.Instance] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), @@ -1000,7 +1003,7 @@ def sample_create_instance(): print(response) Args: - request (Union[google.cloud.redis_v1.types.CreateInstanceRequest, dict]): + request (Union[google.cloud.redis_v1.types.CreateInstanceRequest_pb2, dict]): The request object. Request for [CreateInstance][google.cloud.redis.v1.CloudRedis.CreateInstance]. parent (str): @@ -1026,7 +1029,7 @@ def sample_create_instance(): This corresponds to the ``instance_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - instance (google.cloud.redis_v1.types.Instance): + instance (google.cloud.redis_v1.types.Instance_pb2): Required. A Redis [Instance] resource This corresponds to the ``instance`` field on the ``request`` instance; if ``request`` is provided, this @@ -1042,7 +1045,7 @@ def sample_create_instance(): An object representing a long-running operation. The result type for the operation will be - :class:`google.cloud.redis_v1.types.Instance` A + :class:`google.cloud.redis_v1.types.Instance_pb2` A Memorystore for Redis instance. """ @@ -1054,18 +1057,19 @@ def sample_create_instance(): raise ValueError('If the `request` argument is set, then none of ' 'the individual field arguments should be set.') - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.CreateInstanceRequest): - request = cloud_redis.CreateInstanceRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. + if isinstance(request, dict): + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + request = cloud_redis_pb2.CreateInstanceRequest(**request) + elif not request: + # Null request, just make one. + request = cloud_redis_pb2.CreateInstanceRequest() if parent is not None: request.parent = parent if instance_id is not None: request.instance_id = instance_id if instance is not None: - request.instance = instance + request.instance.MergeFrom(instance) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1094,18 +1098,18 @@ def sample_create_instance(): response = operation.from_gapic( response, self._transport.operations_client, - cloud_redis.Instance, - metadata_type=cloud_redis.OperationMetadata, + cloud_redis_pb2.Instance, + metadata_type=cloud_redis_pb2.OperationMetadata, ) # Done; return the response. return response def update_instance(self, - request: Optional[Union[cloud_redis.UpdateInstanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.UpdateInstanceRequest, dict]] = None, *, update_mask: Optional[field_mask_pb2.FieldMask] = None, - instance: Optional[cloud_redis.Instance] = None, + instance: Optional[cloud_redis_pb2.Instance] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), @@ -1153,7 +1157,7 @@ def sample_update_instance(): print(response) Args: - request (Union[google.cloud.redis_v1.types.UpdateInstanceRequest, dict]): + request (Union[google.cloud.redis_v1.types.UpdateInstanceRequest_pb2, dict]): The request object. Request for [UpdateInstance][google.cloud.redis.v1.CloudRedis.UpdateInstance]. update_mask (google.protobuf.field_mask_pb2.FieldMask): @@ -1171,7 +1175,7 @@ def sample_update_instance(): This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - instance (google.cloud.redis_v1.types.Instance): + instance (google.cloud.redis_v1.types.Instance_pb2): Required. Update description. Only fields specified in update_mask are updated. @@ -1189,7 +1193,7 @@ def sample_update_instance(): An object representing a long-running operation. The result type for the operation will be - :class:`google.cloud.redis_v1.types.Instance` A + :class:`google.cloud.redis_v1.types.Instance_pb2` A Memorystore for Redis instance. """ @@ -1201,16 +1205,17 @@ def sample_update_instance(): raise ValueError('If the `request` argument is set, then none of ' 'the individual field arguments should be set.') - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.UpdateInstanceRequest): - request = cloud_redis.UpdateInstanceRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. + if isinstance(request, dict): + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + request = cloud_redis_pb2.UpdateInstanceRequest(**request) + elif not request: + # Null request, just make one. + request = cloud_redis_pb2.UpdateInstanceRequest() if update_mask is not None: - request.update_mask = update_mask + request.update_mask.MergeFrom(update_mask) if instance is not None: - request.instance = instance + request.instance.MergeFrom(instance) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1239,15 +1244,15 @@ def sample_update_instance(): response = operation.from_gapic( response, self._transport.operations_client, - cloud_redis.Instance, - metadata_type=cloud_redis.OperationMetadata, + cloud_redis_pb2.Instance, + metadata_type=cloud_redis_pb2.OperationMetadata, ) # Done; return the response. return response def upgrade_instance(self, - request: Optional[Union[cloud_redis.UpgradeInstanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.UpgradeInstanceRequest, dict]] = None, *, name: Optional[str] = None, redis_version: Optional[str] = None, @@ -1290,7 +1295,7 @@ def sample_upgrade_instance(): print(response) Args: - request (Union[google.cloud.redis_v1.types.UpgradeInstanceRequest, dict]): + request (Union[google.cloud.redis_v1.types.UpgradeInstanceRequest_pb2, dict]): The request object. Request for [UpgradeInstance][google.cloud.redis.v1.CloudRedis.UpgradeInstance]. name (str): @@ -1319,7 +1324,7 @@ def sample_upgrade_instance(): An object representing a long-running operation. The result type for the operation will be - :class:`google.cloud.redis_v1.types.Instance` A + :class:`google.cloud.redis_v1.types.Instance_pb2` A Memorystore for Redis instance. """ @@ -1331,12 +1336,13 @@ def sample_upgrade_instance(): raise ValueError('If the `request` argument is set, then none of ' 'the individual field arguments should be set.') - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.UpgradeInstanceRequest): - request = cloud_redis.UpgradeInstanceRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. + if isinstance(request, dict): + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + request = cloud_redis_pb2.UpgradeInstanceRequest(**request) + elif not request: + # Null request, just make one. + request = cloud_redis_pb2.UpgradeInstanceRequest() if name is not None: request.name = name if redis_version is not None: @@ -1369,18 +1375,18 @@ def sample_upgrade_instance(): response = operation.from_gapic( response, self._transport.operations_client, - cloud_redis.Instance, - metadata_type=cloud_redis.OperationMetadata, + cloud_redis_pb2.Instance, + metadata_type=cloud_redis_pb2.OperationMetadata, ) # Done; return the response. return response def import_instance(self, - request: Optional[Union[cloud_redis.ImportInstanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.ImportInstanceRequest, dict]] = None, *, name: Optional[str] = None, - input_config: Optional[cloud_redis.InputConfig] = None, + input_config: Optional[cloud_redis_pb2.InputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), @@ -1430,7 +1436,7 @@ def sample_import_instance(): print(response) Args: - request (Union[google.cloud.redis_v1.types.ImportInstanceRequest, dict]): + request (Union[google.cloud.redis_v1.types.ImportInstanceRequest_pb2, dict]): The request object. Request for [Import][google.cloud.redis.v1.CloudRedis.ImportInstance]. name (str): @@ -1441,7 +1447,7 @@ def sample_import_instance(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - input_config (google.cloud.redis_v1.types.InputConfig): + input_config (google.cloud.redis_v1.types.InputConfig_pb2): Required. Specify data to be imported. @@ -1459,7 +1465,7 @@ def sample_import_instance(): An object representing a long-running operation. The result type for the operation will be - :class:`google.cloud.redis_v1.types.Instance` A + :class:`google.cloud.redis_v1.types.Instance_pb2` A Memorystore for Redis instance. """ @@ -1471,16 +1477,17 @@ def sample_import_instance(): raise ValueError('If the `request` argument is set, then none of ' 'the individual field arguments should be set.') - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.ImportInstanceRequest): - request = cloud_redis.ImportInstanceRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. + if isinstance(request, dict): + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + request = cloud_redis_pb2.ImportInstanceRequest(**request) + elif not request: + # Null request, just make one. + request = cloud_redis_pb2.ImportInstanceRequest() if name is not None: request.name = name if input_config is not None: - request.input_config = input_config + request.input_config.MergeFrom(input_config) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1509,18 +1516,18 @@ def sample_import_instance(): response = operation.from_gapic( response, self._transport.operations_client, - cloud_redis.Instance, - metadata_type=cloud_redis.OperationMetadata, + cloud_redis_pb2.Instance, + metadata_type=cloud_redis_pb2.OperationMetadata, ) # Done; return the response. return response def export_instance(self, - request: Optional[Union[cloud_redis.ExportInstanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.ExportInstanceRequest, dict]] = None, *, name: Optional[str] = None, - output_config: Optional[cloud_redis.OutputConfig] = None, + output_config: Optional[cloud_redis_pb2.OutputConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), @@ -1567,7 +1574,7 @@ def sample_export_instance(): print(response) Args: - request (Union[google.cloud.redis_v1.types.ExportInstanceRequest, dict]): + request (Union[google.cloud.redis_v1.types.ExportInstanceRequest_pb2, dict]): The request object. Request for [Export][google.cloud.redis.v1.CloudRedis.ExportInstance]. name (str): @@ -1578,7 +1585,7 @@ def sample_export_instance(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - output_config (google.cloud.redis_v1.types.OutputConfig): + output_config (google.cloud.redis_v1.types.OutputConfig_pb2): Required. Specify data to be exported. @@ -1596,7 +1603,7 @@ def sample_export_instance(): An object representing a long-running operation. The result type for the operation will be - :class:`google.cloud.redis_v1.types.Instance` A + :class:`google.cloud.redis_v1.types.Instance_pb2` A Memorystore for Redis instance. """ @@ -1608,16 +1615,17 @@ def sample_export_instance(): raise ValueError('If the `request` argument is set, then none of ' 'the individual field arguments should be set.') - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.ExportInstanceRequest): - request = cloud_redis.ExportInstanceRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. + if isinstance(request, dict): + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + request = cloud_redis_pb2.ExportInstanceRequest(**request) + elif not request: + # Null request, just make one. + request = cloud_redis_pb2.ExportInstanceRequest() if name is not None: request.name = name if output_config is not None: - request.output_config = output_config + request.output_config.MergeFrom(output_config) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1646,18 +1654,18 @@ def sample_export_instance(): response = operation.from_gapic( response, self._transport.operations_client, - cloud_redis.Instance, - metadata_type=cloud_redis.OperationMetadata, + cloud_redis_pb2.Instance, + metadata_type=cloud_redis_pb2.OperationMetadata, ) # Done; return the response. return response def failover_instance(self, - request: Optional[Union[cloud_redis.FailoverInstanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.FailoverInstanceRequest, dict]] = None, *, name: Optional[str] = None, - data_protection_mode: Optional[cloud_redis.FailoverInstanceRequest.DataProtectionMode] = None, + data_protection_mode: Optional[cloud_redis_pb2.FailoverInstanceRequest.DataProtectionMode] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), @@ -1697,7 +1705,7 @@ def sample_failover_instance(): print(response) Args: - request (Union[google.cloud.redis_v1.types.FailoverInstanceRequest, dict]): + request (Union[google.cloud.redis_v1.types.FailoverInstanceRequest_pb2, dict]): The request object. Request for [Failover][google.cloud.redis.v1.CloudRedis.FailoverInstance]. name (str): @@ -1708,7 +1716,7 @@ def sample_failover_instance(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - data_protection_mode (google.cloud.redis_v1.types.FailoverInstanceRequest.DataProtectionMode): + data_protection_mode (google.cloud.redis_v1.types.FailoverInstanceRequest.DataProtectionMode_pb2): Optional. Available data protection modes that the user can choose. If it's unspecified, data protection mode will be LIMITED_DATA_LOSS by default. @@ -1727,7 +1735,7 @@ def sample_failover_instance(): An object representing a long-running operation. The result type for the operation will be - :class:`google.cloud.redis_v1.types.Instance` A + :class:`google.cloud.redis_v1.types.Instance_pb2` A Memorystore for Redis instance. """ @@ -1739,12 +1747,13 @@ def sample_failover_instance(): raise ValueError('If the `request` argument is set, then none of ' 'the individual field arguments should be set.') - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.FailoverInstanceRequest): - request = cloud_redis.FailoverInstanceRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. + if isinstance(request, dict): + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + request = cloud_redis_pb2.FailoverInstanceRequest(**request) + elif not request: + # Null request, just make one. + request = cloud_redis_pb2.FailoverInstanceRequest() if name is not None: request.name = name if data_protection_mode is not None: @@ -1777,15 +1786,15 @@ def sample_failover_instance(): response = operation.from_gapic( response, self._transport.operations_client, - cloud_redis.Instance, - metadata_type=cloud_redis.OperationMetadata, + cloud_redis_pb2.Instance, + metadata_type=cloud_redis_pb2.OperationMetadata, ) # Done; return the response. return response def delete_instance(self, - request: Optional[Union[cloud_redis.DeleteInstanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.DeleteInstanceRequest, dict]] = None, *, name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, @@ -1826,7 +1835,7 @@ def sample_delete_instance(): print(response) Args: - request (Union[google.cloud.redis_v1.types.DeleteInstanceRequest, dict]): + request (Union[google.cloud.redis_v1.types.DeleteInstanceRequest_pb2, dict]): The request object. Request for [DeleteInstance][google.cloud.redis.v1.CloudRedis.DeleteInstance]. name (str): @@ -1867,12 +1876,13 @@ def sample_delete_instance(): raise ValueError('If the `request` argument is set, then none of ' 'the individual field arguments should be set.') - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, cloud_redis.DeleteInstanceRequest): - request = cloud_redis.DeleteInstanceRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. + if isinstance(request, dict): + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + request = cloud_redis_pb2.DeleteInstanceRequest(**request) + elif not request: + # Null request, just make one. + request = cloud_redis_pb2.DeleteInstanceRequest() if name is not None: request.name = name @@ -1904,17 +1914,17 @@ def sample_delete_instance(): response, self._transport.operations_client, empty_pb2.Empty, - metadata_type=cloud_redis.OperationMetadata, + metadata_type=cloud_redis_pb2.OperationMetadata, ) # Done; return the response. return response def reschedule_maintenance(self, - request: Optional[Union[cloud_redis.RescheduleMaintenanceRequest, dict]] = None, + request: Optional[Union[cloud_redis_pb2.RescheduleMaintenanceRequest, dict]] = None, *, name: Optional[str] = None, - reschedule_type: Optional[cloud_redis.RescheduleMaintenanceRequest.RescheduleType] = None, + reschedule_type: Optional[cloud_redis_pb2.RescheduleMaintenanceRequest.RescheduleType] = None, schedule_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, @@ -1955,7 +1965,7 @@ def sample_reschedule_maintenance(): print(response) Args: - request (Union[google.cloud.redis_v1.types.RescheduleMaintenanceRequest, dict]): + request (Union[google.cloud.redis_v1.types.RescheduleMaintenanceRequest_pb2, dict]): The request object. Request for [RescheduleMaintenance][google.cloud.redis.v1.CloudRedis.RescheduleMaintenance]. name (str): @@ -1966,7 +1976,7 @@ def sample_reschedule_maintenance(): This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - reschedule_type (google.cloud.redis_v1.types.RescheduleMaintenanceRequest.RescheduleType): + reschedule_type (google.cloud.redis_v1.types.RescheduleMaintenanceRequest.RescheduleType_pb2): Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. @@ -1992,7 +2002,7 @@ def sample_reschedule_maintenance(): An object representing a long-running operation. The result type for the operation will be - :class:`google.cloud.redis_v1.types.Instance` A + :class:`google.cloud.redis_v1.types.Instance_pb2` A Memorystore for Redis instance. """ @@ -2004,18 +2014,19 @@ def sample_reschedule_maintenance(): raise ValueError('If the `request` argument is set, then none of ' 'the individual field arguments should be set.') - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - 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 isinstance(request, dict): + # - The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + request = cloud_redis_pb2.RescheduleMaintenanceRequest(**request) + elif not request: + # Null request, just make one. + request = cloud_redis_pb2.RescheduleMaintenanceRequest() 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 + request.schedule_time.MergeFrom(schedule_time) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -2044,8 +2055,8 @@ def sample_reschedule_maintenance(): response = operation.from_gapic( response, self._transport.operations_client, - cloud_redis.Instance, - metadata_type=cloud_redis.OperationMetadata, + cloud_redis_pb2.Instance, + metadata_type=cloud_redis_pb2.OperationMetadata, ) # Done; return the response. diff --git a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/pagers.py b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/pagers.py index 55a7a66f95..e8d45a5aa5 100755 --- a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/pagers.py +++ b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/pagers.py @@ -24,14 +24,14 @@ OptionalRetry = Union[retries.Retry, object, None] # type: ignore OptionalAsyncRetry = Union[retries_async.AsyncRetry, object, None] # type: ignore -from google.cloud.redis_v1.types import cloud_redis +from google.cloud.redis_v1.types import cloud_redis_pb2 # type: ignore class ListInstancesPager: """A pager for iterating through ``list_instances`` requests. This class thinly wraps an initial - :class:`google.cloud.redis_v1.types.ListInstancesResponse` object, and + :class:`google.cloud.redis_v1.types.ListInstancesResponse_pb2` object, and provides an ``__iter__`` method to iterate through its ``instances`` field. @@ -40,14 +40,14 @@ class ListInstancesPager: through the ``instances`` field on the corresponding responses. - All the usual :class:`google.cloud.redis_v1.types.ListInstancesResponse` + All the usual :class:`google.cloud.redis_v1.types.ListInstancesResponse_pb2` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ def __init__(self, - method: Callable[..., cloud_redis.ListInstancesResponse], - request: cloud_redis.ListInstancesRequest, - response: cloud_redis.ListInstancesResponse, + method: Callable[..., cloud_redis_pb2.ListInstancesResponse], + request: cloud_redis_pb2.ListInstancesRequest, + response: cloud_redis_pb2.ListInstancesResponse, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, @@ -57,9 +57,9 @@ def __init__(self, Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (google.cloud.redis_v1.types.ListInstancesRequest): + request (google.cloud.redis_v1.types.ListInstancesRequest_pb2): The initial request object. - response (google.cloud.redis_v1.types.ListInstancesResponse): + response (google.cloud.redis_v1.types.ListInstancesResponse_pb2): The initial response object. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. @@ -68,7 +68,7 @@ def __init__(self, sent along with the request as metadata. """ self._method = method - self._request = cloud_redis.ListInstancesRequest(request) + self._request = request self._response = response self._retry = retry self._timeout = timeout @@ -78,14 +78,14 @@ def __getattr__(self, name: str) -> Any: return getattr(self._response, name) @property - def pages(self) -> Iterator[cloud_redis.ListInstancesResponse]: + def pages(self) -> Iterator[cloud_redis_pb2.ListInstancesResponse]: yield self._response while self._response.next_page_token: self._request.page_token = self._response.next_page_token self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) yield self._response - def __iter__(self) -> Iterator[cloud_redis.Instance]: + def __iter__(self) -> Iterator[cloud_redis_pb2.Instance]: for page in self.pages: yield from page.instances @@ -97,7 +97,7 @@ class ListInstancesAsyncPager: """A pager for iterating through ``list_instances`` requests. This class thinly wraps an initial - :class:`google.cloud.redis_v1.types.ListInstancesResponse` object, and + :class:`google.cloud.redis_v1.types.ListInstancesResponse_pb2` object, and provides an ``__aiter__`` method to iterate through its ``instances`` field. @@ -106,14 +106,14 @@ class ListInstancesAsyncPager: through the ``instances`` field on the corresponding responses. - All the usual :class:`google.cloud.redis_v1.types.ListInstancesResponse` + All the usual :class:`google.cloud.redis_v1.types.ListInstancesResponse_pb2` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ def __init__(self, - method: Callable[..., Awaitable[cloud_redis.ListInstancesResponse]], - request: cloud_redis.ListInstancesRequest, - response: cloud_redis.ListInstancesResponse, + method: Callable[..., Awaitable[cloud_redis_pb2.ListInstancesResponse]], + request: cloud_redis_pb2.ListInstancesRequest, + response: cloud_redis_pb2.ListInstancesResponse, *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, @@ -123,9 +123,9 @@ def __init__(self, Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (google.cloud.redis_v1.types.ListInstancesRequest): + request (google.cloud.redis_v1.types.ListInstancesRequest_pb2): The initial request object. - response (google.cloud.redis_v1.types.ListInstancesResponse): + response (google.cloud.redis_v1.types.ListInstancesResponse_pb2): The initial response object. retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. @@ -134,7 +134,7 @@ def __init__(self, sent along with the request as metadata. """ self._method = method - self._request = cloud_redis.ListInstancesRequest(request) + self._request = request self._response = response self._retry = retry self._timeout = timeout @@ -144,13 +144,13 @@ def __getattr__(self, name: str) -> Any: return getattr(self._response, name) @property - async def pages(self) -> AsyncIterator[cloud_redis.ListInstancesResponse]: + async def pages(self) -> AsyncIterator[cloud_redis_pb2.ListInstancesResponse]: yield self._response while self._response.next_page_token: self._request.page_token = self._response.next_page_token self._response = await self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) yield self._response - def __aiter__(self) -> AsyncIterator[cloud_redis.Instance]: + def __aiter__(self) -> AsyncIterator[cloud_redis_pb2.Instance]: async def async_generator(): async for page in self.pages: for response in page.instances: diff --git a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/base.py b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/base.py index 57832b4d91..e573fb2a6f 100755 --- a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/base.py +++ b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/base.py @@ -28,7 +28,7 @@ from google.oauth2 import service_account # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.cloud.redis_v1.types import cloud_redis +from google.cloud.redis_v1.types import cloud_redis_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) @@ -230,34 +230,34 @@ def operations_client(self): @property def list_instances(self) -> Callable[ - [cloud_redis.ListInstancesRequest], + [cloud_redis_pb2.ListInstancesRequest], Union[ - cloud_redis.ListInstancesResponse, - Awaitable[cloud_redis.ListInstancesResponse] + cloud_redis_pb2.ListInstancesResponse, + Awaitable[cloud_redis_pb2.ListInstancesResponse] ]]: raise NotImplementedError() @property def get_instance(self) -> Callable[ - [cloud_redis.GetInstanceRequest], + [cloud_redis_pb2.GetInstanceRequest], Union[ - cloud_redis.Instance, - Awaitable[cloud_redis.Instance] + cloud_redis_pb2.Instance, + Awaitable[cloud_redis_pb2.Instance] ]]: raise NotImplementedError() @property def get_instance_auth_string(self) -> Callable[ - [cloud_redis.GetInstanceAuthStringRequest], + [cloud_redis_pb2.GetInstanceAuthStringRequest], Union[ - cloud_redis.InstanceAuthString, - Awaitable[cloud_redis.InstanceAuthString] + cloud_redis_pb2.InstanceAuthString, + Awaitable[cloud_redis_pb2.InstanceAuthString] ]]: raise NotImplementedError() @property def create_instance(self) -> Callable[ - [cloud_redis.CreateInstanceRequest], + [cloud_redis_pb2.CreateInstanceRequest], Union[ operations_pb2.Operation, Awaitable[operations_pb2.Operation] @@ -266,7 +266,7 @@ def create_instance(self) -> Callable[ @property def update_instance(self) -> Callable[ - [cloud_redis.UpdateInstanceRequest], + [cloud_redis_pb2.UpdateInstanceRequest], Union[ operations_pb2.Operation, Awaitable[operations_pb2.Operation] @@ -275,7 +275,7 @@ def update_instance(self) -> Callable[ @property def upgrade_instance(self) -> Callable[ - [cloud_redis.UpgradeInstanceRequest], + [cloud_redis_pb2.UpgradeInstanceRequest], Union[ operations_pb2.Operation, Awaitable[operations_pb2.Operation] @@ -284,7 +284,7 @@ def upgrade_instance(self) -> Callable[ @property def import_instance(self) -> Callable[ - [cloud_redis.ImportInstanceRequest], + [cloud_redis_pb2.ImportInstanceRequest], Union[ operations_pb2.Operation, Awaitable[operations_pb2.Operation] @@ -293,7 +293,7 @@ def import_instance(self) -> Callable[ @property def export_instance(self) -> Callable[ - [cloud_redis.ExportInstanceRequest], + [cloud_redis_pb2.ExportInstanceRequest], Union[ operations_pb2.Operation, Awaitable[operations_pb2.Operation] @@ -302,7 +302,7 @@ def export_instance(self) -> Callable[ @property def failover_instance(self) -> Callable[ - [cloud_redis.FailoverInstanceRequest], + [cloud_redis_pb2.FailoverInstanceRequest], Union[ operations_pb2.Operation, Awaitable[operations_pb2.Operation] @@ -311,7 +311,7 @@ def failover_instance(self) -> Callable[ @property def delete_instance(self) -> Callable[ - [cloud_redis.DeleteInstanceRequest], + [cloud_redis_pb2.DeleteInstanceRequest], Union[ operations_pb2.Operation, Awaitable[operations_pb2.Operation] @@ -320,7 +320,7 @@ def delete_instance(self) -> Callable[ @property def reschedule_maintenance(self) -> Callable[ - [cloud_redis.RescheduleMaintenanceRequest], + [cloud_redis_pb2.RescheduleMaintenanceRequest], Union[ operations_pb2.Operation, Awaitable[operations_pb2.Operation] diff --git a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/grpc.py b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/grpc.py index 0df3839157..d2faa94878 100755 --- a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/grpc.py +++ b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/grpc.py @@ -26,7 +26,7 @@ import grpc # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.cloud.redis_v1.types import cloud_redis +from google.cloud.redis_v1.types import cloud_redis_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from .base import CloudRedisTransport, DEFAULT_CLIENT_INFO @@ -273,8 +273,8 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def list_instances(self) -> Callable[ - [cloud_redis.ListInstancesRequest], - cloud_redis.ListInstancesResponse]: + [cloud_redis_pb2.ListInstancesRequest], + cloud_redis_pb2.ListInstancesResponse]: r"""Return a callable for the list instances method over gRPC. Lists all Redis instances owned by a project in either the @@ -301,15 +301,15 @@ def list_instances(self) -> Callable[ if 'list_instances' not in self._stubs: self._stubs['list_instances'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/ListInstances', - request_serializer=cloud_redis.ListInstancesRequest.serialize, - response_deserializer=cloud_redis.ListInstancesResponse.deserialize, + request_serializer=cloud_redis_pb2.ListInstancesRequest.SerializeToString, + response_deserializer=cloud_redis_pb2.ListInstancesResponse.FromString, ) return self._stubs['list_instances'] @property def get_instance(self) -> Callable[ - [cloud_redis.GetInstanceRequest], - cloud_redis.Instance]: + [cloud_redis_pb2.GetInstanceRequest], + cloud_redis_pb2.Instance]: r"""Return a callable for the get instance method over gRPC. Gets the details of a specific Redis instance. @@ -327,15 +327,15 @@ def get_instance(self) -> Callable[ if 'get_instance' not in self._stubs: self._stubs['get_instance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/GetInstance', - request_serializer=cloud_redis.GetInstanceRequest.serialize, - response_deserializer=cloud_redis.Instance.deserialize, + request_serializer=cloud_redis_pb2.GetInstanceRequest.SerializeToString, + response_deserializer=cloud_redis_pb2.Instance.FromString, ) return self._stubs['get_instance'] @property def get_instance_auth_string(self) -> Callable[ - [cloud_redis.GetInstanceAuthStringRequest], - cloud_redis.InstanceAuthString]: + [cloud_redis_pb2.GetInstanceAuthStringRequest], + cloud_redis_pb2.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 @@ -356,14 +356,14 @@ def get_instance_auth_string(self) -> Callable[ if 'get_instance_auth_string' not in self._stubs: self._stubs['get_instance_auth_string'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/GetInstanceAuthString', - request_serializer=cloud_redis.GetInstanceAuthStringRequest.serialize, - response_deserializer=cloud_redis.InstanceAuthString.deserialize, + request_serializer=cloud_redis_pb2.GetInstanceAuthStringRequest.SerializeToString, + response_deserializer=cloud_redis_pb2.InstanceAuthString.FromString, ) return self._stubs['get_instance_auth_string'] @property def create_instance(self) -> Callable[ - [cloud_redis.CreateInstanceRequest], + [cloud_redis_pb2.CreateInstanceRequest], operations_pb2.Operation]: r"""Return a callable for the create instance method over gRPC. @@ -395,14 +395,14 @@ def create_instance(self) -> Callable[ if 'create_instance' not in self._stubs: self._stubs['create_instance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/CreateInstance', - request_serializer=cloud_redis.CreateInstanceRequest.serialize, + request_serializer=cloud_redis_pb2.CreateInstanceRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs['create_instance'] @property def update_instance(self) -> Callable[ - [cloud_redis.UpdateInstanceRequest], + [cloud_redis_pb2.UpdateInstanceRequest], operations_pb2.Operation]: r"""Return a callable for the update instance method over gRPC. @@ -426,14 +426,14 @@ def update_instance(self) -> Callable[ if 'update_instance' not in self._stubs: self._stubs['update_instance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/UpdateInstance', - request_serializer=cloud_redis.UpdateInstanceRequest.serialize, + request_serializer=cloud_redis_pb2.UpdateInstanceRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs['update_instance'] @property def upgrade_instance(self) -> Callable[ - [cloud_redis.UpgradeInstanceRequest], + [cloud_redis_pb2.UpgradeInstanceRequest], operations_pb2.Operation]: r"""Return a callable for the upgrade instance method over gRPC. @@ -453,14 +453,14 @@ def upgrade_instance(self) -> Callable[ if 'upgrade_instance' not in self._stubs: self._stubs['upgrade_instance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/UpgradeInstance', - request_serializer=cloud_redis.UpgradeInstanceRequest.serialize, + request_serializer=cloud_redis_pb2.UpgradeInstanceRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs['upgrade_instance'] @property def import_instance(self) -> Callable[ - [cloud_redis.ImportInstanceRequest], + [cloud_redis_pb2.ImportInstanceRequest], operations_pb2.Operation]: r"""Return a callable for the import instance method over gRPC. @@ -487,14 +487,14 @@ def import_instance(self) -> Callable[ if 'import_instance' not in self._stubs: self._stubs['import_instance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/ImportInstance', - request_serializer=cloud_redis.ImportInstanceRequest.serialize, + request_serializer=cloud_redis_pb2.ImportInstanceRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs['import_instance'] @property def export_instance(self) -> Callable[ - [cloud_redis.ExportInstanceRequest], + [cloud_redis_pb2.ExportInstanceRequest], operations_pb2.Operation]: r"""Return a callable for the export instance method over gRPC. @@ -518,14 +518,14 @@ def export_instance(self) -> Callable[ if 'export_instance' not in self._stubs: self._stubs['export_instance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/ExportInstance', - request_serializer=cloud_redis.ExportInstanceRequest.serialize, + request_serializer=cloud_redis_pb2.ExportInstanceRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs['export_instance'] @property def failover_instance(self) -> Callable[ - [cloud_redis.FailoverInstanceRequest], + [cloud_redis_pb2.FailoverInstanceRequest], operations_pb2.Operation]: r"""Return a callable for the failover instance method over gRPC. @@ -546,14 +546,14 @@ def failover_instance(self) -> Callable[ if 'failover_instance' not in self._stubs: self._stubs['failover_instance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/FailoverInstance', - request_serializer=cloud_redis.FailoverInstanceRequest.serialize, + request_serializer=cloud_redis_pb2.FailoverInstanceRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs['failover_instance'] @property def delete_instance(self) -> Callable[ - [cloud_redis.DeleteInstanceRequest], + [cloud_redis_pb2.DeleteInstanceRequest], operations_pb2.Operation]: r"""Return a callable for the delete instance method over gRPC. @@ -573,14 +573,14 @@ def delete_instance(self) -> Callable[ if 'delete_instance' not in self._stubs: self._stubs['delete_instance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/DeleteInstance', - request_serializer=cloud_redis.DeleteInstanceRequest.serialize, + request_serializer=cloud_redis_pb2.DeleteInstanceRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs['delete_instance'] @property def reschedule_maintenance(self) -> Callable[ - [cloud_redis.RescheduleMaintenanceRequest], + [cloud_redis_pb2.RescheduleMaintenanceRequest], operations_pb2.Operation]: r"""Return a callable for the reschedule maintenance method over gRPC. @@ -600,7 +600,7 @@ def reschedule_maintenance(self) -> Callable[ if 'reschedule_maintenance' not in self._stubs: self._stubs['reschedule_maintenance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/RescheduleMaintenance', - request_serializer=cloud_redis.RescheduleMaintenanceRequest.serialize, + request_serializer=cloud_redis_pb2.RescheduleMaintenanceRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs['reschedule_maintenance'] diff --git a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/grpc_asyncio.py b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/grpc_asyncio.py index 78b7c4d028..224574787a 100755 --- a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/grpc_asyncio.py +++ b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/grpc_asyncio.py @@ -29,7 +29,7 @@ from grpc.experimental import aio # type: ignore from google.cloud.location import locations_pb2 # type: ignore -from google.cloud.redis_v1.types import cloud_redis +from google.cloud.redis_v1.types import cloud_redis_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from .base import CloudRedisTransport, DEFAULT_CLIENT_INFO from .grpc import CloudRedisGrpcTransport @@ -279,8 +279,8 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: @property def list_instances(self) -> Callable[ - [cloud_redis.ListInstancesRequest], - Awaitable[cloud_redis.ListInstancesResponse]]: + [cloud_redis_pb2.ListInstancesRequest], + Awaitable[cloud_redis_pb2.ListInstancesResponse]]: r"""Return a callable for the list instances method over gRPC. Lists all Redis instances owned by a project in either the @@ -307,15 +307,15 @@ def list_instances(self) -> Callable[ if 'list_instances' not in self._stubs: self._stubs['list_instances'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/ListInstances', - request_serializer=cloud_redis.ListInstancesRequest.serialize, - response_deserializer=cloud_redis.ListInstancesResponse.deserialize, + request_serializer=cloud_redis_pb2.ListInstancesRequest.SerializeToString, + response_deserializer=cloud_redis_pb2.ListInstancesResponse.FromString, ) return self._stubs['list_instances'] @property def get_instance(self) -> Callable[ - [cloud_redis.GetInstanceRequest], - Awaitable[cloud_redis.Instance]]: + [cloud_redis_pb2.GetInstanceRequest], + Awaitable[cloud_redis_pb2.Instance]]: r"""Return a callable for the get instance method over gRPC. Gets the details of a specific Redis instance. @@ -333,15 +333,15 @@ def get_instance(self) -> Callable[ if 'get_instance' not in self._stubs: self._stubs['get_instance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/GetInstance', - request_serializer=cloud_redis.GetInstanceRequest.serialize, - response_deserializer=cloud_redis.Instance.deserialize, + request_serializer=cloud_redis_pb2.GetInstanceRequest.SerializeToString, + response_deserializer=cloud_redis_pb2.Instance.FromString, ) return self._stubs['get_instance'] @property def get_instance_auth_string(self) -> Callable[ - [cloud_redis.GetInstanceAuthStringRequest], - Awaitable[cloud_redis.InstanceAuthString]]: + [cloud_redis_pb2.GetInstanceAuthStringRequest], + Awaitable[cloud_redis_pb2.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 @@ -362,14 +362,14 @@ def get_instance_auth_string(self) -> Callable[ if 'get_instance_auth_string' not in self._stubs: self._stubs['get_instance_auth_string'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/GetInstanceAuthString', - request_serializer=cloud_redis.GetInstanceAuthStringRequest.serialize, - response_deserializer=cloud_redis.InstanceAuthString.deserialize, + request_serializer=cloud_redis_pb2.GetInstanceAuthStringRequest.SerializeToString, + response_deserializer=cloud_redis_pb2.InstanceAuthString.FromString, ) return self._stubs['get_instance_auth_string'] @property def create_instance(self) -> Callable[ - [cloud_redis.CreateInstanceRequest], + [cloud_redis_pb2.CreateInstanceRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the create instance method over gRPC. @@ -401,14 +401,14 @@ def create_instance(self) -> Callable[ if 'create_instance' not in self._stubs: self._stubs['create_instance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/CreateInstance', - request_serializer=cloud_redis.CreateInstanceRequest.serialize, + request_serializer=cloud_redis_pb2.CreateInstanceRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs['create_instance'] @property def update_instance(self) -> Callable[ - [cloud_redis.UpdateInstanceRequest], + [cloud_redis_pb2.UpdateInstanceRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the update instance method over gRPC. @@ -432,14 +432,14 @@ def update_instance(self) -> Callable[ if 'update_instance' not in self._stubs: self._stubs['update_instance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/UpdateInstance', - request_serializer=cloud_redis.UpdateInstanceRequest.serialize, + request_serializer=cloud_redis_pb2.UpdateInstanceRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs['update_instance'] @property def upgrade_instance(self) -> Callable[ - [cloud_redis.UpgradeInstanceRequest], + [cloud_redis_pb2.UpgradeInstanceRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the upgrade instance method over gRPC. @@ -459,14 +459,14 @@ def upgrade_instance(self) -> Callable[ if 'upgrade_instance' not in self._stubs: self._stubs['upgrade_instance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/UpgradeInstance', - request_serializer=cloud_redis.UpgradeInstanceRequest.serialize, + request_serializer=cloud_redis_pb2.UpgradeInstanceRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs['upgrade_instance'] @property def import_instance(self) -> Callable[ - [cloud_redis.ImportInstanceRequest], + [cloud_redis_pb2.ImportInstanceRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the import instance method over gRPC. @@ -493,14 +493,14 @@ def import_instance(self) -> Callable[ if 'import_instance' not in self._stubs: self._stubs['import_instance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/ImportInstance', - request_serializer=cloud_redis.ImportInstanceRequest.serialize, + request_serializer=cloud_redis_pb2.ImportInstanceRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs['import_instance'] @property def export_instance(self) -> Callable[ - [cloud_redis.ExportInstanceRequest], + [cloud_redis_pb2.ExportInstanceRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the export instance method over gRPC. @@ -524,14 +524,14 @@ def export_instance(self) -> Callable[ if 'export_instance' not in self._stubs: self._stubs['export_instance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/ExportInstance', - request_serializer=cloud_redis.ExportInstanceRequest.serialize, + request_serializer=cloud_redis_pb2.ExportInstanceRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs['export_instance'] @property def failover_instance(self) -> Callable[ - [cloud_redis.FailoverInstanceRequest], + [cloud_redis_pb2.FailoverInstanceRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the failover instance method over gRPC. @@ -552,14 +552,14 @@ def failover_instance(self) -> Callable[ if 'failover_instance' not in self._stubs: self._stubs['failover_instance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/FailoverInstance', - request_serializer=cloud_redis.FailoverInstanceRequest.serialize, + request_serializer=cloud_redis_pb2.FailoverInstanceRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs['failover_instance'] @property def delete_instance(self) -> Callable[ - [cloud_redis.DeleteInstanceRequest], + [cloud_redis_pb2.DeleteInstanceRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the delete instance method over gRPC. @@ -579,14 +579,14 @@ def delete_instance(self) -> Callable[ if 'delete_instance' not in self._stubs: self._stubs['delete_instance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/DeleteInstance', - request_serializer=cloud_redis.DeleteInstanceRequest.serialize, + request_serializer=cloud_redis_pb2.DeleteInstanceRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs['delete_instance'] @property def reschedule_maintenance(self) -> Callable[ - [cloud_redis.RescheduleMaintenanceRequest], + [cloud_redis_pb2.RescheduleMaintenanceRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the reschedule maintenance method over gRPC. @@ -606,7 +606,7 @@ def reschedule_maintenance(self) -> Callable[ if 'reschedule_maintenance' not in self._stubs: self._stubs['reschedule_maintenance'] = self.grpc_channel.unary_unary( '/google.cloud.redis.v1.CloudRedis/RescheduleMaintenance', - request_serializer=cloud_redis.RescheduleMaintenanceRequest.serialize, + request_serializer=cloud_redis_pb2.RescheduleMaintenanceRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs['reschedule_maintenance'] diff --git a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest.py b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest.py index 2e18f09cd9..346f69e799 100755 --- a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest.py +++ b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest.py @@ -33,7 +33,7 @@ import warnings -from google.cloud.redis_v1.types import cloud_redis +from google.cloud.redis_v1.types import cloud_redis_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore @@ -161,7 +161,7 @@ def post_upgrade_instance(self, response): """ - def pre_create_instance(self, request: cloud_redis.CreateInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.CreateInstanceRequest, Sequence[Tuple[str, str]]]: + def pre_create_instance(self, request: cloud_redis_pb2.CreateInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.CreateInstanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for create_instance Override in a subclass to manipulate the request or metadata @@ -178,7 +178,7 @@ def post_create_instance(self, response: operations_pb2.Operation) -> operations """ return response - def pre_delete_instance(self, request: cloud_redis.DeleteInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.DeleteInstanceRequest, Sequence[Tuple[str, str]]]: + def pre_delete_instance(self, request: cloud_redis_pb2.DeleteInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.DeleteInstanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for delete_instance Override in a subclass to manipulate the request or metadata @@ -195,7 +195,7 @@ def post_delete_instance(self, response: operations_pb2.Operation) -> operations """ return response - def pre_export_instance(self, request: cloud_redis.ExportInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.ExportInstanceRequest, Sequence[Tuple[str, str]]]: + def pre_export_instance(self, request: cloud_redis_pb2.ExportInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.ExportInstanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for export_instance Override in a subclass to manipulate the request or metadata @@ -212,7 +212,7 @@ def post_export_instance(self, response: operations_pb2.Operation) -> operations """ return response - def pre_failover_instance(self, request: cloud_redis.FailoverInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.FailoverInstanceRequest, Sequence[Tuple[str, str]]]: + def pre_failover_instance(self, request: cloud_redis_pb2.FailoverInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.FailoverInstanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for failover_instance Override in a subclass to manipulate the request or metadata @@ -229,7 +229,7 @@ def post_failover_instance(self, response: operations_pb2.Operation) -> operatio """ return response - def pre_get_instance(self, request: cloud_redis.GetInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.GetInstanceRequest, Sequence[Tuple[str, str]]]: + def pre_get_instance(self, request: cloud_redis_pb2.GetInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.GetInstanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata @@ -237,7 +237,7 @@ def pre_get_instance(self, request: cloud_redis.GetInstanceRequest, metadata: Se """ return request, metadata - def post_get_instance(self, response: cloud_redis.Instance) -> cloud_redis.Instance: + def post_get_instance(self, response: cloud_redis_pb2.Instance) -> cloud_redis_pb2.Instance: """Post-rpc interceptor for get_instance Override in a subclass to manipulate the response @@ -246,7 +246,7 @@ def post_get_instance(self, response: cloud_redis.Instance) -> cloud_redis.Insta """ return response - def pre_get_instance_auth_string(self, request: cloud_redis.GetInstanceAuthStringRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.GetInstanceAuthStringRequest, Sequence[Tuple[str, str]]]: + def pre_get_instance_auth_string(self, request: cloud_redis_pb2.GetInstanceAuthStringRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.GetInstanceAuthStringRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for get_instance_auth_string Override in a subclass to manipulate the request or metadata @@ -254,7 +254,7 @@ def pre_get_instance_auth_string(self, request: cloud_redis.GetInstanceAuthStrin """ return request, metadata - def post_get_instance_auth_string(self, response: cloud_redis.InstanceAuthString) -> cloud_redis.InstanceAuthString: + def post_get_instance_auth_string(self, response: cloud_redis_pb2.InstanceAuthString) -> cloud_redis_pb2.InstanceAuthString: """Post-rpc interceptor for get_instance_auth_string Override in a subclass to manipulate the response @@ -263,7 +263,7 @@ def post_get_instance_auth_string(self, response: cloud_redis.InstanceAuthString """ return response - def pre_import_instance(self, request: cloud_redis.ImportInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.ImportInstanceRequest, Sequence[Tuple[str, str]]]: + def pre_import_instance(self, request: cloud_redis_pb2.ImportInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.ImportInstanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for import_instance Override in a subclass to manipulate the request or metadata @@ -280,7 +280,7 @@ def post_import_instance(self, response: operations_pb2.Operation) -> operations """ return response - def pre_list_instances(self, request: cloud_redis.ListInstancesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.ListInstancesRequest, Sequence[Tuple[str, str]]]: + def pre_list_instances(self, request: cloud_redis_pb2.ListInstancesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.ListInstancesRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for list_instances Override in a subclass to manipulate the request or metadata @@ -288,7 +288,7 @@ def pre_list_instances(self, request: cloud_redis.ListInstancesRequest, metadata """ return request, metadata - def post_list_instances(self, response: cloud_redis.ListInstancesResponse) -> cloud_redis.ListInstancesResponse: + def post_list_instances(self, response: cloud_redis_pb2.ListInstancesResponse) -> cloud_redis_pb2.ListInstancesResponse: """Post-rpc interceptor for list_instances Override in a subclass to manipulate the response @@ -297,7 +297,7 @@ def post_list_instances(self, response: cloud_redis.ListInstancesResponse) -> cl """ return response - def pre_reschedule_maintenance(self, request: cloud_redis.RescheduleMaintenanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.RescheduleMaintenanceRequest, Sequence[Tuple[str, str]]]: + def pre_reschedule_maintenance(self, request: cloud_redis_pb2.RescheduleMaintenanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.RescheduleMaintenanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for reschedule_maintenance Override in a subclass to manipulate the request or metadata @@ -314,7 +314,7 @@ def post_reschedule_maintenance(self, response: operations_pb2.Operation) -> ope """ return response - def pre_update_instance(self, request: cloud_redis.UpdateInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.UpdateInstanceRequest, Sequence[Tuple[str, str]]]: + def pre_update_instance(self, request: cloud_redis_pb2.UpdateInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.UpdateInstanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for update_instance Override in a subclass to manipulate the request or metadata @@ -331,7 +331,7 @@ def post_update_instance(self, response: operations_pb2.Operation) -> operations """ return response - def pre_upgrade_instance(self, request: cloud_redis.UpgradeInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.UpgradeInstanceRequest, Sequence[Tuple[str, str]]]: + def pre_upgrade_instance(self, request: cloud_redis_pb2.UpgradeInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.UpgradeInstanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for upgrade_instance Override in a subclass to manipulate the request or metadata @@ -689,7 +689,7 @@ def _get_response( return response def __call__(self, - request: cloud_redis.CreateInstanceRequest, *, + request: cloud_redis_pb2.CreateInstanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), @@ -697,7 +697,7 @@ def __call__(self, r"""Call the create instance method over HTTP. Args: - request (~.cloud_redis.CreateInstanceRequest): + request (~.cloud_redis_pb2.CreateInstanceRequest): The request object. Request for [CreateInstance][google.cloud.redis.v1.CloudRedis.CreateInstance]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -764,7 +764,7 @@ def _get_response( return response def __call__(self, - request: cloud_redis.DeleteInstanceRequest, *, + request: cloud_redis_pb2.DeleteInstanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), @@ -772,7 +772,7 @@ def __call__(self, r"""Call the delete instance method over HTTP. Args: - request (~.cloud_redis.DeleteInstanceRequest): + request (~.cloud_redis_pb2.DeleteInstanceRequest): The request object. Request for [DeleteInstance][google.cloud.redis.v1.CloudRedis.DeleteInstance]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -838,7 +838,7 @@ def _get_response( return response def __call__(self, - request: cloud_redis.ExportInstanceRequest, *, + request: cloud_redis_pb2.ExportInstanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), @@ -846,7 +846,7 @@ def __call__(self, r"""Call the export instance method over HTTP. Args: - request (~.cloud_redis.ExportInstanceRequest): + request (~.cloud_redis_pb2.ExportInstanceRequest): The request object. Request for [Export][google.cloud.redis.v1.CloudRedis.ExportInstance]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -914,7 +914,7 @@ def _get_response( return response def __call__(self, - request: cloud_redis.FailoverInstanceRequest, *, + request: cloud_redis_pb2.FailoverInstanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), @@ -922,7 +922,7 @@ def __call__(self, r"""Call the failover instance method over HTTP. Args: - request (~.cloud_redis.FailoverInstanceRequest): + request (~.cloud_redis_pb2.FailoverInstanceRequest): The request object. Request for [Failover][google.cloud.redis.v1.CloudRedis.FailoverInstance]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -989,15 +989,15 @@ def _get_response( return response def __call__(self, - request: cloud_redis.GetInstanceRequest, *, + request: cloud_redis_pb2.GetInstanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), - ) -> cloud_redis.Instance: + ) -> cloud_redis_pb2.Instance: r"""Call the get instance method over HTTP. Args: - request (~.cloud_redis.GetInstanceRequest): + request (~.cloud_redis_pb2.GetInstanceRequest): The request object. Request for [GetInstance][google.cloud.redis.v1.CloudRedis.GetInstance]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -1007,7 +1007,7 @@ def __call__(self, sent along with the request as metadata. Returns: - ~.cloud_redis.Instance: + ~.cloud_redis_pb2.Instance: A Memorystore for Redis instance. """ @@ -1027,8 +1027,8 @@ def __call__(self, raise core_exceptions.from_http_response(response) # Return the response - resp = cloud_redis.Instance() - pb_resp = cloud_redis.Instance.pb(resp) + resp = cloud_redis_pb2.Instance() + pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_get_instance(resp) @@ -1061,15 +1061,15 @@ def _get_response( return response def __call__(self, - request: cloud_redis.GetInstanceAuthStringRequest, *, + request: cloud_redis_pb2.GetInstanceAuthStringRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), - ) -> cloud_redis.InstanceAuthString: + ) -> cloud_redis_pb2.InstanceAuthString: r"""Call the get instance auth string method over HTTP. Args: - request (~.cloud_redis.GetInstanceAuthStringRequest): + request (~.cloud_redis_pb2.GetInstanceAuthStringRequest): The request object. Request for [GetInstanceAuthString][google.cloud.redis.v1.CloudRedis.GetInstanceAuthString]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -1079,7 +1079,7 @@ def __call__(self, sent along with the request as metadata. Returns: - ~.cloud_redis.InstanceAuthString: + ~.cloud_redis_pb2.InstanceAuthString: Instance AUTH string details. """ @@ -1099,8 +1099,8 @@ def __call__(self, raise core_exceptions.from_http_response(response) # Return the response - resp = cloud_redis.InstanceAuthString() - pb_resp = cloud_redis.InstanceAuthString.pb(resp) + resp = cloud_redis_pb2.InstanceAuthString() + pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_get_instance_auth_string(resp) @@ -1134,7 +1134,7 @@ def _get_response( return response def __call__(self, - request: cloud_redis.ImportInstanceRequest, *, + request: cloud_redis_pb2.ImportInstanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), @@ -1142,7 +1142,7 @@ def __call__(self, r"""Call the import instance method over HTTP. Args: - request (~.cloud_redis.ImportInstanceRequest): + request (~.cloud_redis_pb2.ImportInstanceRequest): The request object. Request for [Import][google.cloud.redis.v1.CloudRedis.ImportInstance]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -1209,15 +1209,15 @@ def _get_response( return response def __call__(self, - request: cloud_redis.ListInstancesRequest, *, + request: cloud_redis_pb2.ListInstancesRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), - ) -> cloud_redis.ListInstancesResponse: + ) -> cloud_redis_pb2.ListInstancesResponse: r"""Call the list instances method over HTTP. Args: - request (~.cloud_redis.ListInstancesRequest): + request (~.cloud_redis_pb2.ListInstancesRequest): The request object. Request for [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -1227,7 +1227,7 @@ def __call__(self, sent along with the request as metadata. Returns: - ~.cloud_redis.ListInstancesResponse: + ~.cloud_redis_pb2.ListInstancesResponse: Response for [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances]. @@ -1249,8 +1249,8 @@ def __call__(self, raise core_exceptions.from_http_response(response) # Return the response - resp = cloud_redis.ListInstancesResponse() - pb_resp = cloud_redis.ListInstancesResponse.pb(resp) + resp = cloud_redis_pb2.ListInstancesResponse() + pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_list_instances(resp) @@ -1284,7 +1284,7 @@ def _get_response( return response def __call__(self, - request: cloud_redis.RescheduleMaintenanceRequest, *, + request: cloud_redis_pb2.RescheduleMaintenanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), @@ -1292,7 +1292,7 @@ def __call__(self, r"""Call the reschedule maintenance method over HTTP. Args: - request (~.cloud_redis.RescheduleMaintenanceRequest): + request (~.cloud_redis_pb2.RescheduleMaintenanceRequest): The request object. Request for [RescheduleMaintenance][google.cloud.redis.v1.CloudRedis.RescheduleMaintenance]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -1360,7 +1360,7 @@ def _get_response( return response def __call__(self, - request: cloud_redis.UpdateInstanceRequest, *, + request: cloud_redis_pb2.UpdateInstanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), @@ -1368,7 +1368,7 @@ def __call__(self, r"""Call the update instance method over HTTP. Args: - request (~.cloud_redis.UpdateInstanceRequest): + request (~.cloud_redis_pb2.UpdateInstanceRequest): The request object. Request for [UpdateInstance][google.cloud.redis.v1.CloudRedis.UpdateInstance]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -1436,7 +1436,7 @@ def _get_response( return response def __call__(self, - request: cloud_redis.UpgradeInstanceRequest, *, + request: cloud_redis_pb2.UpgradeInstanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), @@ -1444,7 +1444,7 @@ def __call__(self, r"""Call the upgrade instance method over HTTP. Args: - request (~.cloud_redis.UpgradeInstanceRequest): + request (~.cloud_redis_pb2.UpgradeInstanceRequest): The request object. Request for [UpgradeInstance][google.cloud.redis.v1.CloudRedis.UpgradeInstance]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -1486,7 +1486,7 @@ def __call__(self, @property def create_instance(self) -> Callable[ - [cloud_redis.CreateInstanceRequest], + [cloud_redis_pb2.CreateInstanceRequest], operations_pb2.Operation]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast @@ -1494,7 +1494,7 @@ def create_instance(self) -> Callable[ @property def delete_instance(self) -> Callable[ - [cloud_redis.DeleteInstanceRequest], + [cloud_redis_pb2.DeleteInstanceRequest], operations_pb2.Operation]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast @@ -1502,7 +1502,7 @@ def delete_instance(self) -> Callable[ @property def export_instance(self) -> Callable[ - [cloud_redis.ExportInstanceRequest], + [cloud_redis_pb2.ExportInstanceRequest], operations_pb2.Operation]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast @@ -1510,7 +1510,7 @@ def export_instance(self) -> Callable[ @property def failover_instance(self) -> Callable[ - [cloud_redis.FailoverInstanceRequest], + [cloud_redis_pb2.FailoverInstanceRequest], operations_pb2.Operation]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast @@ -1518,23 +1518,23 @@ def failover_instance(self) -> Callable[ @property def get_instance(self) -> Callable[ - [cloud_redis.GetInstanceRequest], - cloud_redis.Instance]: + [cloud_redis_pb2.GetInstanceRequest], + cloud_redis_pb2.Instance]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast return self._GetInstance(self._session, self._host, self._interceptor) # type: ignore @property def get_instance_auth_string(self) -> Callable[ - [cloud_redis.GetInstanceAuthStringRequest], - cloud_redis.InstanceAuthString]: + [cloud_redis_pb2.GetInstanceAuthStringRequest], + cloud_redis_pb2.InstanceAuthString]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast return self._GetInstanceAuthString(self._session, self._host, self._interceptor) # type: ignore @property def import_instance(self) -> Callable[ - [cloud_redis.ImportInstanceRequest], + [cloud_redis_pb2.ImportInstanceRequest], operations_pb2.Operation]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast @@ -1542,15 +1542,15 @@ def import_instance(self) -> Callable[ @property def list_instances(self) -> Callable[ - [cloud_redis.ListInstancesRequest], - cloud_redis.ListInstancesResponse]: + [cloud_redis_pb2.ListInstancesRequest], + cloud_redis_pb2.ListInstancesResponse]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast return self._ListInstances(self._session, self._host, self._interceptor) # type: ignore @property def reschedule_maintenance(self) -> Callable[ - [cloud_redis.RescheduleMaintenanceRequest], + [cloud_redis_pb2.RescheduleMaintenanceRequest], operations_pb2.Operation]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast @@ -1558,7 +1558,7 @@ def reschedule_maintenance(self) -> Callable[ @property def update_instance(self) -> Callable[ - [cloud_redis.UpdateInstanceRequest], + [cloud_redis_pb2.UpdateInstanceRequest], operations_pb2.Operation]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast @@ -1566,7 +1566,7 @@ def update_instance(self) -> Callable[ @property def upgrade_instance(self) -> Callable[ - [cloud_redis.UpgradeInstanceRequest], + [cloud_redis_pb2.UpgradeInstanceRequest], operations_pb2.Operation]: # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. # In C++ this would require a dynamic_cast diff --git a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest_asyncio.py b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest_asyncio.py index 4eff5c3698..298269ccfb 100755 --- a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest_asyncio.py +++ b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest_asyncio.py @@ -43,7 +43,7 @@ from typing import Any, Dict, List, Callable, Tuple, Optional, Sequence, Union -from google.cloud.redis_v1.types import cloud_redis +from google.cloud.redis_v1.types import cloud_redis_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore @@ -171,7 +171,7 @@ async def post_upgrade_instance(self, response): """ - async def pre_create_instance(self, request: cloud_redis.CreateInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.CreateInstanceRequest, Sequence[Tuple[str, str]]]: + async def pre_create_instance(self, request: cloud_redis_pb2.CreateInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.CreateInstanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for create_instance Override in a subclass to manipulate the request or metadata @@ -188,7 +188,7 @@ async def post_create_instance(self, response: operations_pb2.Operation) -> oper """ return response - async def pre_delete_instance(self, request: cloud_redis.DeleteInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.DeleteInstanceRequest, Sequence[Tuple[str, str]]]: + async def pre_delete_instance(self, request: cloud_redis_pb2.DeleteInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.DeleteInstanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for delete_instance Override in a subclass to manipulate the request or metadata @@ -205,7 +205,7 @@ async def post_delete_instance(self, response: operations_pb2.Operation) -> oper """ return response - async def pre_export_instance(self, request: cloud_redis.ExportInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.ExportInstanceRequest, Sequence[Tuple[str, str]]]: + async def pre_export_instance(self, request: cloud_redis_pb2.ExportInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.ExportInstanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for export_instance Override in a subclass to manipulate the request or metadata @@ -222,7 +222,7 @@ async def post_export_instance(self, response: operations_pb2.Operation) -> oper """ return response - async def pre_failover_instance(self, request: cloud_redis.FailoverInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.FailoverInstanceRequest, Sequence[Tuple[str, str]]]: + async def pre_failover_instance(self, request: cloud_redis_pb2.FailoverInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.FailoverInstanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for failover_instance Override in a subclass to manipulate the request or metadata @@ -239,7 +239,7 @@ async def post_failover_instance(self, response: operations_pb2.Operation) -> op """ return response - async def pre_get_instance(self, request: cloud_redis.GetInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.GetInstanceRequest, Sequence[Tuple[str, str]]]: + async def pre_get_instance(self, request: cloud_redis_pb2.GetInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.GetInstanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata @@ -247,7 +247,7 @@ async def pre_get_instance(self, request: cloud_redis.GetInstanceRequest, metada """ return request, metadata - async def post_get_instance(self, response: cloud_redis.Instance) -> cloud_redis.Instance: + async def post_get_instance(self, response: cloud_redis_pb2.Instance) -> cloud_redis_pb2.Instance: """Post-rpc interceptor for get_instance Override in a subclass to manipulate the response @@ -256,7 +256,7 @@ async def post_get_instance(self, response: cloud_redis.Instance) -> cloud_redis """ return response - async def pre_get_instance_auth_string(self, request: cloud_redis.GetInstanceAuthStringRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.GetInstanceAuthStringRequest, Sequence[Tuple[str, str]]]: + async def pre_get_instance_auth_string(self, request: cloud_redis_pb2.GetInstanceAuthStringRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.GetInstanceAuthStringRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for get_instance_auth_string Override in a subclass to manipulate the request or metadata @@ -264,7 +264,7 @@ async def pre_get_instance_auth_string(self, request: cloud_redis.GetInstanceAut """ return request, metadata - async def post_get_instance_auth_string(self, response: cloud_redis.InstanceAuthString) -> cloud_redis.InstanceAuthString: + async def post_get_instance_auth_string(self, response: cloud_redis_pb2.InstanceAuthString) -> cloud_redis_pb2.InstanceAuthString: """Post-rpc interceptor for get_instance_auth_string Override in a subclass to manipulate the response @@ -273,7 +273,7 @@ async def post_get_instance_auth_string(self, response: cloud_redis.InstanceAuth """ return response - async def pre_import_instance(self, request: cloud_redis.ImportInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.ImportInstanceRequest, Sequence[Tuple[str, str]]]: + async def pre_import_instance(self, request: cloud_redis_pb2.ImportInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.ImportInstanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for import_instance Override in a subclass to manipulate the request or metadata @@ -290,7 +290,7 @@ async def post_import_instance(self, response: operations_pb2.Operation) -> oper """ return response - async def pre_list_instances(self, request: cloud_redis.ListInstancesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.ListInstancesRequest, Sequence[Tuple[str, str]]]: + async def pre_list_instances(self, request: cloud_redis_pb2.ListInstancesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.ListInstancesRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for list_instances Override in a subclass to manipulate the request or metadata @@ -298,7 +298,7 @@ async def pre_list_instances(self, request: cloud_redis.ListInstancesRequest, me """ return request, metadata - async def post_list_instances(self, response: cloud_redis.ListInstancesResponse) -> cloud_redis.ListInstancesResponse: + async def post_list_instances(self, response: cloud_redis_pb2.ListInstancesResponse) -> cloud_redis_pb2.ListInstancesResponse: """Post-rpc interceptor for list_instances Override in a subclass to manipulate the response @@ -307,7 +307,7 @@ async def post_list_instances(self, response: cloud_redis.ListInstancesResponse) """ return response - async def pre_reschedule_maintenance(self, request: cloud_redis.RescheduleMaintenanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.RescheduleMaintenanceRequest, Sequence[Tuple[str, str]]]: + async def pre_reschedule_maintenance(self, request: cloud_redis_pb2.RescheduleMaintenanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.RescheduleMaintenanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for reschedule_maintenance Override in a subclass to manipulate the request or metadata @@ -324,7 +324,7 @@ async def post_reschedule_maintenance(self, response: operations_pb2.Operation) """ return response - async def pre_update_instance(self, request: cloud_redis.UpdateInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.UpdateInstanceRequest, Sequence[Tuple[str, str]]]: + async def pre_update_instance(self, request: cloud_redis_pb2.UpdateInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.UpdateInstanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for update_instance Override in a subclass to manipulate the request or metadata @@ -341,7 +341,7 @@ async def post_update_instance(self, response: operations_pb2.Operation) -> oper """ return response - async def pre_upgrade_instance(self, request: cloud_redis.UpgradeInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis.UpgradeInstanceRequest, Sequence[Tuple[str, str]]]: + async def pre_upgrade_instance(self, request: cloud_redis_pb2.UpgradeInstanceRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[cloud_redis_pb2.UpgradeInstanceRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for upgrade_instance Override in a subclass to manipulate the request or metadata @@ -717,7 +717,7 @@ async def _get_response( return response async def __call__(self, - request: cloud_redis.CreateInstanceRequest, *, + request: cloud_redis_pb2.CreateInstanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), @@ -725,7 +725,7 @@ async def __call__(self, r"""Call the create instance method over HTTP. Args: - request (~.cloud_redis.CreateInstanceRequest): + request (~.cloud_redis_pb2.CreateInstanceRequest): The request object. Request for [CreateInstance][google.cloud.redis.v1.CloudRedis.CreateInstance]. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -798,7 +798,7 @@ async def _get_response( return response async def __call__(self, - request: cloud_redis.DeleteInstanceRequest, *, + request: cloud_redis_pb2.DeleteInstanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), @@ -806,7 +806,7 @@ async def __call__(self, r"""Call the delete instance method over HTTP. Args: - request (~.cloud_redis.DeleteInstanceRequest): + request (~.cloud_redis_pb2.DeleteInstanceRequest): The request object. Request for [DeleteInstance][google.cloud.redis.v1.CloudRedis.DeleteInstance]. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -878,7 +878,7 @@ async def _get_response( return response async def __call__(self, - request: cloud_redis.ExportInstanceRequest, *, + request: cloud_redis_pb2.ExportInstanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), @@ -886,7 +886,7 @@ async def __call__(self, r"""Call the export instance method over HTTP. Args: - request (~.cloud_redis.ExportInstanceRequest): + request (~.cloud_redis_pb2.ExportInstanceRequest): The request object. Request for [Export][google.cloud.redis.v1.CloudRedis.ExportInstance]. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -960,7 +960,7 @@ async def _get_response( return response async def __call__(self, - request: cloud_redis.FailoverInstanceRequest, *, + request: cloud_redis_pb2.FailoverInstanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), @@ -968,7 +968,7 @@ async def __call__(self, r"""Call the failover instance method over HTTP. Args: - request (~.cloud_redis.FailoverInstanceRequest): + request (~.cloud_redis_pb2.FailoverInstanceRequest): The request object. Request for [Failover][google.cloud.redis.v1.CloudRedis.FailoverInstance]. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -1041,15 +1041,15 @@ async def _get_response( return response async def __call__(self, - request: cloud_redis.GetInstanceRequest, *, + request: cloud_redis_pb2.GetInstanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), - ) -> cloud_redis.Instance: + ) -> cloud_redis_pb2.Instance: r"""Call the get instance method over HTTP. Args: - request (~.cloud_redis.GetInstanceRequest): + request (~.cloud_redis_pb2.GetInstanceRequest): The request object. Request for [GetInstance][google.cloud.redis.v1.CloudRedis.GetInstance]. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -1059,7 +1059,7 @@ async def __call__(self, sent along with the request as metadata. Returns: - ~.cloud_redis.Instance: + ~.cloud_redis_pb2.Instance: A Memorystore for Redis instance. """ @@ -1083,8 +1083,8 @@ async def __call__(self, raise core_exceptions.format_http_response_error(response, method, request_url, payload) # type: ignore # Return the response - resp = cloud_redis.Instance() - pb_resp = cloud_redis.Instance.pb(resp) + resp = cloud_redis_pb2.Instance() + pb_resp = resp content = await response.read() json_format.Parse(content, pb_resp, ignore_unknown_fields=True) resp = await self._interceptor.post_get_instance(resp) @@ -1117,15 +1117,15 @@ async def _get_response( return response async def __call__(self, - request: cloud_redis.GetInstanceAuthStringRequest, *, + request: cloud_redis_pb2.GetInstanceAuthStringRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), - ) -> cloud_redis.InstanceAuthString: + ) -> cloud_redis_pb2.InstanceAuthString: r"""Call the get instance auth string method over HTTP. Args: - request (~.cloud_redis.GetInstanceAuthStringRequest): + request (~.cloud_redis_pb2.GetInstanceAuthStringRequest): The request object. Request for [GetInstanceAuthString][google.cloud.redis.v1.CloudRedis.GetInstanceAuthString]. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -1135,7 +1135,7 @@ async def __call__(self, sent along with the request as metadata. Returns: - ~.cloud_redis.InstanceAuthString: + ~.cloud_redis_pb2.InstanceAuthString: Instance AUTH string details. """ @@ -1159,8 +1159,8 @@ async def __call__(self, raise core_exceptions.format_http_response_error(response, method, request_url, payload) # type: ignore # Return the response - resp = cloud_redis.InstanceAuthString() - pb_resp = cloud_redis.InstanceAuthString.pb(resp) + resp = cloud_redis_pb2.InstanceAuthString() + pb_resp = resp content = await response.read() json_format.Parse(content, pb_resp, ignore_unknown_fields=True) resp = await self._interceptor.post_get_instance_auth_string(resp) @@ -1194,7 +1194,7 @@ async def _get_response( return response async def __call__(self, - request: cloud_redis.ImportInstanceRequest, *, + request: cloud_redis_pb2.ImportInstanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), @@ -1202,7 +1202,7 @@ async def __call__(self, r"""Call the import instance method over HTTP. Args: - request (~.cloud_redis.ImportInstanceRequest): + request (~.cloud_redis_pb2.ImportInstanceRequest): The request object. Request for [Import][google.cloud.redis.v1.CloudRedis.ImportInstance]. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -1275,15 +1275,15 @@ async def _get_response( return response async def __call__(self, - request: cloud_redis.ListInstancesRequest, *, + request: cloud_redis_pb2.ListInstancesRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), - ) -> cloud_redis.ListInstancesResponse: + ) -> cloud_redis_pb2.ListInstancesResponse: r"""Call the list instances method over HTTP. Args: - request (~.cloud_redis.ListInstancesRequest): + request (~.cloud_redis_pb2.ListInstancesRequest): The request object. Request for [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances]. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -1293,7 +1293,7 @@ async def __call__(self, sent along with the request as metadata. Returns: - ~.cloud_redis.ListInstancesResponse: + ~.cloud_redis_pb2.ListInstancesResponse: Response for [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances]. @@ -1319,8 +1319,8 @@ async def __call__(self, raise core_exceptions.format_http_response_error(response, method, request_url, payload) # type: ignore # Return the response - resp = cloud_redis.ListInstancesResponse() - pb_resp = cloud_redis.ListInstancesResponse.pb(resp) + resp = cloud_redis_pb2.ListInstancesResponse() + pb_resp = resp content = await response.read() json_format.Parse(content, pb_resp, ignore_unknown_fields=True) resp = await self._interceptor.post_list_instances(resp) @@ -1354,7 +1354,7 @@ async def _get_response( return response async def __call__(self, - request: cloud_redis.RescheduleMaintenanceRequest, *, + request: cloud_redis_pb2.RescheduleMaintenanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), @@ -1362,7 +1362,7 @@ async def __call__(self, r"""Call the reschedule maintenance method over HTTP. Args: - request (~.cloud_redis.RescheduleMaintenanceRequest): + request (~.cloud_redis_pb2.RescheduleMaintenanceRequest): The request object. Request for [RescheduleMaintenance][google.cloud.redis.v1.CloudRedis.RescheduleMaintenance]. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -1436,7 +1436,7 @@ async def _get_response( return response async def __call__(self, - request: cloud_redis.UpdateInstanceRequest, *, + request: cloud_redis_pb2.UpdateInstanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), @@ -1444,7 +1444,7 @@ async def __call__(self, r"""Call the update instance method over HTTP. Args: - request (~.cloud_redis.UpdateInstanceRequest): + request (~.cloud_redis_pb2.UpdateInstanceRequest): The request object. Request for [UpdateInstance][google.cloud.redis.v1.CloudRedis.UpdateInstance]. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -1518,7 +1518,7 @@ async def _get_response( return response async def __call__(self, - request: cloud_redis.UpgradeInstanceRequest, *, + request: cloud_redis_pb2.UpgradeInstanceRequest, *, retry: OptionalRetry=gapic_v1.method.DEFAULT, timeout: Optional[float]=None, metadata: Sequence[Tuple[str, str]]=(), @@ -1526,7 +1526,7 @@ async def __call__(self, r"""Call the upgrade instance method over HTTP. Args: - request (~.cloud_redis.UpgradeInstanceRequest): + request (~.cloud_redis_pb2.UpgradeInstanceRequest): The request object. Request for [UpgradeInstance][google.cloud.redis.v1.CloudRedis.UpgradeInstance]. retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, @@ -1630,67 +1630,67 @@ def operations_client(self) -> AsyncOperationsRestClient: @property def create_instance(self) -> Callable[ - [cloud_redis.CreateInstanceRequest], + [cloud_redis_pb2.CreateInstanceRequest], operations_pb2.Operation]: return self._CreateInstance(self._session, self._host, self._interceptor) # type: ignore @property def delete_instance(self) -> Callable[ - [cloud_redis.DeleteInstanceRequest], + [cloud_redis_pb2.DeleteInstanceRequest], operations_pb2.Operation]: return self._DeleteInstance(self._session, self._host, self._interceptor) # type: ignore @property def export_instance(self) -> Callable[ - [cloud_redis.ExportInstanceRequest], + [cloud_redis_pb2.ExportInstanceRequest], operations_pb2.Operation]: return self._ExportInstance(self._session, self._host, self._interceptor) # type: ignore @property def failover_instance(self) -> Callable[ - [cloud_redis.FailoverInstanceRequest], + [cloud_redis_pb2.FailoverInstanceRequest], operations_pb2.Operation]: return self._FailoverInstance(self._session, self._host, self._interceptor) # type: ignore @property def get_instance(self) -> Callable[ - [cloud_redis.GetInstanceRequest], - cloud_redis.Instance]: + [cloud_redis_pb2.GetInstanceRequest], + cloud_redis_pb2.Instance]: return self._GetInstance(self._session, self._host, self._interceptor) # type: ignore @property def get_instance_auth_string(self) -> Callable[ - [cloud_redis.GetInstanceAuthStringRequest], - cloud_redis.InstanceAuthString]: + [cloud_redis_pb2.GetInstanceAuthStringRequest], + cloud_redis_pb2.InstanceAuthString]: return self._GetInstanceAuthString(self._session, self._host, self._interceptor) # type: ignore @property def import_instance(self) -> Callable[ - [cloud_redis.ImportInstanceRequest], + [cloud_redis_pb2.ImportInstanceRequest], operations_pb2.Operation]: return self._ImportInstance(self._session, self._host, self._interceptor) # type: ignore @property def list_instances(self) -> Callable[ - [cloud_redis.ListInstancesRequest], - cloud_redis.ListInstancesResponse]: + [cloud_redis_pb2.ListInstancesRequest], + cloud_redis_pb2.ListInstancesResponse]: return self._ListInstances(self._session, self._host, self._interceptor) # type: ignore @property def reschedule_maintenance(self) -> Callable[ - [cloud_redis.RescheduleMaintenanceRequest], + [cloud_redis_pb2.RescheduleMaintenanceRequest], operations_pb2.Operation]: return self._RescheduleMaintenance(self._session, self._host, self._interceptor) # type: ignore @property def update_instance(self) -> Callable[ - [cloud_redis.UpdateInstanceRequest], + [cloud_redis_pb2.UpdateInstanceRequest], operations_pb2.Operation]: return self._UpdateInstance(self._session, self._host, self._interceptor) # type: ignore @property def upgrade_instance(self) -> Callable[ - [cloud_redis.UpgradeInstanceRequest], + [cloud_redis_pb2.UpgradeInstanceRequest], operations_pb2.Operation]: return self._UpgradeInstance(self._session, self._host, self._interceptor) # type: ignore diff --git a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest_base.py b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest_base.py index e63a3d8503..3644202ef5 100755 --- a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest_base.py +++ b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest_base.py @@ -25,7 +25,7 @@ from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union -from google.cloud.redis_v1.types import cloud_redis +from google.cloud.redis_v1.types import cloud_redis_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore @@ -110,7 +110,7 @@ def _get_http_options(): @staticmethod def _get_transcoded_request(http_options, request): - pb_request = cloud_redis.CreateInstanceRequest.pb(request) + pb_request = request transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -155,7 +155,7 @@ def _get_http_options(): @staticmethod def _get_transcoded_request(http_options, request): - pb_request = cloud_redis.DeleteInstanceRequest.pb(request) + pb_request = request transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -192,7 +192,7 @@ def _get_http_options(): @staticmethod def _get_transcoded_request(http_options, request): - pb_request = cloud_redis.ExportInstanceRequest.pb(request) + pb_request = request transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -238,7 +238,7 @@ def _get_http_options(): @staticmethod def _get_transcoded_request(http_options, request): - pb_request = cloud_redis.FailoverInstanceRequest.pb(request) + pb_request = request transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -283,7 +283,7 @@ def _get_http_options(): @staticmethod def _get_transcoded_request(http_options, request): - pb_request = cloud_redis.GetInstanceRequest.pb(request) + pb_request = request transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -319,7 +319,7 @@ def _get_http_options(): @staticmethod def _get_transcoded_request(http_options, request): - pb_request = cloud_redis.GetInstanceAuthStringRequest.pb(request) + pb_request = request transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -356,7 +356,7 @@ def _get_http_options(): @staticmethod def _get_transcoded_request(http_options, request): - pb_request = cloud_redis.ImportInstanceRequest.pb(request) + pb_request = request transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -401,7 +401,7 @@ def _get_http_options(): @staticmethod def _get_transcoded_request(http_options, request): - pb_request = cloud_redis.ListInstancesRequest.pb(request) + pb_request = request transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -438,7 +438,7 @@ def _get_http_options(): @staticmethod def _get_transcoded_request(http_options, request): - pb_request = cloud_redis.RescheduleMaintenanceRequest.pb(request) + pb_request = request transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -484,7 +484,7 @@ def _get_http_options(): @staticmethod def _get_transcoded_request(http_options, request): - pb_request = cloud_redis.UpdateInstanceRequest.pb(request) + pb_request = request transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request @@ -530,7 +530,7 @@ def _get_http_options(): @staticmethod def _get_transcoded_request(http_options, request): - pb_request = cloud_redis.UpgradeInstanceRequest.pb(request) + pb_request = request transcoded_request = path_template.transcode(http_options, pb_request) return transcoded_request diff --git a/tests/integration/goldens/redis/google/cloud/redis_v1/types/__init__.py b/tests/integration/goldens/redis/google/cloud/redis_v1/types/__init__.py index 6afcaca198..8f6cf06824 100755 --- a/tests/integration/goldens/redis/google/cloud/redis_v1/types/__init__.py +++ b/tests/integration/goldens/redis/google/cloud/redis_v1/types/__init__.py @@ -13,62 +13,3 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .cloud_redis import ( - CreateInstanceRequest, - DeleteInstanceRequest, - ExportInstanceRequest, - FailoverInstanceRequest, - GcsDestination, - GcsSource, - GetInstanceAuthStringRequest, - GetInstanceRequest, - ImportInstanceRequest, - InputConfig, - Instance, - InstanceAuthString, - ListInstancesRequest, - ListInstancesResponse, - LocationMetadata, - MaintenancePolicy, - MaintenanceSchedule, - NodeInfo, - OperationMetadata, - OutputConfig, - PersistenceConfig, - RescheduleMaintenanceRequest, - TlsCertificate, - UpdateInstanceRequest, - UpgradeInstanceRequest, - WeeklyMaintenanceWindow, - ZoneMetadata, -) - -__all__ = ( - 'CreateInstanceRequest', - 'DeleteInstanceRequest', - 'ExportInstanceRequest', - 'FailoverInstanceRequest', - 'GcsDestination', - 'GcsSource', - 'GetInstanceAuthStringRequest', - 'GetInstanceRequest', - 'ImportInstanceRequest', - 'InputConfig', - 'Instance', - 'InstanceAuthString', - 'ListInstancesRequest', - 'ListInstancesResponse', - 'LocationMetadata', - 'MaintenancePolicy', - 'MaintenanceSchedule', - 'NodeInfo', - 'OperationMetadata', - 'OutputConfig', - 'PersistenceConfig', - 'RescheduleMaintenanceRequest', - 'TlsCertificate', - 'UpdateInstanceRequest', - 'UpgradeInstanceRequest', - 'WeeklyMaintenanceWindow', - 'ZoneMetadata', -) diff --git a/tests/integration/goldens/redis/google/cloud/redis_v1/types/cloud_redis.py b/tests/integration/goldens/redis/google/cloud/redis_v1/types/cloud_redis.py deleted file mode 100755 index 50ca82ff02..0000000000 --- a/tests/integration/goldens/redis/google/cloud/redis_v1/types/cloud_redis.py +++ /dev/null @@ -1,1343 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2024 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from __future__ import annotations - -from typing import MutableMapping, MutableSequence - -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( - package='google.cloud.redis.v1', - manifest={ - 'NodeInfo', - 'Instance', - 'PersistenceConfig', - 'RescheduleMaintenanceRequest', - 'MaintenancePolicy', - 'WeeklyMaintenanceWindow', - 'MaintenanceSchedule', - 'ListInstancesRequest', - 'ListInstancesResponse', - 'GetInstanceRequest', - 'GetInstanceAuthStringRequest', - 'InstanceAuthString', - 'CreateInstanceRequest', - 'UpdateInstanceRequest', - 'UpgradeInstanceRequest', - 'DeleteInstanceRequest', - 'GcsSource', - 'InputConfig', - 'ImportInstanceRequest', - 'GcsDestination', - 'OutputConfig', - 'ExportInstanceRequest', - 'FailoverInstanceRequest', - 'OperationMetadata', - 'LocationMetadata', - 'ZoneMetadata', - 'TlsCertificate', - }, -) - - -class NodeInfo(proto.Message): - r"""Node specific properties. - - Attributes: - id (str): - Output only. Node identifying string. e.g. - 'node-0', 'node-1' - zone (str): - Output only. Location of the node. - """ - - id: str = proto.Field( - proto.STRING, - number=1, - ) - zone: str = proto.Field( - proto.STRING, - number=2, - ) - - -class Instance(proto.Message): - r"""A Memorystore for Redis instance. - - Attributes: - name (str): - Required. Unique name of the resource in this scope - including project and location using the form: - ``projects/{project_id}/locations/{location_id}/instances/{instance_id}`` - - Note: Redis instances are managed and addressed at regional - level so location_id here refers to a GCP region; however, - users may choose which specific zone (or collection of zones - for cross-zone instances) an instance should be provisioned - in. Refer to - [location_id][google.cloud.redis.v1.Instance.location_id] - and - [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] - fields for more details. - display_name (str): - An arbitrary and optional user-provided name - for the instance. - labels (MutableMapping[str, str]): - Resource labels to represent user provided - metadata - location_id (str): - Optional. The zone where the instance will be - provisioned. If not provided, the service will - choose a zone from the specified region for the - instance. For standard tier, additional nodes - will be added across multiple zones for - protection against zonal failures. If specified, - at least one node will be provisioned in this - zone. - alternative_location_id (str): - Optional. If specified, at least one node will be - provisioned in this zone in addition to the zone specified - in location_id. Only applicable to standard tier. If - provided, it must be a different zone from the one provided - in [location_id]. Additional nodes beyond the first 2 will - be placed in zones selected by the service. - redis_version (str): - Optional. The version of Redis software. If not provided, - latest supported version will be used. Currently, the - supported values are: - - - ``REDIS_3_2`` for Redis 3.2 compatibility - - ``REDIS_4_0`` for Redis 4.0 compatibility (default) - - ``REDIS_5_0`` for Redis 5.0 compatibility - - ``REDIS_6_X`` for Redis 6.x compatibility - reserved_ip_range (str): - Optional. For DIRECT_PEERING mode, the CIDR range of - internal addresses that are reserved for this instance. - Range must be unique and non-overlapping with existing - subnets in an authorized network. For PRIVATE_SERVICE_ACCESS - mode, the name of one allocated IP address ranges associated - with this private service access connection. If not - provided, the service will choose an unused /29 block, for - example, 10.0.0.0/29 or 192.168.0.0/29. For - READ_REPLICAS_ENABLED the default block size is /28. - secondary_ip_range (str): - Optional. Additional IP range for node placement. Required - when enabling read replicas on an existing instance. For - DIRECT_PEERING mode value must be a CIDR range of size /28, - or "auto". For PRIVATE_SERVICE_ACCESS mode value must be the - name of an allocated address range associated with the - private service access connection, or "auto". - host (str): - Output only. Hostname or IP address of the - exposed Redis endpoint used by clients to - connect to the service. - port (int): - Output only. The port number of the exposed - Redis endpoint. - current_location_id (str): - Output only. The current zone where the Redis primary node - is located. In basic tier, this will always be the same as - [location_id]. In standard tier, this can be the zone of any - node in the instance. - create_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the instance was - created. - state (google.cloud.redis_v1.types.Instance.State): - Output only. The current state of this - instance. - status_message (str): - Output only. Additional information about the - current status of this instance, if available. - redis_configs (MutableMapping[str, str]): - Optional. Redis configuration parameters, according to - http://redis.io/topics/config. Currently, the only supported - parameters are: - - Redis version 3.2 and newer: - - - maxmemory-policy - - notify-keyspace-events - - Redis version 4.0 and newer: - - - activedefrag - - lfu-decay-time - - lfu-log-factor - - maxmemory-gb - - Redis version 5.0 and newer: - - - stream-node-max-bytes - - stream-node-max-entries - tier (google.cloud.redis_v1.types.Instance.Tier): - Required. The service tier of the instance. - memory_size_gb (int): - Required. Redis memory size in GiB. - authorized_network (str): - Optional. The full name of the Google Compute Engine - `network `__ to which - the instance is connected. If left unspecified, the - ``default`` network will be used. - persistence_iam_identity (str): - Output only. Cloud IAM identity used by import / export - operations to transfer data to/from Cloud Storage. Format is - "serviceAccount:". The value may - change over time for a given instance so should be checked - before each import/export operation. - connect_mode (google.cloud.redis_v1.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 (MutableSequence[google.cloud.redis_v1.types.TlsCertificate]): - Output only. List of server CA certificates - for the instance. - transit_encryption_mode (google.cloud.redis_v1.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_v1.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_v1.types.MaintenanceSchedule): - Output only. Date and time of upcoming - maintenance events which have been scheduled. - replica_count (int): - 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 (MutableSequence[google.cloud.redis_v1.types.NodeInfo]): - Output only. Info per node. - read_endpoint (str): - Output only. Hostname or IP address of the - exposed readonly Redis endpoint. Standard tier - only. Targets all healthy replica nodes in - instance. Replication is asynchronous and - replica nodes will exhibit some lag behind the - primary. Write requests must target 'host'. - read_endpoint_port (int): - Output only. The port number of the exposed - readonly redis endpoint. Standard tier only. - Write requests should target 'port'. - read_replicas_mode (google.cloud.redis_v1.types.Instance.ReadReplicasMode): - Optional. Read replicas mode for the instance. Defaults to - READ_REPLICAS_DISABLED. - customer_managed_key (str): - Optional. The KMS key reference that the - customer provides when trying to create the - instance. - persistence_config (google.cloud.redis_v1.types.PersistenceConfig): - Optional. Persistence configuration - parameters - suspension_reasons (MutableSequence[google.cloud.redis_v1.types.Instance.SuspensionReason]): - Optional. reasons that causes instance in - "SUSPENDED" state. - maintenance_version (str): - Optional. The self service update maintenance version. The - version is date based such as "20210712_00_00". - available_maintenance_versions (MutableSequence[str]): - Optional. The available maintenance versions - that an instance could update to. - """ - class State(proto.Enum): - r"""Represents the different states of a Redis instance. - - Values: - STATE_UNSPECIFIED (0): - Not set. - CREATING (1): - Redis instance is being created. - READY (2): - Redis instance has been created and is fully - usable. - UPDATING (3): - Redis instance configuration is being - updated. Certain kinds of updates may cause the - instance to become unusable while the update is - in progress. - DELETING (4): - Redis instance is being deleted. - REPAIRING (5): - Redis instance is being repaired and may be - unusable. - MAINTENANCE (6): - Maintenance is being performed on this Redis - instance. - IMPORTING (8): - Redis instance is importing data - (availability may be affected). - FAILING_OVER (9): - Redis instance is failing over (availability - may be affected). - """ - STATE_UNSPECIFIED = 0 - CREATING = 1 - READY = 2 - UPDATING = 3 - DELETING = 4 - REPAIRING = 5 - MAINTENANCE = 6 - IMPORTING = 8 - FAILING_OVER = 9 - - class Tier(proto.Enum): - r"""Available service tiers to choose from - - Values: - TIER_UNSPECIFIED (0): - Not set. - BASIC (1): - BASIC tier: standalone instance - STANDARD_HA (3): - STANDARD_HA tier: highly available primary/replica instances - """ - TIER_UNSPECIFIED = 0 - BASIC = 1 - STANDARD_HA = 3 - - class ConnectMode(proto.Enum): - r"""Available connection modes. - - Values: - CONNECT_MODE_UNSPECIFIED (0): - Not set. - DIRECT_PEERING (1): - Connect via direct peering to the Memorystore - for Redis hosted service. - PRIVATE_SERVICE_ACCESS (2): - Connect your Memorystore for Redis instance - using Private Service Access. Private services - access provides an IP address range for multiple - Google Cloud services, including Memorystore. - """ - CONNECT_MODE_UNSPECIFIED = 0 - DIRECT_PEERING = 1 - PRIVATE_SERVICE_ACCESS = 2 - - class TransitEncryptionMode(proto.Enum): - r"""Available TLS modes. - - Values: - TRANSIT_ENCRYPTION_MODE_UNSPECIFIED (0): - Not set. - SERVER_AUTHENTICATION (1): - Client to Server traffic encryption enabled - with server authentication. - DISABLED (2): - TLS is disabled for the instance. - """ - TRANSIT_ENCRYPTION_MODE_UNSPECIFIED = 0 - SERVER_AUTHENTICATION = 1 - DISABLED = 2 - - class ReadReplicasMode(proto.Enum): - r"""Read replicas mode. - - Values: - READ_REPLICAS_MODE_UNSPECIFIED (0): - If not set, Memorystore Redis backend will default to - READ_REPLICAS_DISABLED. - READ_REPLICAS_DISABLED (1): - If disabled, read endpoint will not be - provided and the instance cannot scale up or - down the number of replicas. - READ_REPLICAS_ENABLED (2): - If enabled, read endpoint will be provided - and the instance can scale up and down the - number of replicas. Not valid for basic tier. - """ - READ_REPLICAS_MODE_UNSPECIFIED = 0 - READ_REPLICAS_DISABLED = 1 - READ_REPLICAS_ENABLED = 2 - - class SuspensionReason(proto.Enum): - r"""Possible reasons for the instance to be in a "SUSPENDED" - state. - - Values: - SUSPENSION_REASON_UNSPECIFIED (0): - Not set. - CUSTOMER_MANAGED_KEY_ISSUE (1): - Something wrong with the CMEK key provided by - customer. - """ - SUSPENSION_REASON_UNSPECIFIED = 0 - CUSTOMER_MANAGED_KEY_ISSUE = 1 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - display_name: str = proto.Field( - proto.STRING, - number=2, - ) - labels: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=3, - ) - location_id: str = proto.Field( - proto.STRING, - number=4, - ) - alternative_location_id: str = proto.Field( - proto.STRING, - number=5, - ) - redis_version: str = proto.Field( - proto.STRING, - number=7, - ) - reserved_ip_range: str = proto.Field( - proto.STRING, - number=9, - ) - secondary_ip_range: str = proto.Field( - proto.STRING, - number=30, - ) - host: str = proto.Field( - proto.STRING, - number=10, - ) - port: int = proto.Field( - proto.INT32, - number=11, - ) - current_location_id: str = proto.Field( - proto.STRING, - number=12, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=13, - message=timestamp_pb2.Timestamp, - ) - state: State = proto.Field( - proto.ENUM, - number=14, - enum=State, - ) - status_message: str = proto.Field( - proto.STRING, - number=15, - ) - redis_configs: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=16, - ) - tier: Tier = proto.Field( - proto.ENUM, - number=17, - enum=Tier, - ) - memory_size_gb: int = proto.Field( - proto.INT32, - number=18, - ) - authorized_network: str = proto.Field( - proto.STRING, - number=20, - ) - persistence_iam_identity: str = proto.Field( - proto.STRING, - number=21, - ) - connect_mode: ConnectMode = proto.Field( - proto.ENUM, - number=22, - enum=ConnectMode, - ) - auth_enabled: bool = proto.Field( - proto.BOOL, - number=23, - ) - server_ca_certs: MutableSequence['TlsCertificate'] = proto.RepeatedField( - proto.MESSAGE, - number=25, - message='TlsCertificate', - ) - transit_encryption_mode: TransitEncryptionMode = proto.Field( - proto.ENUM, - number=26, - enum=TransitEncryptionMode, - ) - maintenance_policy: 'MaintenancePolicy' = proto.Field( - proto.MESSAGE, - number=27, - message='MaintenancePolicy', - ) - maintenance_schedule: 'MaintenanceSchedule' = proto.Field( - proto.MESSAGE, - number=28, - message='MaintenanceSchedule', - ) - replica_count: int = proto.Field( - proto.INT32, - number=31, - ) - nodes: MutableSequence['NodeInfo'] = proto.RepeatedField( - proto.MESSAGE, - number=32, - message='NodeInfo', - ) - read_endpoint: str = proto.Field( - proto.STRING, - number=33, - ) - read_endpoint_port: int = proto.Field( - proto.INT32, - number=34, - ) - read_replicas_mode: ReadReplicasMode = proto.Field( - proto.ENUM, - number=35, - enum=ReadReplicasMode, - ) - customer_managed_key: str = proto.Field( - proto.STRING, - number=36, - ) - persistence_config: 'PersistenceConfig' = proto.Field( - proto.MESSAGE, - number=37, - message='PersistenceConfig', - ) - suspension_reasons: MutableSequence[SuspensionReason] = proto.RepeatedField( - proto.ENUM, - number=38, - enum=SuspensionReason, - ) - maintenance_version: str = proto.Field( - proto.STRING, - number=39, - ) - available_maintenance_versions: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=40, - ) - - -class PersistenceConfig(proto.Message): - r"""Configuration of the persistence functionality. - - Attributes: - persistence_mode (google.cloud.redis_v1.types.PersistenceConfig.PersistenceMode): - Optional. Controls whether Persistence - features are enabled. If not provided, the - existing value will be used. - rdb_snapshot_period (google.cloud.redis_v1.types.PersistenceConfig.SnapshotPeriod): - Optional. Period between RDB snapshots. Snapshots will be - attempted every period starting from the provided snapshot - start time. For example, a start time of 01/01/2033 06:45 - and SIX_HOURS snapshot period will do nothing until - 01/01/2033, and then trigger snapshots every day at 06:45, - 12:45, 18:45, and 00:45 the next day, and so on. If not - provided, TWENTY_FOUR_HOURS will be used as default. - rdb_next_snapshot_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The next time that a snapshot - attempt is scheduled to occur. - rdb_snapshot_start_time (google.protobuf.timestamp_pb2.Timestamp): - Optional. Date and time that the first - snapshot was/will be attempted, and to which - future snapshots will be aligned. If not - provided, the current time will be used. - """ - class PersistenceMode(proto.Enum): - r"""Available Persistence modes. - - Values: - PERSISTENCE_MODE_UNSPECIFIED (0): - Not set. - DISABLED (1): - Persistence is disabled for the instance, - and any existing snapshots are deleted. - RDB (2): - RDB based Persistence is enabled. - """ - PERSISTENCE_MODE_UNSPECIFIED = 0 - DISABLED = 1 - RDB = 2 - - class SnapshotPeriod(proto.Enum): - r"""Available snapshot periods for scheduling. - - Values: - SNAPSHOT_PERIOD_UNSPECIFIED (0): - Not set. - ONE_HOUR (3): - Snapshot every 1 hour. - SIX_HOURS (4): - Snapshot every 6 hours. - TWELVE_HOURS (5): - Snapshot every 12 hours. - TWENTY_FOUR_HOURS (6): - Snapshot every 24 hours. - """ - SNAPSHOT_PERIOD_UNSPECIFIED = 0 - ONE_HOUR = 3 - SIX_HOURS = 4 - TWELVE_HOURS = 5 - TWENTY_FOUR_HOURS = 6 - - persistence_mode: PersistenceMode = proto.Field( - proto.ENUM, - number=1, - enum=PersistenceMode, - ) - rdb_snapshot_period: SnapshotPeriod = proto.Field( - proto.ENUM, - number=2, - enum=SnapshotPeriod, - ) - rdb_next_snapshot_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - rdb_snapshot_start_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - - -class RescheduleMaintenanceRequest(proto.Message): - r"""Request for - [RescheduleMaintenance][google.cloud.redis.v1.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_v1.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. - - Values: - RESCHEDULE_TYPE_UNSPECIFIED (0): - Not set. - IMMEDIATE (1): - If the user wants to schedule the maintenance - to happen now. - NEXT_AVAILABLE_WINDOW (2): - If the user wants to use the existing - maintenance policy to find the next available - window. - SPECIFIC_TIME (3): - If the user wants to reschedule the - maintenance to a specific time. - """ - RESCHEDULE_TYPE_UNSPECIFIED = 0 - IMMEDIATE = 1 - NEXT_AVAILABLE_WINDOW = 2 - SPECIFIC_TIME = 3 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - reschedule_type: RescheduleType = proto.Field( - proto.ENUM, - number=2, - enum=RescheduleType, - ) - schedule_time: timestamp_pb2.Timestamp = 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 (MutableSequence[google.cloud.redis_v1.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: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - description: str = proto.Field( - proto.STRING, - number=3, - ) - weekly_maintenance_window: MutableSequence['WeeklyMaintenanceWindow'] = 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: dayofweek_pb2.DayOfWeek = proto.Field( - proto.ENUM, - number=1, - enum=dayofweek_pb2.DayOfWeek, - ) - start_time: timeofday_pb2.TimeOfDay = proto.Field( - proto.MESSAGE, - number=2, - message=timeofday_pb2.TimeOfDay, - ) - duration: duration_pb2.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: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - can_reschedule: bool = proto.Field( - proto.BOOL, - number=3, - ) - schedule_deadline_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=5, - message=timestamp_pb2.Timestamp, - ) - - -class ListInstancesRequest(proto.Message): - r"""Request for - [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances]. - - Attributes: - parent (str): - Required. The resource name of the instance location using - the form: ``projects/{project_id}/locations/{location_id}`` - where ``location_id`` refers to a GCP region. - page_size (int): - The maximum number of items to return. - - If not specified, a default value of 1000 will be used by - the service. Regardless of the page_size value, the response - may include a partial list and a caller should only rely on - response's - [``next_page_token``][google.cloud.redis.v1.ListInstancesResponse.next_page_token] - to determine if there are more instances left to be queried. - page_token (str): - The ``next_page_token`` value returned from a previous - [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances] - request, if any. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - - -class ListInstancesResponse(proto.Message): - r"""Response for - [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances]. - - Attributes: - instances (MutableSequence[google.cloud.redis_v1.types.Instance]): - A list of Redis instances in the project in the specified - location, or across all locations. - - If the ``location_id`` in the parent field of the request is - "-", all regions available to the project are queried, and - the results aggregated. If in such an aggregated query a - location is unavailable, a placeholder Redis entry is - included in the response with the ``name`` field set to a - value of the form - ``projects/{project_id}/locations/{location_id}/instances/``- - and the ``status`` field set to ERROR and ``status_message`` - field set to "location not available for ListInstances". - next_page_token (str): - Token to retrieve the next page of results, - or empty if there are no more results in the - list. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - instances: MutableSequence['Instance'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='Instance', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetInstanceRequest(proto.Message): - r"""Request for - [GetInstance][google.cloud.redis.v1.CloudRedis.GetInstance]. - - 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: str = proto.Field( - proto.STRING, - number=1, - ) - - -class GetInstanceAuthStringRequest(proto.Message): - r"""Request for - [GetInstanceAuthString][google.cloud.redis.v1.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: str = 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: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateInstanceRequest(proto.Message): - r"""Request for - [CreateInstance][google.cloud.redis.v1.CloudRedis.CreateInstance]. - - Attributes: - parent (str): - Required. The resource name of the instance location using - the form: ``projects/{project_id}/locations/{location_id}`` - where ``location_id`` refers to a GCP region. - instance_id (str): - Required. The logical name of the Redis instance in the - customer project with the following restrictions: - - - Must contain only lowercase letters, numbers, and - hyphens. - - Must start with a letter. - - Must be between 1-40 characters. - - Must end with a number or a letter. - - Must be unique within the customer project / location - instance (google.cloud.redis_v1.types.Instance): - Required. A Redis [Instance] resource - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - instance_id: str = proto.Field( - proto.STRING, - number=2, - ) - instance: 'Instance' = proto.Field( - proto.MESSAGE, - number=3, - message='Instance', - ) - - -class UpdateInstanceRequest(proto.Message): - r"""Request for - [UpdateInstance][google.cloud.redis.v1.CloudRedis.UpdateInstance]. - - Attributes: - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Mask of fields to update. At least one path must - be supplied in this field. The elements of the repeated - paths field may only include these fields from - [Instance][google.cloud.redis.v1.Instance]: - - - ``displayName`` - - ``labels`` - - ``memorySizeGb`` - - ``redisConfig`` - - ``replica_count`` - instance (google.cloud.redis_v1.types.Instance): - Required. Update description. Only fields specified in - update_mask are updated. - """ - - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=1, - message=field_mask_pb2.FieldMask, - ) - instance: 'Instance' = proto.Field( - proto.MESSAGE, - number=2, - message='Instance', - ) - - -class UpgradeInstanceRequest(proto.Message): - r"""Request for - [UpgradeInstance][google.cloud.redis.v1.CloudRedis.UpgradeInstance]. - - 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. - redis_version (str): - Required. Specifies the target version of - Redis software to upgrade to. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - redis_version: str = proto.Field( - proto.STRING, - number=2, - ) - - -class DeleteInstanceRequest(proto.Message): - r"""Request for - [DeleteInstance][google.cloud.redis.v1.CloudRedis.DeleteInstance]. - - 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: str = proto.Field( - proto.STRING, - number=1, - ) - - -class GcsSource(proto.Message): - r"""The Cloud Storage location for the input content - - Attributes: - uri (str): - Required. Source data URI. (e.g. - 'gs://my_bucket/my_object'). - """ - - uri: str = proto.Field( - proto.STRING, - number=1, - ) - - -class InputConfig(proto.Message): - r"""The input content - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - 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``. - """ - - gcs_source: 'GcsSource' = proto.Field( - proto.MESSAGE, - number=1, - oneof='source', - message='GcsSource', - ) - - -class ImportInstanceRequest(proto.Message): - r"""Request for - [Import][google.cloud.redis.v1.CloudRedis.ImportInstance]. - - 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. - input_config (google.cloud.redis_v1.types.InputConfig): - Required. Specify data to be imported. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - input_config: 'InputConfig' = proto.Field( - proto.MESSAGE, - number=3, - message='InputConfig', - ) - - -class GcsDestination(proto.Message): - r"""The Cloud Storage location for the output content - - Attributes: - uri (str): - Required. Data destination URI (e.g. - 'gs://my_bucket/my_object'). Existing files will be - overwritten. - """ - - uri: str = proto.Field( - proto.STRING, - number=1, - ) - - -class OutputConfig(proto.Message): - r"""The output content - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - gcs_destination (google.cloud.redis_v1.types.GcsDestination): - Google Cloud Storage destination for output - content. - - This field is a member of `oneof`_ ``destination``. - """ - - gcs_destination: 'GcsDestination' = proto.Field( - proto.MESSAGE, - number=1, - oneof='destination', - message='GcsDestination', - ) - - -class ExportInstanceRequest(proto.Message): - r"""Request for - [Export][google.cloud.redis.v1.CloudRedis.ExportInstance]. - - 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. - output_config (google.cloud.redis_v1.types.OutputConfig): - Required. Specify data to be exported. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - output_config: 'OutputConfig' = proto.Field( - proto.MESSAGE, - number=3, - message='OutputConfig', - ) - - -class FailoverInstanceRequest(proto.Message): - r"""Request for - [Failover][google.cloud.redis.v1.CloudRedis.FailoverInstance]. - - 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. - data_protection_mode (google.cloud.redis_v1.types.FailoverInstanceRequest.DataProtectionMode): - Optional. Available data protection modes that the user can - choose. If it's unspecified, data protection mode will be - LIMITED_DATA_LOSS by default. - """ - class DataProtectionMode(proto.Enum): - r"""Specifies different modes of operation in relation to the - data retention. - - Values: - DATA_PROTECTION_MODE_UNSPECIFIED (0): - Defaults to LIMITED_DATA_LOSS if a data protection mode is - not specified. - LIMITED_DATA_LOSS (1): - Instance failover will be protected with data - loss control. More specifically, the failover - will only be performed if the current - replication offset diff between primary and - replica is under a certain threshold. - FORCE_DATA_LOSS (2): - Instance failover will be performed without - data loss control. - """ - DATA_PROTECTION_MODE_UNSPECIFIED = 0 - LIMITED_DATA_LOSS = 1 - FORCE_DATA_LOSS = 2 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - data_protection_mode: DataProtectionMode = proto.Field( - proto.ENUM, - number=2, - enum=DataProtectionMode, - ) - - -class OperationMetadata(proto.Message): - r"""Represents the v1 metadata of the long-running operation. - - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - Creation timestamp. - end_time (google.protobuf.timestamp_pb2.Timestamp): - End timestamp. - target (str): - Operation target. - verb (str): - Operation verb. - status_detail (str): - Operation status details. - cancel_requested (bool): - Specifies if cancellation was requested for - the operation. - api_version (str): - API version. - """ - - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - target: str = proto.Field( - proto.STRING, - number=3, - ) - verb: str = proto.Field( - proto.STRING, - number=4, - ) - status_detail: str = proto.Field( - proto.STRING, - number=5, - ) - cancel_requested: bool = proto.Field( - proto.BOOL, - number=6, - ) - api_version: str = proto.Field( - proto.STRING, - number=7, - ) - - -class LocationMetadata(proto.Message): - r"""This location metadata represents additional configuration options - for a given location where a Redis instance may be created. All - fields are output only. It is returned as content of the - ``google.cloud.location.Location.metadata`` field. - - Attributes: - available_zones (MutableMapping[str, google.cloud.redis_v1.types.ZoneMetadata]): - Output only. The set of available zones in the location. The - map is keyed by the lowercase ID of each zone, as defined by - GCE. These keys can be specified in ``location_id`` or - ``alternative_location_id`` fields when creating a Redis - instance. - """ - - available_zones: MutableMapping[str, 'ZoneMetadata'] = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=1, - message='ZoneMetadata', - ) - - -class ZoneMetadata(proto.Message): - r"""Defines specific information for a particular zone. Currently - empty and reserved for future use only. - - """ - - -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: str = proto.Field( - proto.STRING, - number=1, - ) - cert: str = proto.Field( - proto.STRING, - number=2, - ) - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=3, - message=timestamp_pb2.Timestamp, - ) - expire_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - sha1_fingerprint: str = proto.Field( - proto.STRING, - number=5, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/tests/integration/goldens/redis/google/cloud/redis_v1/types/cloud_redis_pb2.py b/tests/integration/goldens/redis/google/cloud/redis_v1/types/cloud_redis_pb2.py new file mode 100644 index 0000000000..02dee49382 --- /dev/null +++ b/tests/integration/goldens/redis/google/cloud/redis_v1/types/cloud_redis_pb2.py @@ -0,0 +1,300 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/redis/v1/cloud_redis.proto +# Protobuf Python Version: 4.25.3 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.api import client_pb2 as google_dot_api_dot_client__pb2 +from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 +from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 +from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 +from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from google.protobuf import field_mask_pb2 as google_dot_protobuf_dot_field__mask__pb2 +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 +from google.type import dayofweek_pb2 as google_dot_type_dot_dayofweek__pb2 +from google.type import timeofday_pb2 as google_dot_type_dot_timeofday__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\'google/cloud/redis/v1/cloud_redis.proto\x12\x15google.cloud.redis.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a#google/longrunning/operations.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1bgoogle/type/dayofweek.proto\x1a\x1bgoogle/type/timeofday.proto\".\n\x08NodeInfo\x12\x0f\n\x02id\x18\x01 \x01(\tB\x03\xe0\x41\x03\x12\x11\n\x04zone\x18\x02 \x01(\tB\x03\xe0\x41\x03\"\x85\x13\n\x08Instance\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x14\n\x0c\x64isplay_name\x18\x02 \x01(\t\x12;\n\x06labels\x18\x03 \x03(\x0b\x32+.google.cloud.redis.v1.Instance.LabelsEntry\x12\x18\n\x0blocation_id\x18\x04 \x01(\tB\x03\xe0\x41\x01\x12$\n\x17\x61lternative_location_id\x18\x05 \x01(\tB\x03\xe0\x41\x01\x12\x1a\n\rredis_version\x18\x07 \x01(\tB\x03\xe0\x41\x01\x12\x1e\n\x11reserved_ip_range\x18\t \x01(\tB\x03\xe0\x41\x01\x12\x1f\n\x12secondary_ip_range\x18\x1e \x01(\tB\x03\xe0\x41\x01\x12\x11\n\x04host\x18\n \x01(\tB\x03\xe0\x41\x03\x12\x11\n\x04port\x18\x0b \x01(\x05\x42\x03\xe0\x41\x03\x12 \n\x13\x63urrent_location_id\x18\x0c \x01(\tB\x03\xe0\x41\x03\x12\x34\n\x0b\x63reate_time\x18\r \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x03\x12\x39\n\x05state\x18\x0e \x01(\x0e\x32%.google.cloud.redis.v1.Instance.StateB\x03\xe0\x41\x03\x12\x1b\n\x0estatus_message\x18\x0f \x01(\tB\x03\xe0\x41\x03\x12M\n\rredis_configs\x18\x10 \x03(\x0b\x32\x31.google.cloud.redis.v1.Instance.RedisConfigsEntryB\x03\xe0\x41\x01\x12\x37\n\x04tier\x18\x11 \x01(\x0e\x32$.google.cloud.redis.v1.Instance.TierB\x03\xe0\x41\x02\x12\x1b\n\x0ememory_size_gb\x18\x12 \x01(\x05\x42\x03\xe0\x41\x02\x12\x1f\n\x12\x61uthorized_network\x18\x14 \x01(\tB\x03\xe0\x41\x01\x12%\n\x18persistence_iam_identity\x18\x15 \x01(\tB\x03\xe0\x41\x03\x12\x46\n\x0c\x63onnect_mode\x18\x16 \x01(\x0e\x32+.google.cloud.redis.v1.Instance.ConnectModeB\x03\xe0\x41\x01\x12\x19\n\x0c\x61uth_enabled\x18\x17 \x01(\x08\x42\x03\xe0\x41\x01\x12\x43\n\x0fserver_ca_certs\x18\x19 \x03(\x0b\x32%.google.cloud.redis.v1.TlsCertificateB\x03\xe0\x41\x03\x12[\n\x17transit_encryption_mode\x18\x1a \x01(\x0e\x32\x35.google.cloud.redis.v1.Instance.TransitEncryptionModeB\x03\xe0\x41\x01\x12I\n\x12maintenance_policy\x18\x1b \x01(\x0b\x32(.google.cloud.redis.v1.MaintenancePolicyB\x03\xe0\x41\x01\x12M\n\x14maintenance_schedule\x18\x1c \x01(\x0b\x32*.google.cloud.redis.v1.MaintenanceScheduleB\x03\xe0\x41\x03\x12\x1a\n\rreplica_count\x18\x1f \x01(\x05\x42\x03\xe0\x41\x01\x12\x33\n\x05nodes\x18 \x03(\x0b\x32\x1f.google.cloud.redis.v1.NodeInfoB\x03\xe0\x41\x03\x12\x1a\n\rread_endpoint\x18! \x01(\tB\x03\xe0\x41\x03\x12\x1f\n\x12read_endpoint_port\x18\" \x01(\x05\x42\x03\xe0\x41\x03\x12Q\n\x12read_replicas_mode\x18# \x01(\x0e\x32\x30.google.cloud.redis.v1.Instance.ReadReplicasModeB\x03\xe0\x41\x01\x12!\n\x14\x63ustomer_managed_key\x18$ \x01(\tB\x03\xe0\x41\x01\x12I\n\x12persistence_config\x18% \x01(\x0b\x32(.google.cloud.redis.v1.PersistenceConfigB\x03\xe0\x41\x01\x12Q\n\x12suspension_reasons\x18& \x03(\x0e\x32\x30.google.cloud.redis.v1.Instance.SuspensionReasonB\x03\xe0\x41\x01\x12 \n\x13maintenance_version\x18\' \x01(\tB\x03\xe0\x41\x01\x12+\n\x1e\x61vailable_maintenance_versions\x18( \x03(\tB\x03\xe0\x41\x01\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\x1a\x33\n\x11RedisConfigsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\x94\x01\n\x05State\x12\x15\n\x11STATE_UNSPECIFIED\x10\x00\x12\x0c\n\x08\x43REATING\x10\x01\x12\t\n\x05READY\x10\x02\x12\x0c\n\x08UPDATING\x10\x03\x12\x0c\n\x08\x44\x45LETING\x10\x04\x12\r\n\tREPAIRING\x10\x05\x12\x0f\n\x0bMAINTENANCE\x10\x06\x12\r\n\tIMPORTING\x10\x08\x12\x10\n\x0c\x46\x41ILING_OVER\x10\t\"8\n\x04Tier\x12\x14\n\x10TIER_UNSPECIFIED\x10\x00\x12\t\n\x05\x42\x41SIC\x10\x01\x12\x0f\n\x0bSTANDARD_HA\x10\x03\"[\n\x0b\x43onnectMode\x12\x1c\n\x18\x43ONNECT_MODE_UNSPECIFIED\x10\x00\x12\x12\n\x0e\x44IRECT_PEERING\x10\x01\x12\x1a\n\x16PRIVATE_SERVICE_ACCESS\x10\x02\"i\n\x15TransitEncryptionMode\x12\'\n#TRANSIT_ENCRYPTION_MODE_UNSPECIFIED\x10\x00\x12\x19\n\x15SERVER_AUTHENTICATION\x10\x01\x12\x0c\n\x08\x44ISABLED\x10\x02\"m\n\x10ReadReplicasMode\x12\"\n\x1eREAD_REPLICAS_MODE_UNSPECIFIED\x10\x00\x12\x1a\n\x16READ_REPLICAS_DISABLED\x10\x01\x12\x19\n\x15READ_REPLICAS_ENABLED\x10\x02\"U\n\x10SuspensionReason\x12!\n\x1dSUSPENSION_REASON_UNSPECIFIED\x10\x00\x12\x1e\n\x1a\x43USTOMER_MANAGED_KEY_ISSUE\x10\x01:`\xea\x41]\n\x1dredis.googleapis.com/Instance\x12\xda\x41\x06parent\x82\xd3\xe4\x93\x02/\x12-/v1/{parent=projects/*/locations/*}/instances\x12\x97\x01\n\x0bGetInstance\x12).google.cloud.redis.v1.GetInstanceRequest\x1a\x1f.google.cloud.redis.v1.Instance\"<\xda\x41\x04name\x82\xd3\xe4\x93\x02/\x12-/v1/{name=projects/*/locations/*/instances/*}\x12\xc0\x01\n\x15GetInstanceAuthString\x12\x33.google.cloud.redis.v1.GetInstanceAuthStringRequest\x1a).google.cloud.redis.v1.InstanceAuthString\"G\xda\x41\x04name\x82\xd3\xe4\x93\x02:\x12\x38/v1/{name=projects/*/locations/*/instances/*}/authString\x12\x89\x02\n\x0e\x43reateInstance\x12,.google.cloud.redis.v1.CreateInstanceRequest\x1a\x1d.google.longrunning.Operation\"\xa9\x01\xca\x41I\n\x1egoogle.cloud.redis.v1.Instance\x12\'google.cloud.redis.v1.OperationMetadata\xda\x41\x1bparent,instance_id,instance\x82\xd3\xe4\x93\x02\x39\"-/v1/{parent=projects/*/locations/*}/instances:\x08instance\x12\x8b\x02\n\x0eUpdateInstance\x12,.google.cloud.redis.v1.UpdateInstanceRequest\x1a\x1d.google.longrunning.Operation\"\xab\x01\xca\x41I\n\x1egoogle.cloud.redis.v1.Instance\x12\'google.cloud.redis.v1.OperationMetadata\xda\x41\x14update_mask,instance\x82\xd3\xe4\x93\x02\x42\x32\x36/v1/{instance.name=projects/*/locations/*/instances/*}:\x08instance\x12\x83\x02\n\x0fUpgradeInstance\x12-.google.cloud.redis.v1.UpgradeInstanceRequest\x1a\x1d.google.longrunning.Operation\"\xa1\x01\xca\x41I\n\x1egoogle.cloud.redis.v1.Instance\x12\'google.cloud.redis.v1.OperationMetadata\xda\x41\x12name,redis_version\x82\xd3\xe4\x93\x02:\"5/v1/{name=projects/*/locations/*/instances/*}:upgrade:\x01*\x12\xff\x01\n\x0eImportInstance\x12,.google.cloud.redis.v1.ImportInstanceRequest\x1a\x1d.google.longrunning.Operation\"\x9f\x01\xca\x41I\n\x1egoogle.cloud.redis.v1.Instance\x12\'google.cloud.redis.v1.OperationMetadata\xda\x41\x11name,input_config\x82\xd3\xe4\x93\x02\x39\"4/v1/{name=projects/*/locations/*/instances/*}:import:\x01*\x12\x80\x02\n\x0e\x45xportInstance\x12,.google.cloud.redis.v1.ExportInstanceRequest\x1a\x1d.google.longrunning.Operation\"\xa0\x01\xca\x41I\n\x1egoogle.cloud.redis.v1.Instance\x12\'google.cloud.redis.v1.OperationMetadata\xda\x41\x12name,output_config\x82\xd3\xe4\x93\x02\x39\"4/v1/{name=projects/*/locations/*/instances/*}:export:\x01*\x12\x8d\x02\n\x10\x46\x61iloverInstance\x12..google.cloud.redis.v1.FailoverInstanceRequest\x1a\x1d.google.longrunning.Operation\"\xa9\x01\xca\x41I\n\x1egoogle.cloud.redis.v1.Instance\x12\'google.cloud.redis.v1.OperationMetadata\xda\x41\x19name,data_protection_mode\x82\xd3\xe4\x93\x02;\"6/v1/{name=projects/*/locations/*/instances/*}:failover:\x01*\x12\xde\x01\n\x0e\x44\x65leteInstance\x12,.google.cloud.redis.v1.DeleteInstanceRequest\x1a\x1d.google.longrunning.Operation\"\x7f\xca\x41@\n\x15google.protobuf.Empty\x12\'google.cloud.redis.v1.OperationMetadata\xda\x41\x04name\x82\xd3\xe4\x93\x02/*-/v1/{name=projects/*/locations/*/instances/*}\x12\xaf\x02\n\x15RescheduleMaintenance\x12\x33.google.cloud.redis.v1.RescheduleMaintenanceRequest\x1a\x1d.google.longrunning.Operation\"\xc1\x01\xca\x41I\n\x1egoogle.cloud.redis.v1.Instance\x12\'google.cloud.redis.v1.OperationMetadata\xda\x41$name, reschedule_type, schedule_time\x82\xd3\xe4\x93\x02H\"C/v1/{name=projects/*/locations/*/instances/*}:rescheduleMaintenance:\x01*\x1aH\xca\x41\x14redis.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformBh\n\x19\x63om.google.cloud.redis.v1B\x18\x43loudRedisServiceV1ProtoP\x01Z/cloud.google.com/go/redis/apiv1/redispb;redispbb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'google.cloud.redis.v1.cloud_redis_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + _globals['DESCRIPTOR']._options = None + _globals['DESCRIPTOR']._serialized_options = b'\n\031com.google.cloud.redis.v1B\030CloudRedisServiceV1ProtoP\001Z/cloud.google.com/go/redis/apiv1/redispb;redispb' + _globals['_NODEINFO'].fields_by_name['id']._options = None + _globals['_NODEINFO'].fields_by_name['id']._serialized_options = b'\340A\003' + _globals['_NODEINFO'].fields_by_name['zone']._options = None + _globals['_NODEINFO'].fields_by_name['zone']._serialized_options = b'\340A\003' + _globals['_INSTANCE_LABELSENTRY']._options = None + _globals['_INSTANCE_LABELSENTRY']._serialized_options = b'8\001' + _globals['_INSTANCE_REDISCONFIGSENTRY']._options = None + _globals['_INSTANCE_REDISCONFIGSENTRY']._serialized_options = b'8\001' + _globals['_INSTANCE'].fields_by_name['name']._options = None + _globals['_INSTANCE'].fields_by_name['name']._serialized_options = b'\340A\002' + _globals['_INSTANCE'].fields_by_name['location_id']._options = None + _globals['_INSTANCE'].fields_by_name['location_id']._serialized_options = b'\340A\001' + _globals['_INSTANCE'].fields_by_name['alternative_location_id']._options = None + _globals['_INSTANCE'].fields_by_name['alternative_location_id']._serialized_options = b'\340A\001' + _globals['_INSTANCE'].fields_by_name['redis_version']._options = None + _globals['_INSTANCE'].fields_by_name['redis_version']._serialized_options = b'\340A\001' + _globals['_INSTANCE'].fields_by_name['reserved_ip_range']._options = None + _globals['_INSTANCE'].fields_by_name['reserved_ip_range']._serialized_options = b'\340A\001' + _globals['_INSTANCE'].fields_by_name['secondary_ip_range']._options = None + _globals['_INSTANCE'].fields_by_name['secondary_ip_range']._serialized_options = b'\340A\001' + _globals['_INSTANCE'].fields_by_name['host']._options = None + _globals['_INSTANCE'].fields_by_name['host']._serialized_options = b'\340A\003' + _globals['_INSTANCE'].fields_by_name['port']._options = None + _globals['_INSTANCE'].fields_by_name['port']._serialized_options = b'\340A\003' + _globals['_INSTANCE'].fields_by_name['current_location_id']._options = None + _globals['_INSTANCE'].fields_by_name['current_location_id']._serialized_options = b'\340A\003' + _globals['_INSTANCE'].fields_by_name['create_time']._options = None + _globals['_INSTANCE'].fields_by_name['create_time']._serialized_options = b'\340A\003' + _globals['_INSTANCE'].fields_by_name['state']._options = None + _globals['_INSTANCE'].fields_by_name['state']._serialized_options = b'\340A\003' + _globals['_INSTANCE'].fields_by_name['status_message']._options = None + _globals['_INSTANCE'].fields_by_name['status_message']._serialized_options = b'\340A\003' + _globals['_INSTANCE'].fields_by_name['redis_configs']._options = None + _globals['_INSTANCE'].fields_by_name['redis_configs']._serialized_options = b'\340A\001' + _globals['_INSTANCE'].fields_by_name['tier']._options = None + _globals['_INSTANCE'].fields_by_name['tier']._serialized_options = b'\340A\002' + _globals['_INSTANCE'].fields_by_name['memory_size_gb']._options = None + _globals['_INSTANCE'].fields_by_name['memory_size_gb']._serialized_options = b'\340A\002' + _globals['_INSTANCE'].fields_by_name['authorized_network']._options = None + _globals['_INSTANCE'].fields_by_name['authorized_network']._serialized_options = b'\340A\001' + _globals['_INSTANCE'].fields_by_name['persistence_iam_identity']._options = None + _globals['_INSTANCE'].fields_by_name['persistence_iam_identity']._serialized_options = b'\340A\003' + _globals['_INSTANCE'].fields_by_name['connect_mode']._options = None + _globals['_INSTANCE'].fields_by_name['connect_mode']._serialized_options = b'\340A\001' + _globals['_INSTANCE'].fields_by_name['auth_enabled']._options = None + _globals['_INSTANCE'].fields_by_name['auth_enabled']._serialized_options = b'\340A\001' + _globals['_INSTANCE'].fields_by_name['server_ca_certs']._options = None + _globals['_INSTANCE'].fields_by_name['server_ca_certs']._serialized_options = b'\340A\003' + _globals['_INSTANCE'].fields_by_name['transit_encryption_mode']._options = None + _globals['_INSTANCE'].fields_by_name['transit_encryption_mode']._serialized_options = b'\340A\001' + _globals['_INSTANCE'].fields_by_name['maintenance_policy']._options = None + _globals['_INSTANCE'].fields_by_name['maintenance_policy']._serialized_options = b'\340A\001' + _globals['_INSTANCE'].fields_by_name['maintenance_schedule']._options = None + _globals['_INSTANCE'].fields_by_name['maintenance_schedule']._serialized_options = b'\340A\003' + _globals['_INSTANCE'].fields_by_name['replica_count']._options = None + _globals['_INSTANCE'].fields_by_name['replica_count']._serialized_options = b'\340A\001' + _globals['_INSTANCE'].fields_by_name['nodes']._options = None + _globals['_INSTANCE'].fields_by_name['nodes']._serialized_options = b'\340A\003' + _globals['_INSTANCE'].fields_by_name['read_endpoint']._options = None + _globals['_INSTANCE'].fields_by_name['read_endpoint']._serialized_options = b'\340A\003' + _globals['_INSTANCE'].fields_by_name['read_endpoint_port']._options = None + _globals['_INSTANCE'].fields_by_name['read_endpoint_port']._serialized_options = b'\340A\003' + _globals['_INSTANCE'].fields_by_name['read_replicas_mode']._options = None + _globals['_INSTANCE'].fields_by_name['read_replicas_mode']._serialized_options = b'\340A\001' + _globals['_INSTANCE'].fields_by_name['customer_managed_key']._options = None + _globals['_INSTANCE'].fields_by_name['customer_managed_key']._serialized_options = b'\340A\001' + _globals['_INSTANCE'].fields_by_name['persistence_config']._options = None + _globals['_INSTANCE'].fields_by_name['persistence_config']._serialized_options = b'\340A\001' + _globals['_INSTANCE'].fields_by_name['suspension_reasons']._options = None + _globals['_INSTANCE'].fields_by_name['suspension_reasons']._serialized_options = b'\340A\001' + _globals['_INSTANCE'].fields_by_name['maintenance_version']._options = None + _globals['_INSTANCE'].fields_by_name['maintenance_version']._serialized_options = b'\340A\001' + _globals['_INSTANCE'].fields_by_name['available_maintenance_versions']._options = None + _globals['_INSTANCE'].fields_by_name['available_maintenance_versions']._serialized_options = b'\340A\001' + _globals['_INSTANCE']._options = None + _globals['_INSTANCE']._serialized_options = b'\352A]\n\035redis.googleapis.com/Instance\022 None: ... + +class Instance(_message.Message): + __slots__ = ("name", "display_name", "labels", "location_id", "alternative_location_id", "redis_version", "reserved_ip_range", "secondary_ip_range", "host", "port", "current_location_id", "create_time", "state", "status_message", "redis_configs", "tier", "memory_size_gb", "authorized_network", "persistence_iam_identity", "connect_mode", "auth_enabled", "server_ca_certs", "transit_encryption_mode", "maintenance_policy", "maintenance_schedule", "replica_count", "nodes", "read_endpoint", "read_endpoint_port", "read_replicas_mode", "customer_managed_key", "persistence_config", "suspension_reasons", "maintenance_version", "available_maintenance_versions") + class State(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + STATE_UNSPECIFIED: _ClassVar[Instance.State] + CREATING: _ClassVar[Instance.State] + READY: _ClassVar[Instance.State] + UPDATING: _ClassVar[Instance.State] + DELETING: _ClassVar[Instance.State] + REPAIRING: _ClassVar[Instance.State] + MAINTENANCE: _ClassVar[Instance.State] + IMPORTING: _ClassVar[Instance.State] + FAILING_OVER: _ClassVar[Instance.State] + STATE_UNSPECIFIED: Instance.State + CREATING: Instance.State + READY: Instance.State + UPDATING: Instance.State + DELETING: Instance.State + REPAIRING: Instance.State + MAINTENANCE: Instance.State + IMPORTING: Instance.State + FAILING_OVER: Instance.State + class Tier(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + TIER_UNSPECIFIED: _ClassVar[Instance.Tier] + BASIC: _ClassVar[Instance.Tier] + STANDARD_HA: _ClassVar[Instance.Tier] + TIER_UNSPECIFIED: Instance.Tier + BASIC: Instance.Tier + STANDARD_HA: Instance.Tier + class ConnectMode(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + CONNECT_MODE_UNSPECIFIED: _ClassVar[Instance.ConnectMode] + DIRECT_PEERING: _ClassVar[Instance.ConnectMode] + PRIVATE_SERVICE_ACCESS: _ClassVar[Instance.ConnectMode] + CONNECT_MODE_UNSPECIFIED: Instance.ConnectMode + DIRECT_PEERING: Instance.ConnectMode + PRIVATE_SERVICE_ACCESS: Instance.ConnectMode + class TransitEncryptionMode(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + TRANSIT_ENCRYPTION_MODE_UNSPECIFIED: _ClassVar[Instance.TransitEncryptionMode] + SERVER_AUTHENTICATION: _ClassVar[Instance.TransitEncryptionMode] + DISABLED: _ClassVar[Instance.TransitEncryptionMode] + TRANSIT_ENCRYPTION_MODE_UNSPECIFIED: Instance.TransitEncryptionMode + SERVER_AUTHENTICATION: Instance.TransitEncryptionMode + DISABLED: Instance.TransitEncryptionMode + class ReadReplicasMode(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + READ_REPLICAS_MODE_UNSPECIFIED: _ClassVar[Instance.ReadReplicasMode] + READ_REPLICAS_DISABLED: _ClassVar[Instance.ReadReplicasMode] + READ_REPLICAS_ENABLED: _ClassVar[Instance.ReadReplicasMode] + READ_REPLICAS_MODE_UNSPECIFIED: Instance.ReadReplicasMode + READ_REPLICAS_DISABLED: Instance.ReadReplicasMode + READ_REPLICAS_ENABLED: Instance.ReadReplicasMode + class SuspensionReason(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + SUSPENSION_REASON_UNSPECIFIED: _ClassVar[Instance.SuspensionReason] + CUSTOMER_MANAGED_KEY_ISSUE: _ClassVar[Instance.SuspensionReason] + SUSPENSION_REASON_UNSPECIFIED: Instance.SuspensionReason + CUSTOMER_MANAGED_KEY_ISSUE: Instance.SuspensionReason + class LabelsEntry(_message.Message): + __slots__ = ("key", "value") + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: str + value: str + def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ... + class RedisConfigsEntry(_message.Message): + __slots__ = ("key", "value") + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: str + value: str + def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ... + NAME_FIELD_NUMBER: _ClassVar[int] + DISPLAY_NAME_FIELD_NUMBER: _ClassVar[int] + LABELS_FIELD_NUMBER: _ClassVar[int] + LOCATION_ID_FIELD_NUMBER: _ClassVar[int] + ALTERNATIVE_LOCATION_ID_FIELD_NUMBER: _ClassVar[int] + REDIS_VERSION_FIELD_NUMBER: _ClassVar[int] + RESERVED_IP_RANGE_FIELD_NUMBER: _ClassVar[int] + SECONDARY_IP_RANGE_FIELD_NUMBER: _ClassVar[int] + HOST_FIELD_NUMBER: _ClassVar[int] + PORT_FIELD_NUMBER: _ClassVar[int] + CURRENT_LOCATION_ID_FIELD_NUMBER: _ClassVar[int] + CREATE_TIME_FIELD_NUMBER: _ClassVar[int] + STATE_FIELD_NUMBER: _ClassVar[int] + STATUS_MESSAGE_FIELD_NUMBER: _ClassVar[int] + REDIS_CONFIGS_FIELD_NUMBER: _ClassVar[int] + TIER_FIELD_NUMBER: _ClassVar[int] + MEMORY_SIZE_GB_FIELD_NUMBER: _ClassVar[int] + AUTHORIZED_NETWORK_FIELD_NUMBER: _ClassVar[int] + PERSISTENCE_IAM_IDENTITY_FIELD_NUMBER: _ClassVar[int] + CONNECT_MODE_FIELD_NUMBER: _ClassVar[int] + AUTH_ENABLED_FIELD_NUMBER: _ClassVar[int] + SERVER_CA_CERTS_FIELD_NUMBER: _ClassVar[int] + TRANSIT_ENCRYPTION_MODE_FIELD_NUMBER: _ClassVar[int] + MAINTENANCE_POLICY_FIELD_NUMBER: _ClassVar[int] + MAINTENANCE_SCHEDULE_FIELD_NUMBER: _ClassVar[int] + REPLICA_COUNT_FIELD_NUMBER: _ClassVar[int] + NODES_FIELD_NUMBER: _ClassVar[int] + READ_ENDPOINT_FIELD_NUMBER: _ClassVar[int] + READ_ENDPOINT_PORT_FIELD_NUMBER: _ClassVar[int] + READ_REPLICAS_MODE_FIELD_NUMBER: _ClassVar[int] + CUSTOMER_MANAGED_KEY_FIELD_NUMBER: _ClassVar[int] + PERSISTENCE_CONFIG_FIELD_NUMBER: _ClassVar[int] + SUSPENSION_REASONS_FIELD_NUMBER: _ClassVar[int] + MAINTENANCE_VERSION_FIELD_NUMBER: _ClassVar[int] + AVAILABLE_MAINTENANCE_VERSIONS_FIELD_NUMBER: _ClassVar[int] + name: str + display_name: str + labels: _containers.ScalarMap[str, str] + location_id: str + alternative_location_id: str + redis_version: str + reserved_ip_range: str + secondary_ip_range: str + host: str + port: int + current_location_id: str + create_time: _timestamp_pb2.Timestamp + state: Instance.State + status_message: str + redis_configs: _containers.ScalarMap[str, str] + tier: Instance.Tier + memory_size_gb: int + authorized_network: str + persistence_iam_identity: str + connect_mode: Instance.ConnectMode + auth_enabled: bool + server_ca_certs: _containers.RepeatedCompositeFieldContainer[TlsCertificate] + transit_encryption_mode: Instance.TransitEncryptionMode + maintenance_policy: MaintenancePolicy + maintenance_schedule: MaintenanceSchedule + replica_count: int + nodes: _containers.RepeatedCompositeFieldContainer[NodeInfo] + read_endpoint: str + read_endpoint_port: int + read_replicas_mode: Instance.ReadReplicasMode + customer_managed_key: str + persistence_config: PersistenceConfig + suspension_reasons: _containers.RepeatedScalarFieldContainer[Instance.SuspensionReason] + maintenance_version: str + available_maintenance_versions: _containers.RepeatedScalarFieldContainer[str] + def __init__(self, name: _Optional[str] = ..., display_name: _Optional[str] = ..., labels: _Optional[_Mapping[str, str]] = ..., location_id: _Optional[str] = ..., alternative_location_id: _Optional[str] = ..., redis_version: _Optional[str] = ..., reserved_ip_range: _Optional[str] = ..., secondary_ip_range: _Optional[str] = ..., host: _Optional[str] = ..., port: _Optional[int] = ..., current_location_id: _Optional[str] = ..., create_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., state: _Optional[_Union[Instance.State, str]] = ..., status_message: _Optional[str] = ..., redis_configs: _Optional[_Mapping[str, str]] = ..., tier: _Optional[_Union[Instance.Tier, str]] = ..., memory_size_gb: _Optional[int] = ..., authorized_network: _Optional[str] = ..., persistence_iam_identity: _Optional[str] = ..., connect_mode: _Optional[_Union[Instance.ConnectMode, str]] = ..., auth_enabled: bool = ..., server_ca_certs: _Optional[_Iterable[_Union[TlsCertificate, _Mapping]]] = ..., transit_encryption_mode: _Optional[_Union[Instance.TransitEncryptionMode, str]] = ..., maintenance_policy: _Optional[_Union[MaintenancePolicy, _Mapping]] = ..., maintenance_schedule: _Optional[_Union[MaintenanceSchedule, _Mapping]] = ..., replica_count: _Optional[int] = ..., nodes: _Optional[_Iterable[_Union[NodeInfo, _Mapping]]] = ..., read_endpoint: _Optional[str] = ..., read_endpoint_port: _Optional[int] = ..., read_replicas_mode: _Optional[_Union[Instance.ReadReplicasMode, str]] = ..., customer_managed_key: _Optional[str] = ..., persistence_config: _Optional[_Union[PersistenceConfig, _Mapping]] = ..., suspension_reasons: _Optional[_Iterable[_Union[Instance.SuspensionReason, str]]] = ..., maintenance_version: _Optional[str] = ..., available_maintenance_versions: _Optional[_Iterable[str]] = ...) -> None: ... + +class PersistenceConfig(_message.Message): + __slots__ = ("persistence_mode", "rdb_snapshot_period", "rdb_next_snapshot_time", "rdb_snapshot_start_time") + class PersistenceMode(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + PERSISTENCE_MODE_UNSPECIFIED: _ClassVar[PersistenceConfig.PersistenceMode] + DISABLED: _ClassVar[PersistenceConfig.PersistenceMode] + RDB: _ClassVar[PersistenceConfig.PersistenceMode] + PERSISTENCE_MODE_UNSPECIFIED: PersistenceConfig.PersistenceMode + DISABLED: PersistenceConfig.PersistenceMode + RDB: PersistenceConfig.PersistenceMode + class SnapshotPeriod(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + SNAPSHOT_PERIOD_UNSPECIFIED: _ClassVar[PersistenceConfig.SnapshotPeriod] + ONE_HOUR: _ClassVar[PersistenceConfig.SnapshotPeriod] + SIX_HOURS: _ClassVar[PersistenceConfig.SnapshotPeriod] + TWELVE_HOURS: _ClassVar[PersistenceConfig.SnapshotPeriod] + TWENTY_FOUR_HOURS: _ClassVar[PersistenceConfig.SnapshotPeriod] + SNAPSHOT_PERIOD_UNSPECIFIED: PersistenceConfig.SnapshotPeriod + ONE_HOUR: PersistenceConfig.SnapshotPeriod + SIX_HOURS: PersistenceConfig.SnapshotPeriod + TWELVE_HOURS: PersistenceConfig.SnapshotPeriod + TWENTY_FOUR_HOURS: PersistenceConfig.SnapshotPeriod + PERSISTENCE_MODE_FIELD_NUMBER: _ClassVar[int] + RDB_SNAPSHOT_PERIOD_FIELD_NUMBER: _ClassVar[int] + RDB_NEXT_SNAPSHOT_TIME_FIELD_NUMBER: _ClassVar[int] + RDB_SNAPSHOT_START_TIME_FIELD_NUMBER: _ClassVar[int] + persistence_mode: PersistenceConfig.PersistenceMode + rdb_snapshot_period: PersistenceConfig.SnapshotPeriod + rdb_next_snapshot_time: _timestamp_pb2.Timestamp + rdb_snapshot_start_time: _timestamp_pb2.Timestamp + def __init__(self, persistence_mode: _Optional[_Union[PersistenceConfig.PersistenceMode, str]] = ..., rdb_snapshot_period: _Optional[_Union[PersistenceConfig.SnapshotPeriod, str]] = ..., rdb_next_snapshot_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., rdb_snapshot_start_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ... + +class RescheduleMaintenanceRequest(_message.Message): + __slots__ = ("name", "reschedule_type", "schedule_time") + class RescheduleType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + RESCHEDULE_TYPE_UNSPECIFIED: _ClassVar[RescheduleMaintenanceRequest.RescheduleType] + IMMEDIATE: _ClassVar[RescheduleMaintenanceRequest.RescheduleType] + NEXT_AVAILABLE_WINDOW: _ClassVar[RescheduleMaintenanceRequest.RescheduleType] + SPECIFIC_TIME: _ClassVar[RescheduleMaintenanceRequest.RescheduleType] + RESCHEDULE_TYPE_UNSPECIFIED: RescheduleMaintenanceRequest.RescheduleType + IMMEDIATE: RescheduleMaintenanceRequest.RescheduleType + NEXT_AVAILABLE_WINDOW: RescheduleMaintenanceRequest.RescheduleType + SPECIFIC_TIME: RescheduleMaintenanceRequest.RescheduleType + NAME_FIELD_NUMBER: _ClassVar[int] + RESCHEDULE_TYPE_FIELD_NUMBER: _ClassVar[int] + SCHEDULE_TIME_FIELD_NUMBER: _ClassVar[int] + name: str + reschedule_type: RescheduleMaintenanceRequest.RescheduleType + schedule_time: _timestamp_pb2.Timestamp + def __init__(self, name: _Optional[str] = ..., reschedule_type: _Optional[_Union[RescheduleMaintenanceRequest.RescheduleType, str]] = ..., schedule_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ... + +class MaintenancePolicy(_message.Message): + __slots__ = ("create_time", "update_time", "description", "weekly_maintenance_window") + CREATE_TIME_FIELD_NUMBER: _ClassVar[int] + UPDATE_TIME_FIELD_NUMBER: _ClassVar[int] + DESCRIPTION_FIELD_NUMBER: _ClassVar[int] + WEEKLY_MAINTENANCE_WINDOW_FIELD_NUMBER: _ClassVar[int] + create_time: _timestamp_pb2.Timestamp + update_time: _timestamp_pb2.Timestamp + description: str + weekly_maintenance_window: _containers.RepeatedCompositeFieldContainer[WeeklyMaintenanceWindow] + def __init__(self, create_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., update_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., description: _Optional[str] = ..., weekly_maintenance_window: _Optional[_Iterable[_Union[WeeklyMaintenanceWindow, _Mapping]]] = ...) -> None: ... + +class WeeklyMaintenanceWindow(_message.Message): + __slots__ = ("day", "start_time", "duration") + DAY_FIELD_NUMBER: _ClassVar[int] + START_TIME_FIELD_NUMBER: _ClassVar[int] + DURATION_FIELD_NUMBER: _ClassVar[int] + day: _dayofweek_pb2.DayOfWeek + start_time: _timeofday_pb2.TimeOfDay + duration: _duration_pb2.Duration + def __init__(self, day: _Optional[_Union[_dayofweek_pb2.DayOfWeek, str]] = ..., start_time: _Optional[_Union[_timeofday_pb2.TimeOfDay, _Mapping]] = ..., duration: _Optional[_Union[_duration_pb2.Duration, _Mapping]] = ...) -> None: ... + +class MaintenanceSchedule(_message.Message): + __slots__ = ("start_time", "end_time", "can_reschedule", "schedule_deadline_time") + START_TIME_FIELD_NUMBER: _ClassVar[int] + END_TIME_FIELD_NUMBER: _ClassVar[int] + CAN_RESCHEDULE_FIELD_NUMBER: _ClassVar[int] + SCHEDULE_DEADLINE_TIME_FIELD_NUMBER: _ClassVar[int] + start_time: _timestamp_pb2.Timestamp + end_time: _timestamp_pb2.Timestamp + can_reschedule: bool + schedule_deadline_time: _timestamp_pb2.Timestamp + def __init__(self, start_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., end_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., can_reschedule: bool = ..., schedule_deadline_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ... + +class ListInstancesRequest(_message.Message): + __slots__ = ("parent", "page_size", "page_token") + PARENT_FIELD_NUMBER: _ClassVar[int] + PAGE_SIZE_FIELD_NUMBER: _ClassVar[int] + PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + parent: str + page_size: int + page_token: str + def __init__(self, parent: _Optional[str] = ..., page_size: _Optional[int] = ..., page_token: _Optional[str] = ...) -> None: ... + +class ListInstancesResponse(_message.Message): + __slots__ = ("instances", "next_page_token", "unreachable") + INSTANCES_FIELD_NUMBER: _ClassVar[int] + NEXT_PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + UNREACHABLE_FIELD_NUMBER: _ClassVar[int] + instances: _containers.RepeatedCompositeFieldContainer[Instance] + next_page_token: str + unreachable: _containers.RepeatedScalarFieldContainer[str] + def __init__(self, instances: _Optional[_Iterable[_Union[Instance, _Mapping]]] = ..., next_page_token: _Optional[str] = ..., unreachable: _Optional[_Iterable[str]] = ...) -> None: ... + +class GetInstanceRequest(_message.Message): + __slots__ = ("name",) + NAME_FIELD_NUMBER: _ClassVar[int] + name: str + def __init__(self, name: _Optional[str] = ...) -> None: ... + +class GetInstanceAuthStringRequest(_message.Message): + __slots__ = ("name",) + NAME_FIELD_NUMBER: _ClassVar[int] + name: str + def __init__(self, name: _Optional[str] = ...) -> None: ... + +class InstanceAuthString(_message.Message): + __slots__ = ("auth_string",) + AUTH_STRING_FIELD_NUMBER: _ClassVar[int] + auth_string: str + def __init__(self, auth_string: _Optional[str] = ...) -> None: ... + +class CreateInstanceRequest(_message.Message): + __slots__ = ("parent", "instance_id", "instance") + PARENT_FIELD_NUMBER: _ClassVar[int] + INSTANCE_ID_FIELD_NUMBER: _ClassVar[int] + INSTANCE_FIELD_NUMBER: _ClassVar[int] + parent: str + instance_id: str + instance: Instance + def __init__(self, parent: _Optional[str] = ..., instance_id: _Optional[str] = ..., instance: _Optional[_Union[Instance, _Mapping]] = ...) -> None: ... + +class UpdateInstanceRequest(_message.Message): + __slots__ = ("update_mask", "instance") + UPDATE_MASK_FIELD_NUMBER: _ClassVar[int] + INSTANCE_FIELD_NUMBER: _ClassVar[int] + update_mask: _field_mask_pb2.FieldMask + instance: Instance + def __init__(self, update_mask: _Optional[_Union[_field_mask_pb2.FieldMask, _Mapping]] = ..., instance: _Optional[_Union[Instance, _Mapping]] = ...) -> None: ... + +class UpgradeInstanceRequest(_message.Message): + __slots__ = ("name", "redis_version") + NAME_FIELD_NUMBER: _ClassVar[int] + REDIS_VERSION_FIELD_NUMBER: _ClassVar[int] + name: str + redis_version: str + def __init__(self, name: _Optional[str] = ..., redis_version: _Optional[str] = ...) -> None: ... + +class DeleteInstanceRequest(_message.Message): + __slots__ = ("name",) + NAME_FIELD_NUMBER: _ClassVar[int] + name: str + def __init__(self, name: _Optional[str] = ...) -> None: ... + +class GcsSource(_message.Message): + __slots__ = ("uri",) + URI_FIELD_NUMBER: _ClassVar[int] + uri: str + def __init__(self, uri: _Optional[str] = ...) -> None: ... + +class InputConfig(_message.Message): + __slots__ = ("gcs_source",) + GCS_SOURCE_FIELD_NUMBER: _ClassVar[int] + gcs_source: GcsSource + def __init__(self, gcs_source: _Optional[_Union[GcsSource, _Mapping]] = ...) -> None: ... + +class ImportInstanceRequest(_message.Message): + __slots__ = ("name", "input_config") + NAME_FIELD_NUMBER: _ClassVar[int] + INPUT_CONFIG_FIELD_NUMBER: _ClassVar[int] + name: str + input_config: InputConfig + def __init__(self, name: _Optional[str] = ..., input_config: _Optional[_Union[InputConfig, _Mapping]] = ...) -> None: ... + +class GcsDestination(_message.Message): + __slots__ = ("uri",) + URI_FIELD_NUMBER: _ClassVar[int] + uri: str + def __init__(self, uri: _Optional[str] = ...) -> None: ... + +class OutputConfig(_message.Message): + __slots__ = ("gcs_destination",) + GCS_DESTINATION_FIELD_NUMBER: _ClassVar[int] + gcs_destination: GcsDestination + def __init__(self, gcs_destination: _Optional[_Union[GcsDestination, _Mapping]] = ...) -> None: ... + +class ExportInstanceRequest(_message.Message): + __slots__ = ("name", "output_config") + NAME_FIELD_NUMBER: _ClassVar[int] + OUTPUT_CONFIG_FIELD_NUMBER: _ClassVar[int] + name: str + output_config: OutputConfig + def __init__(self, name: _Optional[str] = ..., output_config: _Optional[_Union[OutputConfig, _Mapping]] = ...) -> None: ... + +class FailoverInstanceRequest(_message.Message): + __slots__ = ("name", "data_protection_mode") + class DataProtectionMode(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + DATA_PROTECTION_MODE_UNSPECIFIED: _ClassVar[FailoverInstanceRequest.DataProtectionMode] + LIMITED_DATA_LOSS: _ClassVar[FailoverInstanceRequest.DataProtectionMode] + FORCE_DATA_LOSS: _ClassVar[FailoverInstanceRequest.DataProtectionMode] + DATA_PROTECTION_MODE_UNSPECIFIED: FailoverInstanceRequest.DataProtectionMode + LIMITED_DATA_LOSS: FailoverInstanceRequest.DataProtectionMode + FORCE_DATA_LOSS: FailoverInstanceRequest.DataProtectionMode + NAME_FIELD_NUMBER: _ClassVar[int] + DATA_PROTECTION_MODE_FIELD_NUMBER: _ClassVar[int] + name: str + data_protection_mode: FailoverInstanceRequest.DataProtectionMode + def __init__(self, name: _Optional[str] = ..., data_protection_mode: _Optional[_Union[FailoverInstanceRequest.DataProtectionMode, str]] = ...) -> None: ... + +class OperationMetadata(_message.Message): + __slots__ = ("create_time", "end_time", "target", "verb", "status_detail", "cancel_requested", "api_version") + CREATE_TIME_FIELD_NUMBER: _ClassVar[int] + END_TIME_FIELD_NUMBER: _ClassVar[int] + TARGET_FIELD_NUMBER: _ClassVar[int] + VERB_FIELD_NUMBER: _ClassVar[int] + STATUS_DETAIL_FIELD_NUMBER: _ClassVar[int] + CANCEL_REQUESTED_FIELD_NUMBER: _ClassVar[int] + API_VERSION_FIELD_NUMBER: _ClassVar[int] + create_time: _timestamp_pb2.Timestamp + end_time: _timestamp_pb2.Timestamp + target: str + verb: str + status_detail: str + cancel_requested: bool + api_version: str + def __init__(self, create_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., end_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., target: _Optional[str] = ..., verb: _Optional[str] = ..., status_detail: _Optional[str] = ..., cancel_requested: bool = ..., api_version: _Optional[str] = ...) -> None: ... + +class LocationMetadata(_message.Message): + __slots__ = ("available_zones",) + class AvailableZonesEntry(_message.Message): + __slots__ = ("key", "value") + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: str + value: ZoneMetadata + def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[ZoneMetadata, _Mapping]] = ...) -> None: ... + AVAILABLE_ZONES_FIELD_NUMBER: _ClassVar[int] + available_zones: _containers.MessageMap[str, ZoneMetadata] + def __init__(self, available_zones: _Optional[_Mapping[str, ZoneMetadata]] = ...) -> None: ... + +class ZoneMetadata(_message.Message): + __slots__ = () + def __init__(self) -> None: ... + +class TlsCertificate(_message.Message): + __slots__ = ("serial_number", "cert", "create_time", "expire_time", "sha1_fingerprint") + SERIAL_NUMBER_FIELD_NUMBER: _ClassVar[int] + CERT_FIELD_NUMBER: _ClassVar[int] + CREATE_TIME_FIELD_NUMBER: _ClassVar[int] + EXPIRE_TIME_FIELD_NUMBER: _ClassVar[int] + SHA1_FINGERPRINT_FIELD_NUMBER: _ClassVar[int] + serial_number: str + cert: str + create_time: _timestamp_pb2.Timestamp + expire_time: _timestamp_pb2.Timestamp + sha1_fingerprint: str + def __init__(self, serial_number: _Optional[str] = ..., cert: _Optional[str] = ..., create_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., expire_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., sha1_fingerprint: _Optional[str] = ...) -> None: ... diff --git a/tests/integration/goldens/redis/samples/generated_samples/snippet_metadata_google.cloud.redis.v1.json b/tests/integration/goldens/redis/samples/generated_samples/snippet_metadata_google.cloud.redis.v1.json index 174d9dff49..55235c1449 100755 --- a/tests/integration/goldens/redis/samples/generated_samples/snippet_metadata_google.cloud.redis.v1.json +++ b/tests/integration/goldens/redis/samples/generated_samples/snippet_metadata_google.cloud.redis.v1.json @@ -31,7 +31,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.CreateInstanceRequest" + "type": "google.cloud.redis_v1.types.CreateInstanceRequest_pb2" }, { "name": "parent", @@ -43,7 +43,7 @@ }, { "name": "instance", - "type": "google.cloud.redis_v1.types.Instance" + "type": "google.cloud.redis_v1.types.Instance_pb2" }, { "name": "retry", @@ -119,7 +119,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.CreateInstanceRequest" + "type": "google.cloud.redis_v1.types.CreateInstanceRequest_pb2" }, { "name": "parent", @@ -131,7 +131,7 @@ }, { "name": "instance", - "type": "google.cloud.redis_v1.types.Instance" + "type": "google.cloud.redis_v1.types.Instance_pb2" }, { "name": "retry", @@ -208,7 +208,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.DeleteInstanceRequest" + "type": "google.cloud.redis_v1.types.DeleteInstanceRequest_pb2" }, { "name": "name", @@ -288,7 +288,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.DeleteInstanceRequest" + "type": "google.cloud.redis_v1.types.DeleteInstanceRequest_pb2" }, { "name": "name", @@ -369,7 +369,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.ExportInstanceRequest" + "type": "google.cloud.redis_v1.types.ExportInstanceRequest_pb2" }, { "name": "name", @@ -377,7 +377,7 @@ }, { "name": "output_config", - "type": "google.cloud.redis_v1.types.OutputConfig" + "type": "google.cloud.redis_v1.types.OutputConfig_pb2" }, { "name": "retry", @@ -453,7 +453,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.ExportInstanceRequest" + "type": "google.cloud.redis_v1.types.ExportInstanceRequest_pb2" }, { "name": "name", @@ -461,7 +461,7 @@ }, { "name": "output_config", - "type": "google.cloud.redis_v1.types.OutputConfig" + "type": "google.cloud.redis_v1.types.OutputConfig_pb2" }, { "name": "retry", @@ -538,7 +538,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.FailoverInstanceRequest" + "type": "google.cloud.redis_v1.types.FailoverInstanceRequest_pb2" }, { "name": "name", @@ -546,7 +546,7 @@ }, { "name": "data_protection_mode", - "type": "google.cloud.redis_v1.types.FailoverInstanceRequest.DataProtectionMode" + "type": "google.cloud.redis_v1.types.FailoverInstanceRequest.DataProtectionMode_pb2" }, { "name": "retry", @@ -622,7 +622,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.FailoverInstanceRequest" + "type": "google.cloud.redis_v1.types.FailoverInstanceRequest_pb2" }, { "name": "name", @@ -630,7 +630,7 @@ }, { "name": "data_protection_mode", - "type": "google.cloud.redis_v1.types.FailoverInstanceRequest.DataProtectionMode" + "type": "google.cloud.redis_v1.types.FailoverInstanceRequest.DataProtectionMode_pb2" }, { "name": "retry", @@ -707,7 +707,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.GetInstanceAuthStringRequest" + "type": "google.cloud.redis_v1.types.GetInstanceAuthStringRequest_pb2" }, { "name": "name", @@ -726,7 +726,7 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.redis_v1.types.InstanceAuthString", + "resultType": "google.cloud.redis_v1.types.InstanceAuthString_pb2", "shortName": "get_instance_auth_string" }, "description": "Sample for GetInstanceAuthString", @@ -787,7 +787,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.GetInstanceAuthStringRequest" + "type": "google.cloud.redis_v1.types.GetInstanceAuthStringRequest_pb2" }, { "name": "name", @@ -806,7 +806,7 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.redis_v1.types.InstanceAuthString", + "resultType": "google.cloud.redis_v1.types.InstanceAuthString_pb2", "shortName": "get_instance_auth_string" }, "description": "Sample for GetInstanceAuthString", @@ -868,7 +868,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.GetInstanceRequest" + "type": "google.cloud.redis_v1.types.GetInstanceRequest_pb2" }, { "name": "name", @@ -887,7 +887,7 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.redis_v1.types.Instance", + "resultType": "google.cloud.redis_v1.types.Instance_pb2", "shortName": "get_instance" }, "description": "Sample for GetInstance", @@ -948,7 +948,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.GetInstanceRequest" + "type": "google.cloud.redis_v1.types.GetInstanceRequest_pb2" }, { "name": "name", @@ -967,7 +967,7 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.redis_v1.types.Instance", + "resultType": "google.cloud.redis_v1.types.Instance_pb2", "shortName": "get_instance" }, "description": "Sample for GetInstance", @@ -1029,7 +1029,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.ImportInstanceRequest" + "type": "google.cloud.redis_v1.types.ImportInstanceRequest_pb2" }, { "name": "name", @@ -1037,7 +1037,7 @@ }, { "name": "input_config", - "type": "google.cloud.redis_v1.types.InputConfig" + "type": "google.cloud.redis_v1.types.InputConfig_pb2" }, { "name": "retry", @@ -1113,7 +1113,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.ImportInstanceRequest" + "type": "google.cloud.redis_v1.types.ImportInstanceRequest_pb2" }, { "name": "name", @@ -1121,7 +1121,7 @@ }, { "name": "input_config", - "type": "google.cloud.redis_v1.types.InputConfig" + "type": "google.cloud.redis_v1.types.InputConfig_pb2" }, { "name": "retry", @@ -1198,7 +1198,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.ListInstancesRequest" + "type": "google.cloud.redis_v1.types.ListInstancesRequest_pb2" }, { "name": "parent", @@ -1278,7 +1278,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.ListInstancesRequest" + "type": "google.cloud.redis_v1.types.ListInstancesRequest_pb2" }, { "name": "parent", @@ -1359,7 +1359,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.RescheduleMaintenanceRequest" + "type": "google.cloud.redis_v1.types.RescheduleMaintenanceRequest_pb2" }, { "name": "name", @@ -1367,7 +1367,7 @@ }, { "name": "reschedule_type", - "type": "google.cloud.redis_v1.types.RescheduleMaintenanceRequest.RescheduleType" + "type": "google.cloud.redis_v1.types.RescheduleMaintenanceRequest.RescheduleType_pb2" }, { "name": "schedule_time", @@ -1447,7 +1447,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.RescheduleMaintenanceRequest" + "type": "google.cloud.redis_v1.types.RescheduleMaintenanceRequest_pb2" }, { "name": "name", @@ -1455,7 +1455,7 @@ }, { "name": "reschedule_type", - "type": "google.cloud.redis_v1.types.RescheduleMaintenanceRequest.RescheduleType" + "type": "google.cloud.redis_v1.types.RescheduleMaintenanceRequest.RescheduleType_pb2" }, { "name": "schedule_time", @@ -1536,7 +1536,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.UpdateInstanceRequest" + "type": "google.cloud.redis_v1.types.UpdateInstanceRequest_pb2" }, { "name": "update_mask", @@ -1544,7 +1544,7 @@ }, { "name": "instance", - "type": "google.cloud.redis_v1.types.Instance" + "type": "google.cloud.redis_v1.types.Instance_pb2" }, { "name": "retry", @@ -1620,7 +1620,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.UpdateInstanceRequest" + "type": "google.cloud.redis_v1.types.UpdateInstanceRequest_pb2" }, { "name": "update_mask", @@ -1628,7 +1628,7 @@ }, { "name": "instance", - "type": "google.cloud.redis_v1.types.Instance" + "type": "google.cloud.redis_v1.types.Instance_pb2" }, { "name": "retry", @@ -1705,7 +1705,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.UpgradeInstanceRequest" + "type": "google.cloud.redis_v1.types.UpgradeInstanceRequest_pb2" }, { "name": "name", @@ -1789,7 +1789,7 @@ "parameters": [ { "name": "request", - "type": "google.cloud.redis_v1.types.UpgradeInstanceRequest" + "type": "google.cloud.redis_v1.types.UpgradeInstanceRequest_pb2" }, { "name": "name", diff --git a/tests/integration/goldens/redis/tests/unit/gapic/redis_v1/test_cloud_redis.py b/tests/integration/goldens/redis/tests/unit/gapic/redis_v1/test_cloud_redis.py index 3b867230b7..3eea91e00f 100755 --- a/tests/integration/goldens/redis/tests/unit/gapic/redis_v1/test_cloud_redis.py +++ b/tests/integration/goldens/redis/tests/unit/gapic/redis_v1/test_cloud_redis.py @@ -67,7 +67,7 @@ from google.cloud.redis_v1.services.cloud_redis import CloudRedisClient from google.cloud.redis_v1.services.cloud_redis import pagers from google.cloud.redis_v1.services.cloud_redis import transports -from google.cloud.redis_v1.types import cloud_redis +from google.cloud.redis_v1.types import cloud_redis_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account from google.protobuf import duration_pb2 # type: ignore @@ -736,7 +736,7 @@ def test_cloud_redis_client_create_channel_credentials_file(client_class, transp @pytest.mark.parametrize("request_type", [ - cloud_redis.ListInstancesRequest, + cloud_redis_pb2.ListInstancesRequest, dict, ]) def test_list_instances(request_type, transport: str = 'grpc'): @@ -754,7 +754,7 @@ def test_list_instances(request_type, transport: str = 'grpc'): type(client.transport.list_instances), '__call__') as call: # Designate an appropriate return value for the call. - call.return_value = cloud_redis.ListInstancesResponse( + call.return_value = cloud_redis_pb2.ListInstancesResponse( next_page_token='next_page_token_value', unreachable=['unreachable_value'], ) @@ -763,7 +763,7 @@ def test_list_instances(request_type, transport: str = 'grpc'): # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = cloud_redis.ListInstancesRequest() + request = cloud_redis_pb2.ListInstancesRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -783,7 +783,7 @@ def test_list_instances_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = cloud_redis.ListInstancesRequest( + request = cloud_redis_pb2.ListInstancesRequest( parent='parent_value', page_token='page_token_value', ) @@ -796,7 +796,7 @@ def test_list_instances_non_empty_request_with_auto_populated_field(): client.list_instances(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloud_redis.ListInstancesRequest( + assert args[0] == cloud_redis_pb2.ListInstancesRequest( parent='parent_value', page_token='page_token_value', ) @@ -868,7 +868,7 @@ async def test_list_instances_async_use_cached_wrapped_rpc(transport: str = "grp assert mock_rpc.call_count == 2 @pytest.mark.asyncio -async def test_list_instances_async(transport: str = 'grpc_asyncio', request_type=cloud_redis.ListInstancesRequest): +async def test_list_instances_async(transport: str = 'grpc_asyncio', request_type=cloud_redis_pb2.ListInstancesRequest): client = CloudRedisAsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -883,7 +883,7 @@ async def test_list_instances_async(transport: str = 'grpc_asyncio', request_typ type(client.transport.list_instances), '__call__') as call: # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis.ListInstancesResponse( + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis_pb2.ListInstancesResponse( next_page_token='next_page_token_value', unreachable=['unreachable_value'], )) @@ -892,7 +892,7 @@ async def test_list_instances_async(transport: str = 'grpc_asyncio', request_typ # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = cloud_redis.ListInstancesRequest() + request = cloud_redis_pb2.ListInstancesRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -912,7 +912,7 @@ def test_list_instances_field_headers(): # 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.ListInstancesRequest() + request = cloud_redis_pb2.ListInstancesRequest() request.parent = 'parent_value' @@ -920,7 +920,7 @@ def test_list_instances_field_headers(): with mock.patch.object( type(client.transport.list_instances), '__call__') as call: - call.return_value = cloud_redis.ListInstancesResponse() + call.return_value = cloud_redis_pb2.ListInstancesResponse() client.list_instances(request) # Establish that the underlying gRPC stub method was called. @@ -944,7 +944,7 @@ async def test_list_instances_field_headers_async(): # 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.ListInstancesRequest() + request = cloud_redis_pb2.ListInstancesRequest() request.parent = 'parent_value' @@ -952,7 +952,7 @@ async def test_list_instances_field_headers_async(): with mock.patch.object( type(client.transport.list_instances), '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis.ListInstancesResponse()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis_pb2.ListInstancesResponse()) await client.list_instances(request) # Establish that the underlying gRPC stub method was called. @@ -978,7 +978,7 @@ def test_list_instances_flattened(): type(client.transport.list_instances), '__call__') as call: # Designate an appropriate return value for the call. - call.return_value = cloud_redis.ListInstancesResponse() + call.return_value = cloud_redis_pb2.ListInstancesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_instances( @@ -1003,7 +1003,7 @@ def test_list_instances_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.list_instances( - cloud_redis.ListInstancesRequest(), + cloud_redis_pb2.ListInstancesRequest(), parent='parent_value', ) @@ -1018,9 +1018,9 @@ async def test_list_instances_flattened_async(): type(client.transport.list_instances), '__call__') as call: # Designate an appropriate return value for the call. - call.return_value = cloud_redis.ListInstancesResponse() + call.return_value = cloud_redis_pb2.ListInstancesResponse() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis.ListInstancesResponse()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis_pb2.ListInstancesResponse()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.list_instances( @@ -1045,7 +1045,7 @@ async def test_list_instances_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_instances( - cloud_redis.ListInstancesRequest(), + cloud_redis_pb2.ListInstancesRequest(), parent='parent_value', ) @@ -1062,28 +1062,28 @@ def test_list_instances_pager(transport_name: str = "grpc"): '__call__') as call: # Set the response to a series of pages. call.side_effect = ( - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[ - cloud_redis.Instance(), - cloud_redis.Instance(), - cloud_redis.Instance(), + cloud_redis_pb2.Instance(), + cloud_redis_pb2.Instance(), + cloud_redis_pb2.Instance(), ], next_page_token='abc', ), - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[], next_page_token='def', ), - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[ - cloud_redis.Instance(), + cloud_redis_pb2.Instance(), ], next_page_token='ghi', ), - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[ - cloud_redis.Instance(), - cloud_redis.Instance(), + cloud_redis_pb2.Instance(), + cloud_redis_pb2.Instance(), ], ), RuntimeError, @@ -1105,7 +1105,7 @@ def test_list_instances_pager(transport_name: str = "grpc"): results = list(pager) assert len(results) == 6 - assert all(isinstance(i, cloud_redis.Instance) + assert all(isinstance(i, cloud_redis_pb2.Instance) for i in results) def test_list_instances_pages(transport_name: str = "grpc"): client = CloudRedisClient( @@ -1119,28 +1119,28 @@ def test_list_instances_pages(transport_name: str = "grpc"): '__call__') as call: # Set the response to a series of pages. call.side_effect = ( - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[ - cloud_redis.Instance(), - cloud_redis.Instance(), - cloud_redis.Instance(), + cloud_redis_pb2.Instance(), + cloud_redis_pb2.Instance(), + cloud_redis_pb2.Instance(), ], next_page_token='abc', ), - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[], next_page_token='def', ), - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[ - cloud_redis.Instance(), + cloud_redis_pb2.Instance(), ], next_page_token='ghi', ), - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[ - cloud_redis.Instance(), - cloud_redis.Instance(), + cloud_redis_pb2.Instance(), + cloud_redis_pb2.Instance(), ], ), RuntimeError, @@ -1161,28 +1161,28 @@ async def test_list_instances_async_pager(): '__call__', new_callable=mock.AsyncMock) as call: # Set the response to a series of pages. call.side_effect = ( - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[ - cloud_redis.Instance(), - cloud_redis.Instance(), - cloud_redis.Instance(), + cloud_redis_pb2.Instance(), + cloud_redis_pb2.Instance(), + cloud_redis_pb2.Instance(), ], next_page_token='abc', ), - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[], next_page_token='def', ), - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[ - cloud_redis.Instance(), + cloud_redis_pb2.Instance(), ], next_page_token='ghi', ), - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[ - cloud_redis.Instance(), - cloud_redis.Instance(), + cloud_redis_pb2.Instance(), + cloud_redis_pb2.Instance(), ], ), RuntimeError, @@ -1194,7 +1194,7 @@ async def test_list_instances_async_pager(): responses.append(response) assert len(responses) == 6 - assert all(isinstance(i, cloud_redis.Instance) + assert all(isinstance(i, cloud_redis_pb2.Instance) for i in responses) @@ -1210,28 +1210,28 @@ async def test_list_instances_async_pages(): '__call__', new_callable=mock.AsyncMock) as call: # Set the response to a series of pages. call.side_effect = ( - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[ - cloud_redis.Instance(), - cloud_redis.Instance(), - cloud_redis.Instance(), + cloud_redis_pb2.Instance(), + cloud_redis_pb2.Instance(), + cloud_redis_pb2.Instance(), ], next_page_token='abc', ), - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[], next_page_token='def', ), - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[ - cloud_redis.Instance(), + cloud_redis_pb2.Instance(), ], next_page_token='ghi', ), - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[ - cloud_redis.Instance(), - cloud_redis.Instance(), + cloud_redis_pb2.Instance(), + cloud_redis_pb2.Instance(), ], ), RuntimeError, @@ -1247,7 +1247,7 @@ async def test_list_instances_async_pages(): assert page_.raw_page.next_page_token == token @pytest.mark.parametrize("request_type", [ - cloud_redis.GetInstanceRequest, + cloud_redis_pb2.GetInstanceRequest, dict, ]) def test_get_instance(request_type, transport: str = 'grpc'): @@ -1265,7 +1265,7 @@ def test_get_instance(request_type, transport: str = 'grpc'): type(client.transport.get_instance), '__call__') as call: # Designate an appropriate return value for the call. - call.return_value = cloud_redis.Instance( + call.return_value = cloud_redis_pb2.Instance( name='name_value', display_name='display_name_value', location_id='location_id_value', @@ -1276,21 +1276,21 @@ def test_get_instance(request_type, transport: str = 'grpc'): host='host_value', port=453, current_location_id='current_location_id_value', - state=cloud_redis.Instance.State.CREATING, + state=cloud_redis_pb2.Instance.State.CREATING, status_message='status_message_value', - tier=cloud_redis.Instance.Tier.BASIC, + tier=cloud_redis_pb2.Instance.Tier.BASIC, memory_size_gb=1499, authorized_network='authorized_network_value', persistence_iam_identity='persistence_iam_identity_value', - connect_mode=cloud_redis.Instance.ConnectMode.DIRECT_PEERING, + connect_mode=cloud_redis_pb2.Instance.ConnectMode.DIRECT_PEERING, auth_enabled=True, - transit_encryption_mode=cloud_redis.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION, + transit_encryption_mode=cloud_redis_pb2.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION, replica_count=1384, read_endpoint='read_endpoint_value', read_endpoint_port=1920, - read_replicas_mode=cloud_redis.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED, + read_replicas_mode=cloud_redis_pb2.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED, customer_managed_key='customer_managed_key_value', - suspension_reasons=[cloud_redis.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE], + suspension_reasons=[cloud_redis_pb2.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE], maintenance_version='maintenance_version_value', available_maintenance_versions=['available_maintenance_versions_value'], ) @@ -1299,11 +1299,11 @@ def test_get_instance(request_type, transport: str = 'grpc'): # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = cloud_redis.GetInstanceRequest() + request = cloud_redis_pb2.GetInstanceRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, cloud_redis.Instance) + assert isinstance(response, cloud_redis_pb2.Instance) assert response.name == 'name_value' assert response.display_name == 'display_name_value' assert response.location_id == 'location_id_value' @@ -1314,21 +1314,21 @@ def test_get_instance(request_type, transport: str = 'grpc'): assert response.host == 'host_value' assert response.port == 453 assert response.current_location_id == 'current_location_id_value' - assert response.state == cloud_redis.Instance.State.CREATING + assert response.state == cloud_redis_pb2.Instance.State.CREATING assert response.status_message == 'status_message_value' - assert response.tier == cloud_redis.Instance.Tier.BASIC + assert response.tier == cloud_redis_pb2.Instance.Tier.BASIC assert response.memory_size_gb == 1499 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.connect_mode == cloud_redis_pb2.Instance.ConnectMode.DIRECT_PEERING assert response.auth_enabled is True - assert response.transit_encryption_mode == cloud_redis.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION + assert response.transit_encryption_mode == cloud_redis_pb2.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION assert response.replica_count == 1384 assert response.read_endpoint == 'read_endpoint_value' assert response.read_endpoint_port == 1920 - assert response.read_replicas_mode == cloud_redis.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED + assert response.read_replicas_mode == cloud_redis_pb2.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED assert response.customer_managed_key == 'customer_managed_key_value' - assert response.suspension_reasons == [cloud_redis.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE] + assert response.suspension_reasons == [cloud_redis_pb2.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE] assert response.maintenance_version == 'maintenance_version_value' assert response.available_maintenance_versions == ['available_maintenance_versions_value'] @@ -1344,7 +1344,7 @@ def test_get_instance_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = cloud_redis.GetInstanceRequest( + request = cloud_redis_pb2.GetInstanceRequest( name='name_value', ) @@ -1356,7 +1356,7 @@ def test_get_instance_non_empty_request_with_auto_populated_field(): client.get_instance(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloud_redis.GetInstanceRequest( + assert args[0] == cloud_redis_pb2.GetInstanceRequest( name='name_value', ) @@ -1427,7 +1427,7 @@ async def test_get_instance_async_use_cached_wrapped_rpc(transport: str = "grpc_ assert mock_rpc.call_count == 2 @pytest.mark.asyncio -async def test_get_instance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis.GetInstanceRequest): +async def test_get_instance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis_pb2.GetInstanceRequest): client = CloudRedisAsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -1442,7 +1442,7 @@ async def test_get_instance_async(transport: str = 'grpc_asyncio', request_type= type(client.transport.get_instance), '__call__') as call: # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis.Instance( + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis_pb2.Instance( name='name_value', display_name='display_name_value', location_id='location_id_value', @@ -1453,21 +1453,21 @@ async def test_get_instance_async(transport: str = 'grpc_asyncio', request_type= host='host_value', port=453, current_location_id='current_location_id_value', - state=cloud_redis.Instance.State.CREATING, + state=cloud_redis_pb2.Instance.State.CREATING, status_message='status_message_value', - tier=cloud_redis.Instance.Tier.BASIC, + tier=cloud_redis_pb2.Instance.Tier.BASIC, memory_size_gb=1499, authorized_network='authorized_network_value', persistence_iam_identity='persistence_iam_identity_value', - connect_mode=cloud_redis.Instance.ConnectMode.DIRECT_PEERING, + connect_mode=cloud_redis_pb2.Instance.ConnectMode.DIRECT_PEERING, auth_enabled=True, - transit_encryption_mode=cloud_redis.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION, + transit_encryption_mode=cloud_redis_pb2.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION, replica_count=1384, read_endpoint='read_endpoint_value', read_endpoint_port=1920, - read_replicas_mode=cloud_redis.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED, + read_replicas_mode=cloud_redis_pb2.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED, customer_managed_key='customer_managed_key_value', - suspension_reasons=[cloud_redis.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE], + suspension_reasons=[cloud_redis_pb2.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE], maintenance_version='maintenance_version_value', available_maintenance_versions=['available_maintenance_versions_value'], )) @@ -1476,11 +1476,11 @@ async def test_get_instance_async(transport: str = 'grpc_asyncio', request_type= # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = cloud_redis.GetInstanceRequest() + request = cloud_redis_pb2.GetInstanceRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, cloud_redis.Instance) + assert isinstance(response, cloud_redis_pb2.Instance) assert response.name == 'name_value' assert response.display_name == 'display_name_value' assert response.location_id == 'location_id_value' @@ -1491,21 +1491,21 @@ async def test_get_instance_async(transport: str = 'grpc_asyncio', request_type= assert response.host == 'host_value' assert response.port == 453 assert response.current_location_id == 'current_location_id_value' - assert response.state == cloud_redis.Instance.State.CREATING + assert response.state == cloud_redis_pb2.Instance.State.CREATING assert response.status_message == 'status_message_value' - assert response.tier == cloud_redis.Instance.Tier.BASIC + assert response.tier == cloud_redis_pb2.Instance.Tier.BASIC assert response.memory_size_gb == 1499 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.connect_mode == cloud_redis_pb2.Instance.ConnectMode.DIRECT_PEERING assert response.auth_enabled is True - assert response.transit_encryption_mode == cloud_redis.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION + assert response.transit_encryption_mode == cloud_redis_pb2.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION assert response.replica_count == 1384 assert response.read_endpoint == 'read_endpoint_value' assert response.read_endpoint_port == 1920 - assert response.read_replicas_mode == cloud_redis.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED + assert response.read_replicas_mode == cloud_redis_pb2.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED assert response.customer_managed_key == 'customer_managed_key_value' - assert response.suspension_reasons == [cloud_redis.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE] + assert response.suspension_reasons == [cloud_redis_pb2.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE] assert response.maintenance_version == 'maintenance_version_value' assert response.available_maintenance_versions == ['available_maintenance_versions_value'] @@ -1521,7 +1521,7 @@ def test_get_instance_field_headers(): # 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.GetInstanceRequest() + request = cloud_redis_pb2.GetInstanceRequest() request.name = 'name_value' @@ -1529,7 +1529,7 @@ def test_get_instance_field_headers(): with mock.patch.object( type(client.transport.get_instance), '__call__') as call: - call.return_value = cloud_redis.Instance() + call.return_value = cloud_redis_pb2.Instance() client.get_instance(request) # Establish that the underlying gRPC stub method was called. @@ -1553,7 +1553,7 @@ async def test_get_instance_field_headers_async(): # 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.GetInstanceRequest() + request = cloud_redis_pb2.GetInstanceRequest() request.name = 'name_value' @@ -1561,7 +1561,7 @@ async def test_get_instance_field_headers_async(): with mock.patch.object( type(client.transport.get_instance), '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis.Instance()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis_pb2.Instance()) await client.get_instance(request) # Establish that the underlying gRPC stub method was called. @@ -1587,7 +1587,7 @@ def test_get_instance_flattened(): type(client.transport.get_instance), '__call__') as call: # Designate an appropriate return value for the call. - call.return_value = cloud_redis.Instance() + call.return_value = cloud_redis_pb2.Instance() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_instance( @@ -1612,7 +1612,7 @@ def test_get_instance_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.get_instance( - cloud_redis.GetInstanceRequest(), + cloud_redis_pb2.GetInstanceRequest(), name='name_value', ) @@ -1627,9 +1627,9 @@ async def test_get_instance_flattened_async(): type(client.transport.get_instance), '__call__') as call: # Designate an appropriate return value for the call. - call.return_value = cloud_redis.Instance() + call.return_value = cloud_redis_pb2.Instance() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis.Instance()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis_pb2.Instance()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.get_instance( @@ -1654,13 +1654,13 @@ async def test_get_instance_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_instance( - cloud_redis.GetInstanceRequest(), + cloud_redis_pb2.GetInstanceRequest(), name='name_value', ) @pytest.mark.parametrize("request_type", [ - cloud_redis.GetInstanceAuthStringRequest, + cloud_redis_pb2.GetInstanceAuthStringRequest, dict, ]) def test_get_instance_auth_string(request_type, transport: str = 'grpc'): @@ -1678,7 +1678,7 @@ def test_get_instance_auth_string(request_type, transport: str = 'grpc'): 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 = cloud_redis_pb2.InstanceAuthString( auth_string='auth_string_value', ) response = client.get_instance_auth_string(request) @@ -1686,11 +1686,11 @@ def test_get_instance_auth_string(request_type, transport: str = 'grpc'): # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = cloud_redis.GetInstanceAuthStringRequest() + request = cloud_redis_pb2.GetInstanceAuthStringRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, cloud_redis.InstanceAuthString) + assert isinstance(response, cloud_redis_pb2.InstanceAuthString) assert response.auth_string == 'auth_string_value' @@ -1705,7 +1705,7 @@ def test_get_instance_auth_string_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = cloud_redis.GetInstanceAuthStringRequest( + request = cloud_redis_pb2.GetInstanceAuthStringRequest( name='name_value', ) @@ -1717,7 +1717,7 @@ def test_get_instance_auth_string_non_empty_request_with_auto_populated_field(): client.get_instance_auth_string(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloud_redis.GetInstanceAuthStringRequest( + assert args[0] == cloud_redis_pb2.GetInstanceAuthStringRequest( name='name_value', ) @@ -1788,7 +1788,7 @@ async def test_get_instance_auth_string_async_use_cached_wrapped_rpc(transport: assert mock_rpc.call_count == 2 @pytest.mark.asyncio -async def test_get_instance_auth_string_async(transport: str = 'grpc_asyncio', request_type=cloud_redis.GetInstanceAuthStringRequest): +async def test_get_instance_auth_string_async(transport: str = 'grpc_asyncio', request_type=cloud_redis_pb2.GetInstanceAuthStringRequest): client = CloudRedisAsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -1803,7 +1803,7 @@ async def test_get_instance_auth_string_async(transport: str = 'grpc_asyncio', r 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( + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis_pb2.InstanceAuthString( auth_string='auth_string_value', )) response = await client.get_instance_auth_string(request) @@ -1811,11 +1811,11 @@ async def test_get_instance_auth_string_async(transport: str = 'grpc_asyncio', r # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = cloud_redis.GetInstanceAuthStringRequest() + request = cloud_redis_pb2.GetInstanceAuthStringRequest() assert args[0] == request # Establish that the response is the type that we expect. - assert isinstance(response, cloud_redis.InstanceAuthString) + assert isinstance(response, cloud_redis_pb2.InstanceAuthString) assert response.auth_string == 'auth_string_value' @@ -1830,7 +1830,7 @@ def test_get_instance_auth_string_field_headers(): # 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 = cloud_redis_pb2.GetInstanceAuthStringRequest() request.name = 'name_value' @@ -1838,7 +1838,7 @@ def test_get_instance_auth_string_field_headers(): with mock.patch.object( type(client.transport.get_instance_auth_string), '__call__') as call: - call.return_value = cloud_redis.InstanceAuthString() + call.return_value = cloud_redis_pb2.InstanceAuthString() client.get_instance_auth_string(request) # Establish that the underlying gRPC stub method was called. @@ -1862,7 +1862,7 @@ async def test_get_instance_auth_string_field_headers_async(): # 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 = cloud_redis_pb2.GetInstanceAuthStringRequest() request.name = 'name_value' @@ -1870,7 +1870,7 @@ async def test_get_instance_auth_string_field_headers_async(): with mock.patch.object( type(client.transport.get_instance_auth_string), '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis.InstanceAuthString()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis_pb2.InstanceAuthString()) await client.get_instance_auth_string(request) # Establish that the underlying gRPC stub method was called. @@ -1896,7 +1896,7 @@ def test_get_instance_auth_string_flattened(): 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 = cloud_redis_pb2.InstanceAuthString() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_instance_auth_string( @@ -1921,7 +1921,7 @@ def test_get_instance_auth_string_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.get_instance_auth_string( - cloud_redis.GetInstanceAuthStringRequest(), + cloud_redis_pb2.GetInstanceAuthStringRequest(), name='name_value', ) @@ -1936,9 +1936,9 @@ async def test_get_instance_auth_string_flattened_async(): 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 = cloud_redis_pb2.InstanceAuthString() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis.InstanceAuthString()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis_pb2.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( @@ -1963,13 +1963,13 @@ async def test_get_instance_auth_string_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_instance_auth_string( - cloud_redis.GetInstanceAuthStringRequest(), + cloud_redis_pb2.GetInstanceAuthStringRequest(), name='name_value', ) @pytest.mark.parametrize("request_type", [ - cloud_redis.CreateInstanceRequest, + cloud_redis_pb2.CreateInstanceRequest, dict, ]) def test_create_instance(request_type, transport: str = 'grpc'): @@ -1993,7 +1993,7 @@ def test_create_instance(request_type, transport: str = 'grpc'): # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = cloud_redis.CreateInstanceRequest() + request = cloud_redis_pb2.CreateInstanceRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -2011,7 +2011,7 @@ def test_create_instance_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = cloud_redis.CreateInstanceRequest( + request = cloud_redis_pb2.CreateInstanceRequest( parent='parent_value', instance_id='instance_id_value', ) @@ -2024,7 +2024,7 @@ def test_create_instance_non_empty_request_with_auto_populated_field(): client.create_instance(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloud_redis.CreateInstanceRequest( + assert args[0] == cloud_redis_pb2.CreateInstanceRequest( parent='parent_value', instance_id='instance_id_value', ) @@ -2106,7 +2106,7 @@ async def test_create_instance_async_use_cached_wrapped_rpc(transport: str = "gr assert mock_rpc.call_count == 2 @pytest.mark.asyncio -async def test_create_instance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis.CreateInstanceRequest): +async def test_create_instance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis_pb2.CreateInstanceRequest): client = CloudRedisAsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -2129,7 +2129,7 @@ async def test_create_instance_async(transport: str = 'grpc_asyncio', request_ty # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = cloud_redis.CreateInstanceRequest() + request = cloud_redis_pb2.CreateInstanceRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -2147,7 +2147,7 @@ def test_create_instance_field_headers(): # 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.CreateInstanceRequest() + request = cloud_redis_pb2.CreateInstanceRequest() request.parent = 'parent_value' @@ -2179,7 +2179,7 @@ async def test_create_instance_field_headers_async(): # 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.CreateInstanceRequest() + request = cloud_redis_pb2.CreateInstanceRequest() request.parent = 'parent_value' @@ -2219,7 +2219,7 @@ def test_create_instance_flattened(): client.create_instance( parent='parent_value', instance_id='instance_id_value', - instance=cloud_redis.Instance(name='name_value'), + instance=cloud_redis_pb2.Instance(name='name_value'), ) # Establish that the underlying call was made with the expected @@ -2233,7 +2233,7 @@ def test_create_instance_flattened(): mock_val = 'instance_id_value' assert arg == mock_val arg = args[0].instance - mock_val = cloud_redis.Instance(name='name_value') + mock_val = cloud_redis_pb2.Instance(name='name_value') assert arg == mock_val @@ -2246,10 +2246,10 @@ def test_create_instance_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.create_instance( - cloud_redis.CreateInstanceRequest(), + cloud_redis_pb2.CreateInstanceRequest(), parent='parent_value', instance_id='instance_id_value', - instance=cloud_redis.Instance(name='name_value'), + instance=cloud_redis_pb2.Instance(name='name_value'), ) @pytest.mark.asyncio @@ -2273,7 +2273,7 @@ async def test_create_instance_flattened_async(): response = await client.create_instance( parent='parent_value', instance_id='instance_id_value', - instance=cloud_redis.Instance(name='name_value'), + instance=cloud_redis_pb2.Instance(name='name_value'), ) # Establish that the underlying call was made with the expected @@ -2287,7 +2287,7 @@ async def test_create_instance_flattened_async(): mock_val = 'instance_id_value' assert arg == mock_val arg = args[0].instance - mock_val = cloud_redis.Instance(name='name_value') + mock_val = cloud_redis_pb2.Instance(name='name_value') assert arg == mock_val @pytest.mark.asyncio @@ -2300,15 +2300,15 @@ async def test_create_instance_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.create_instance( - cloud_redis.CreateInstanceRequest(), + cloud_redis_pb2.CreateInstanceRequest(), parent='parent_value', instance_id='instance_id_value', - instance=cloud_redis.Instance(name='name_value'), + instance=cloud_redis_pb2.Instance(name='name_value'), ) @pytest.mark.parametrize("request_type", [ - cloud_redis.UpdateInstanceRequest, + cloud_redis_pb2.UpdateInstanceRequest, dict, ]) def test_update_instance(request_type, transport: str = 'grpc'): @@ -2332,7 +2332,7 @@ def test_update_instance(request_type, transport: str = 'grpc'): # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = cloud_redis.UpdateInstanceRequest() + request = cloud_redis_pb2.UpdateInstanceRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -2350,7 +2350,7 @@ def test_update_instance_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = cloud_redis.UpdateInstanceRequest( + request = cloud_redis_pb2.UpdateInstanceRequest( ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2361,7 +2361,7 @@ def test_update_instance_non_empty_request_with_auto_populated_field(): client.update_instance(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloud_redis.UpdateInstanceRequest( + assert args[0] == cloud_redis_pb2.UpdateInstanceRequest( ) def test_update_instance_use_cached_wrapped_rpc(): @@ -2441,7 +2441,7 @@ async def test_update_instance_async_use_cached_wrapped_rpc(transport: str = "gr assert mock_rpc.call_count == 2 @pytest.mark.asyncio -async def test_update_instance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis.UpdateInstanceRequest): +async def test_update_instance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis_pb2.UpdateInstanceRequest): client = CloudRedisAsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -2464,7 +2464,7 @@ async def test_update_instance_async(transport: str = 'grpc_asyncio', request_ty # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = cloud_redis.UpdateInstanceRequest() + request = cloud_redis_pb2.UpdateInstanceRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -2482,7 +2482,7 @@ def test_update_instance_field_headers(): # 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.UpdateInstanceRequest() + request = cloud_redis_pb2.UpdateInstanceRequest() request.instance.name = 'name_value' @@ -2514,7 +2514,7 @@ async def test_update_instance_field_headers_async(): # 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.UpdateInstanceRequest() + request = cloud_redis_pb2.UpdateInstanceRequest() request.instance.name = 'name_value' @@ -2553,7 +2553,7 @@ def test_update_instance_flattened(): # using the keyword arguments to the method. client.update_instance( update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - instance=cloud_redis.Instance(name='name_value'), + instance=cloud_redis_pb2.Instance(name='name_value'), ) # Establish that the underlying call was made with the expected @@ -2564,7 +2564,7 @@ def test_update_instance_flattened(): 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') + mock_val = cloud_redis_pb2.Instance(name='name_value') assert arg == mock_val @@ -2577,9 +2577,9 @@ def test_update_instance_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.update_instance( - cloud_redis.UpdateInstanceRequest(), + cloud_redis_pb2.UpdateInstanceRequest(), update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - instance=cloud_redis.Instance(name='name_value'), + instance=cloud_redis_pb2.Instance(name='name_value'), ) @pytest.mark.asyncio @@ -2602,7 +2602,7 @@ async def test_update_instance_flattened_async(): # using the keyword arguments to the method. response = await client.update_instance( update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - instance=cloud_redis.Instance(name='name_value'), + instance=cloud_redis_pb2.Instance(name='name_value'), ) # Establish that the underlying call was made with the expected @@ -2613,7 +2613,7 @@ async def test_update_instance_flattened_async(): 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') + mock_val = cloud_redis_pb2.Instance(name='name_value') assert arg == mock_val @pytest.mark.asyncio @@ -2626,14 +2626,14 @@ async def test_update_instance_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.update_instance( - cloud_redis.UpdateInstanceRequest(), + cloud_redis_pb2.UpdateInstanceRequest(), update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - instance=cloud_redis.Instance(name='name_value'), + instance=cloud_redis_pb2.Instance(name='name_value'), ) @pytest.mark.parametrize("request_type", [ - cloud_redis.UpgradeInstanceRequest, + cloud_redis_pb2.UpgradeInstanceRequest, dict, ]) def test_upgrade_instance(request_type, transport: str = 'grpc'): @@ -2657,7 +2657,7 @@ def test_upgrade_instance(request_type, transport: str = 'grpc'): # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = cloud_redis.UpgradeInstanceRequest() + request = cloud_redis_pb2.UpgradeInstanceRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -2675,7 +2675,7 @@ def test_upgrade_instance_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = cloud_redis.UpgradeInstanceRequest( + request = cloud_redis_pb2.UpgradeInstanceRequest( name='name_value', redis_version='redis_version_value', ) @@ -2688,7 +2688,7 @@ def test_upgrade_instance_non_empty_request_with_auto_populated_field(): client.upgrade_instance(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloud_redis.UpgradeInstanceRequest( + assert args[0] == cloud_redis_pb2.UpgradeInstanceRequest( name='name_value', redis_version='redis_version_value', ) @@ -2770,7 +2770,7 @@ async def test_upgrade_instance_async_use_cached_wrapped_rpc(transport: str = "g assert mock_rpc.call_count == 2 @pytest.mark.asyncio -async def test_upgrade_instance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis.UpgradeInstanceRequest): +async def test_upgrade_instance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis_pb2.UpgradeInstanceRequest): client = CloudRedisAsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -2793,7 +2793,7 @@ async def test_upgrade_instance_async(transport: str = 'grpc_asyncio', request_t # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = cloud_redis.UpgradeInstanceRequest() + request = cloud_redis_pb2.UpgradeInstanceRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -2811,7 +2811,7 @@ def test_upgrade_instance_field_headers(): # 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.UpgradeInstanceRequest() + request = cloud_redis_pb2.UpgradeInstanceRequest() request.name = 'name_value' @@ -2843,7 +2843,7 @@ async def test_upgrade_instance_field_headers_async(): # 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.UpgradeInstanceRequest() + request = cloud_redis_pb2.UpgradeInstanceRequest() request.name = 'name_value' @@ -2906,7 +2906,7 @@ def test_upgrade_instance_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.upgrade_instance( - cloud_redis.UpgradeInstanceRequest(), + cloud_redis_pb2.UpgradeInstanceRequest(), name='name_value', redis_version='redis_version_value', ) @@ -2955,14 +2955,14 @@ async def test_upgrade_instance_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.upgrade_instance( - cloud_redis.UpgradeInstanceRequest(), + cloud_redis_pb2.UpgradeInstanceRequest(), name='name_value', redis_version='redis_version_value', ) @pytest.mark.parametrize("request_type", [ - cloud_redis.ImportInstanceRequest, + cloud_redis_pb2.ImportInstanceRequest, dict, ]) def test_import_instance(request_type, transport: str = 'grpc'): @@ -2986,7 +2986,7 @@ def test_import_instance(request_type, transport: str = 'grpc'): # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = cloud_redis.ImportInstanceRequest() + request = cloud_redis_pb2.ImportInstanceRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -3004,7 +3004,7 @@ def test_import_instance_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = cloud_redis.ImportInstanceRequest( + request = cloud_redis_pb2.ImportInstanceRequest( name='name_value', ) @@ -3016,7 +3016,7 @@ def test_import_instance_non_empty_request_with_auto_populated_field(): client.import_instance(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloud_redis.ImportInstanceRequest( + assert args[0] == cloud_redis_pb2.ImportInstanceRequest( name='name_value', ) @@ -3097,7 +3097,7 @@ async def test_import_instance_async_use_cached_wrapped_rpc(transport: str = "gr assert mock_rpc.call_count == 2 @pytest.mark.asyncio -async def test_import_instance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis.ImportInstanceRequest): +async def test_import_instance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis_pb2.ImportInstanceRequest): client = CloudRedisAsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -3120,7 +3120,7 @@ async def test_import_instance_async(transport: str = 'grpc_asyncio', request_ty # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = cloud_redis.ImportInstanceRequest() + request = cloud_redis_pb2.ImportInstanceRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -3138,7 +3138,7 @@ def test_import_instance_field_headers(): # 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.ImportInstanceRequest() + request = cloud_redis_pb2.ImportInstanceRequest() request.name = 'name_value' @@ -3170,7 +3170,7 @@ async def test_import_instance_field_headers_async(): # 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.ImportInstanceRequest() + request = cloud_redis_pb2.ImportInstanceRequest() request.name = 'name_value' @@ -3209,7 +3209,7 @@ def test_import_instance_flattened(): # using the keyword arguments to the method. client.import_instance( name='name_value', - input_config=cloud_redis.InputConfig(gcs_source=cloud_redis.GcsSource(uri='uri_value')), + input_config=cloud_redis_pb2.InputConfig(gcs_source=cloud_redis_pb2.GcsSource(uri='uri_value')), ) # Establish that the underlying call was made with the expected @@ -3220,7 +3220,7 @@ def test_import_instance_flattened(): 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')) + mock_val = cloud_redis_pb2.InputConfig(gcs_source=cloud_redis_pb2.GcsSource(uri='uri_value')) assert arg == mock_val @@ -3233,9 +3233,9 @@ def test_import_instance_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.import_instance( - cloud_redis.ImportInstanceRequest(), + cloud_redis_pb2.ImportInstanceRequest(), name='name_value', - input_config=cloud_redis.InputConfig(gcs_source=cloud_redis.GcsSource(uri='uri_value')), + input_config=cloud_redis_pb2.InputConfig(gcs_source=cloud_redis_pb2.GcsSource(uri='uri_value')), ) @pytest.mark.asyncio @@ -3258,7 +3258,7 @@ async def test_import_instance_flattened_async(): # using the keyword arguments to the method. response = await client.import_instance( name='name_value', - input_config=cloud_redis.InputConfig(gcs_source=cloud_redis.GcsSource(uri='uri_value')), + input_config=cloud_redis_pb2.InputConfig(gcs_source=cloud_redis_pb2.GcsSource(uri='uri_value')), ) # Establish that the underlying call was made with the expected @@ -3269,7 +3269,7 @@ async def test_import_instance_flattened_async(): 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')) + mock_val = cloud_redis_pb2.InputConfig(gcs_source=cloud_redis_pb2.GcsSource(uri='uri_value')) assert arg == mock_val @pytest.mark.asyncio @@ -3282,14 +3282,14 @@ async def test_import_instance_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.import_instance( - cloud_redis.ImportInstanceRequest(), + cloud_redis_pb2.ImportInstanceRequest(), name='name_value', - input_config=cloud_redis.InputConfig(gcs_source=cloud_redis.GcsSource(uri='uri_value')), + input_config=cloud_redis_pb2.InputConfig(gcs_source=cloud_redis_pb2.GcsSource(uri='uri_value')), ) @pytest.mark.parametrize("request_type", [ - cloud_redis.ExportInstanceRequest, + cloud_redis_pb2.ExportInstanceRequest, dict, ]) def test_export_instance(request_type, transport: str = 'grpc'): @@ -3313,7 +3313,7 @@ def test_export_instance(request_type, transport: str = 'grpc'): # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = cloud_redis.ExportInstanceRequest() + request = cloud_redis_pb2.ExportInstanceRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -3331,7 +3331,7 @@ def test_export_instance_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = cloud_redis.ExportInstanceRequest( + request = cloud_redis_pb2.ExportInstanceRequest( name='name_value', ) @@ -3343,7 +3343,7 @@ def test_export_instance_non_empty_request_with_auto_populated_field(): client.export_instance(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloud_redis.ExportInstanceRequest( + assert args[0] == cloud_redis_pb2.ExportInstanceRequest( name='name_value', ) @@ -3424,7 +3424,7 @@ async def test_export_instance_async_use_cached_wrapped_rpc(transport: str = "gr assert mock_rpc.call_count == 2 @pytest.mark.asyncio -async def test_export_instance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis.ExportInstanceRequest): +async def test_export_instance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis_pb2.ExportInstanceRequest): client = CloudRedisAsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -3447,7 +3447,7 @@ async def test_export_instance_async(transport: str = 'grpc_asyncio', request_ty # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = cloud_redis.ExportInstanceRequest() + request = cloud_redis_pb2.ExportInstanceRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -3465,7 +3465,7 @@ def test_export_instance_field_headers(): # 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.ExportInstanceRequest() + request = cloud_redis_pb2.ExportInstanceRequest() request.name = 'name_value' @@ -3497,7 +3497,7 @@ async def test_export_instance_field_headers_async(): # 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.ExportInstanceRequest() + request = cloud_redis_pb2.ExportInstanceRequest() request.name = 'name_value' @@ -3536,7 +3536,7 @@ def test_export_instance_flattened(): # using the keyword arguments to the method. client.export_instance( name='name_value', - output_config=cloud_redis.OutputConfig(gcs_destination=cloud_redis.GcsDestination(uri='uri_value')), + output_config=cloud_redis_pb2.OutputConfig(gcs_destination=cloud_redis_pb2.GcsDestination(uri='uri_value')), ) # Establish that the underlying call was made with the expected @@ -3547,7 +3547,7 @@ def test_export_instance_flattened(): 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')) + mock_val = cloud_redis_pb2.OutputConfig(gcs_destination=cloud_redis_pb2.GcsDestination(uri='uri_value')) assert arg == mock_val @@ -3560,9 +3560,9 @@ def test_export_instance_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.export_instance( - cloud_redis.ExportInstanceRequest(), + cloud_redis_pb2.ExportInstanceRequest(), name='name_value', - output_config=cloud_redis.OutputConfig(gcs_destination=cloud_redis.GcsDestination(uri='uri_value')), + output_config=cloud_redis_pb2.OutputConfig(gcs_destination=cloud_redis_pb2.GcsDestination(uri='uri_value')), ) @pytest.mark.asyncio @@ -3585,7 +3585,7 @@ async def test_export_instance_flattened_async(): # using the keyword arguments to the method. response = await client.export_instance( name='name_value', - output_config=cloud_redis.OutputConfig(gcs_destination=cloud_redis.GcsDestination(uri='uri_value')), + output_config=cloud_redis_pb2.OutputConfig(gcs_destination=cloud_redis_pb2.GcsDestination(uri='uri_value')), ) # Establish that the underlying call was made with the expected @@ -3596,7 +3596,7 @@ async def test_export_instance_flattened_async(): 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')) + mock_val = cloud_redis_pb2.OutputConfig(gcs_destination=cloud_redis_pb2.GcsDestination(uri='uri_value')) assert arg == mock_val @pytest.mark.asyncio @@ -3609,14 +3609,14 @@ async def test_export_instance_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.export_instance( - cloud_redis.ExportInstanceRequest(), + cloud_redis_pb2.ExportInstanceRequest(), name='name_value', - output_config=cloud_redis.OutputConfig(gcs_destination=cloud_redis.GcsDestination(uri='uri_value')), + output_config=cloud_redis_pb2.OutputConfig(gcs_destination=cloud_redis_pb2.GcsDestination(uri='uri_value')), ) @pytest.mark.parametrize("request_type", [ - cloud_redis.FailoverInstanceRequest, + cloud_redis_pb2.FailoverInstanceRequest, dict, ]) def test_failover_instance(request_type, transport: str = 'grpc'): @@ -3640,7 +3640,7 @@ def test_failover_instance(request_type, transport: str = 'grpc'): # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = cloud_redis.FailoverInstanceRequest() + request = cloud_redis_pb2.FailoverInstanceRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -3658,7 +3658,7 @@ def test_failover_instance_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = cloud_redis.FailoverInstanceRequest( + request = cloud_redis_pb2.FailoverInstanceRequest( name='name_value', ) @@ -3670,7 +3670,7 @@ def test_failover_instance_non_empty_request_with_auto_populated_field(): client.failover_instance(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloud_redis.FailoverInstanceRequest( + assert args[0] == cloud_redis_pb2.FailoverInstanceRequest( name='name_value', ) @@ -3751,7 +3751,7 @@ async def test_failover_instance_async_use_cached_wrapped_rpc(transport: str = " assert mock_rpc.call_count == 2 @pytest.mark.asyncio -async def test_failover_instance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis.FailoverInstanceRequest): +async def test_failover_instance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis_pb2.FailoverInstanceRequest): client = CloudRedisAsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -3774,7 +3774,7 @@ async def test_failover_instance_async(transport: str = 'grpc_asyncio', request_ # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = cloud_redis.FailoverInstanceRequest() + request = cloud_redis_pb2.FailoverInstanceRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -3792,7 +3792,7 @@ def test_failover_instance_field_headers(): # 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.FailoverInstanceRequest() + request = cloud_redis_pb2.FailoverInstanceRequest() request.name = 'name_value' @@ -3824,7 +3824,7 @@ async def test_failover_instance_field_headers_async(): # 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.FailoverInstanceRequest() + request = cloud_redis_pb2.FailoverInstanceRequest() request.name = 'name_value' @@ -3863,7 +3863,7 @@ def test_failover_instance_flattened(): # using the keyword arguments to the method. client.failover_instance( name='name_value', - data_protection_mode=cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS, + data_protection_mode=cloud_redis_pb2.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS, ) # Establish that the underlying call was made with the expected @@ -3874,7 +3874,7 @@ def test_failover_instance_flattened(): mock_val = 'name_value' assert arg == mock_val arg = args[0].data_protection_mode - mock_val = cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS + mock_val = cloud_redis_pb2.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS assert arg == mock_val @@ -3887,9 +3887,9 @@ def test_failover_instance_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.failover_instance( - cloud_redis.FailoverInstanceRequest(), + cloud_redis_pb2.FailoverInstanceRequest(), name='name_value', - data_protection_mode=cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS, + data_protection_mode=cloud_redis_pb2.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS, ) @pytest.mark.asyncio @@ -3912,7 +3912,7 @@ async def test_failover_instance_flattened_async(): # using the keyword arguments to the method. response = await client.failover_instance( name='name_value', - data_protection_mode=cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS, + data_protection_mode=cloud_redis_pb2.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS, ) # Establish that the underlying call was made with the expected @@ -3923,7 +3923,7 @@ async def test_failover_instance_flattened_async(): mock_val = 'name_value' assert arg == mock_val arg = args[0].data_protection_mode - mock_val = cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS + mock_val = cloud_redis_pb2.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS assert arg == mock_val @pytest.mark.asyncio @@ -3936,14 +3936,14 @@ async def test_failover_instance_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.failover_instance( - cloud_redis.FailoverInstanceRequest(), + cloud_redis_pb2.FailoverInstanceRequest(), name='name_value', - data_protection_mode=cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS, + data_protection_mode=cloud_redis_pb2.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS, ) @pytest.mark.parametrize("request_type", [ - cloud_redis.DeleteInstanceRequest, + cloud_redis_pb2.DeleteInstanceRequest, dict, ]) def test_delete_instance(request_type, transport: str = 'grpc'): @@ -3967,7 +3967,7 @@ def test_delete_instance(request_type, transport: str = 'grpc'): # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = cloud_redis.DeleteInstanceRequest() + request = cloud_redis_pb2.DeleteInstanceRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -3985,7 +3985,7 @@ def test_delete_instance_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = cloud_redis.DeleteInstanceRequest( + request = cloud_redis_pb2.DeleteInstanceRequest( name='name_value', ) @@ -3997,7 +3997,7 @@ def test_delete_instance_non_empty_request_with_auto_populated_field(): client.delete_instance(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloud_redis.DeleteInstanceRequest( + assert args[0] == cloud_redis_pb2.DeleteInstanceRequest( name='name_value', ) @@ -4078,7 +4078,7 @@ async def test_delete_instance_async_use_cached_wrapped_rpc(transport: str = "gr assert mock_rpc.call_count == 2 @pytest.mark.asyncio -async def test_delete_instance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis.DeleteInstanceRequest): +async def test_delete_instance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis_pb2.DeleteInstanceRequest): client = CloudRedisAsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -4101,7 +4101,7 @@ async def test_delete_instance_async(transport: str = 'grpc_asyncio', request_ty # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = cloud_redis.DeleteInstanceRequest() + request = cloud_redis_pb2.DeleteInstanceRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -4119,7 +4119,7 @@ def test_delete_instance_field_headers(): # 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.DeleteInstanceRequest() + request = cloud_redis_pb2.DeleteInstanceRequest() request.name = 'name_value' @@ -4151,7 +4151,7 @@ async def test_delete_instance_field_headers_async(): # 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.DeleteInstanceRequest() + request = cloud_redis_pb2.DeleteInstanceRequest() request.name = 'name_value' @@ -4210,7 +4210,7 @@ def test_delete_instance_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.delete_instance( - cloud_redis.DeleteInstanceRequest(), + cloud_redis_pb2.DeleteInstanceRequest(), name='name_value', ) @@ -4254,13 +4254,13 @@ async def test_delete_instance_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.delete_instance( - cloud_redis.DeleteInstanceRequest(), + cloud_redis_pb2.DeleteInstanceRequest(), name='name_value', ) @pytest.mark.parametrize("request_type", [ - cloud_redis.RescheduleMaintenanceRequest, + cloud_redis_pb2.RescheduleMaintenanceRequest, dict, ]) def test_reschedule_maintenance(request_type, transport: str = 'grpc'): @@ -4284,7 +4284,7 @@ def test_reschedule_maintenance(request_type, transport: str = 'grpc'): # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - request = cloud_redis.RescheduleMaintenanceRequest() + request = cloud_redis_pb2.RescheduleMaintenanceRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -4302,7 +4302,7 @@ def test_reschedule_maintenance_non_empty_request_with_auto_populated_field(): # Populate all string fields in the request which are not UUID4 # since we want to check that UUID4 are populated automatically # if they meet the requirements of AIP 4235. - request = cloud_redis.RescheduleMaintenanceRequest( + request = cloud_redis_pb2.RescheduleMaintenanceRequest( name='name_value', ) @@ -4314,7 +4314,7 @@ def test_reschedule_maintenance_non_empty_request_with_auto_populated_field(): client.reschedule_maintenance(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloud_redis.RescheduleMaintenanceRequest( + assert args[0] == cloud_redis_pb2.RescheduleMaintenanceRequest( name='name_value', ) @@ -4395,7 +4395,7 @@ async def test_reschedule_maintenance_async_use_cached_wrapped_rpc(transport: st assert mock_rpc.call_count == 2 @pytest.mark.asyncio -async def test_reschedule_maintenance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis.RescheduleMaintenanceRequest): +async def test_reschedule_maintenance_async(transport: str = 'grpc_asyncio', request_type=cloud_redis_pb2.RescheduleMaintenanceRequest): client = CloudRedisAsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -4418,7 +4418,7 @@ async def test_reschedule_maintenance_async(transport: str = 'grpc_asyncio', req # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - request = cloud_redis.RescheduleMaintenanceRequest() + request = cloud_redis_pb2.RescheduleMaintenanceRequest() assert args[0] == request # Establish that the response is the type that we expect. @@ -4436,7 +4436,7 @@ def test_reschedule_maintenance_field_headers(): # 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 = cloud_redis_pb2.RescheduleMaintenanceRequest() request.name = 'name_value' @@ -4468,7 +4468,7 @@ async def test_reschedule_maintenance_field_headers_async(): # 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 = cloud_redis_pb2.RescheduleMaintenanceRequest() request.name = 'name_value' @@ -4507,7 +4507,7 @@ def test_reschedule_maintenance_flattened(): # using the keyword arguments to the method. client.reschedule_maintenance( name='name_value', - reschedule_type=cloud_redis.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE, + reschedule_type=cloud_redis_pb2.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE, schedule_time=timestamp_pb2.Timestamp(seconds=751), ) @@ -4519,7 +4519,7 @@ def test_reschedule_maintenance_flattened(): mock_val = 'name_value' assert arg == mock_val arg = args[0].reschedule_type - mock_val = cloud_redis.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE + mock_val = cloud_redis_pb2.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE assert arg == mock_val assert TimestampRule().to_proto(args[0].schedule_time) == timestamp_pb2.Timestamp(seconds=751) @@ -4533,9 +4533,9 @@ def test_reschedule_maintenance_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.reschedule_maintenance( - cloud_redis.RescheduleMaintenanceRequest(), + cloud_redis_pb2.RescheduleMaintenanceRequest(), name='name_value', - reschedule_type=cloud_redis.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE, + reschedule_type=cloud_redis_pb2.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE, schedule_time=timestamp_pb2.Timestamp(seconds=751), ) @@ -4559,7 +4559,7 @@ async def test_reschedule_maintenance_flattened_async(): # using the keyword arguments to the method. response = await client.reschedule_maintenance( name='name_value', - reschedule_type=cloud_redis.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE, + reschedule_type=cloud_redis_pb2.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE, schedule_time=timestamp_pb2.Timestamp(seconds=751), ) @@ -4571,7 +4571,7 @@ async def test_reschedule_maintenance_flattened_async(): mock_val = 'name_value' assert arg == mock_val arg = args[0].reschedule_type - mock_val = cloud_redis.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE + mock_val = cloud_redis_pb2.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE assert arg == mock_val assert TimestampRule().to_proto(args[0].schedule_time) == timestamp_pb2.Timestamp(seconds=751) @@ -4585,9 +4585,9 @@ async def test_reschedule_maintenance_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.reschedule_maintenance( - cloud_redis.RescheduleMaintenanceRequest(), + cloud_redis_pb2.RescheduleMaintenanceRequest(), name='name_value', - reschedule_type=cloud_redis.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE, + reschedule_type=cloud_redis_pb2.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE, schedule_time=timestamp_pb2.Timestamp(seconds=751), ) @@ -4626,13 +4626,13 @@ def test_list_instances_rest_use_cached_wrapped_rpc(): assert mock_rpc.call_count == 2 -def test_list_instances_rest_required_fields(request_type=cloud_redis.ListInstancesRequest): +def test_list_instances_rest_required_fields(request_type=cloud_redis_pb2.ListInstancesRequest): transport_class = transports.CloudRedisRestTransport request_init = {} request_init["parent"] = "" request = request_type(**request_init) - pb_request = request_type.pb(request) + pb_request = request jsonified_request = json.loads(json_format.MessageToJson( pb_request, use_integers_for_enums=False @@ -4663,7 +4663,7 @@ def test_list_instances_rest_required_fields(request_type=cloud_redis.ListInstan request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = cloud_redis.ListInstancesResponse() + return_value = cloud_redis_pb2.ListInstancesResponse() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, 'request') as req: # We need to mock transcode() because providing default values @@ -4672,7 +4672,7 @@ def test_list_instances_rest_required_fields(request_type=cloud_redis.ListInstan with mock.patch.object(path_template, 'transcode') as transcode: # A uri without fields and an empty body will force all the # request fields to show up in the query_params. - pb_request = request_type.pb(request) + pb_request = request transcode_result = { 'uri': 'v1/sample_method', 'method': "get", @@ -4683,8 +4683,6 @@ def test_list_instances_rest_required_fields(request_type=cloud_redis.ListInstan response_value = Response() response_value.status_code = 200 - # Convert return value to protobuf type - return_value = cloud_redis.ListInstancesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode('UTF-8') @@ -4714,7 +4712,7 @@ def test_list_instances_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), 'request') as req: # Designate an appropriate value for the returned response. - return_value = cloud_redis.ListInstancesResponse() + return_value = cloud_redis_pb2.ListInstancesResponse() # get arguments that satisfy an http rule for this method sample_request = {'parent': 'projects/sample1/locations/sample2'} @@ -4728,8 +4726,6 @@ def test_list_instances_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - # Convert return value to protobuf type - return_value = cloud_redis.ListInstancesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode('UTF-8') req.return_value = response_value @@ -4753,7 +4749,7 @@ def test_list_instances_rest_flattened_error(transport: str = 'rest'): # fields is an error. with pytest.raises(ValueError): client.list_instances( - cloud_redis.ListInstancesRequest(), + cloud_redis_pb2.ListInstancesRequest(), parent='parent_value', ) @@ -4770,28 +4766,28 @@ def test_list_instances_rest_pager(transport: str = 'rest'): #with mock.patch.object(path_template, 'transcode') as transcode: # Set the response as a series of pages response = ( - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[ - cloud_redis.Instance(), - cloud_redis.Instance(), - cloud_redis.Instance(), + cloud_redis_pb2.Instance(), + cloud_redis_pb2.Instance(), + cloud_redis_pb2.Instance(), ], next_page_token='abc', ), - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[], next_page_token='def', ), - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[ - cloud_redis.Instance(), + cloud_redis_pb2.Instance(), ], next_page_token='ghi', ), - cloud_redis.ListInstancesResponse( + cloud_redis_pb2.ListInstancesResponse( instances=[ - cloud_redis.Instance(), - cloud_redis.Instance(), + cloud_redis_pb2.Instance(), + cloud_redis_pb2.Instance(), ], ), ) @@ -4799,7 +4795,7 @@ def test_list_instances_rest_pager(transport: str = 'rest'): response = response + response # Wrap the values into proper Response objs - response = tuple(cloud_redis.ListInstancesResponse.to_json(x) for x in response) + response = tuple(cloud_redis_pb2.ListInstancesResponse.to_json(x) for x in response) return_values = tuple(Response() for i in response) for return_val, response_val in zip(return_values, response): return_val._content = response_val.encode('UTF-8') @@ -4812,7 +4808,7 @@ def test_list_instances_rest_pager(transport: str = 'rest'): results = list(pager) assert len(results) == 6 - assert all(isinstance(i, cloud_redis.Instance) + assert all(isinstance(i, cloud_redis_pb2.Instance) for i in results) pages = list(client.list_instances(request=sample_request).pages) @@ -4854,13 +4850,13 @@ def test_get_instance_rest_use_cached_wrapped_rpc(): assert mock_rpc.call_count == 2 -def test_get_instance_rest_required_fields(request_type=cloud_redis.GetInstanceRequest): +def test_get_instance_rest_required_fields(request_type=cloud_redis_pb2.GetInstanceRequest): transport_class = transports.CloudRedisRestTransport request_init = {} request_init["name"] = "" request = request_type(**request_init) - pb_request = request_type.pb(request) + pb_request = request jsonified_request = json.loads(json_format.MessageToJson( pb_request, use_integers_for_enums=False @@ -4889,7 +4885,7 @@ def test_get_instance_rest_required_fields(request_type=cloud_redis.GetInstanceR request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = cloud_redis.Instance() + return_value = cloud_redis_pb2.Instance() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, 'request') as req: # We need to mock transcode() because providing default values @@ -4898,7 +4894,7 @@ def test_get_instance_rest_required_fields(request_type=cloud_redis.GetInstanceR with mock.patch.object(path_template, 'transcode') as transcode: # A uri without fields and an empty body will force all the # request fields to show up in the query_params. - pb_request = request_type.pb(request) + pb_request = request transcode_result = { 'uri': 'v1/sample_method', 'method': "get", @@ -4909,8 +4905,6 @@ def test_get_instance_rest_required_fields(request_type=cloud_redis.GetInstanceR response_value = Response() response_value.status_code = 200 - # Convert return value to protobuf type - return_value = cloud_redis.Instance.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode('UTF-8') @@ -4940,7 +4934,7 @@ def test_get_instance_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), 'request') as req: # Designate an appropriate value for the returned response. - return_value = cloud_redis.Instance() + return_value = cloud_redis_pb2.Instance() # get arguments that satisfy an http rule for this method sample_request = {'name': 'projects/sample1/locations/sample2/instances/sample3'} @@ -4954,8 +4948,6 @@ def test_get_instance_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - # Convert return value to protobuf type - return_value = cloud_redis.Instance.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode('UTF-8') req.return_value = response_value @@ -4979,7 +4971,7 @@ def test_get_instance_rest_flattened_error(transport: str = 'rest'): # fields is an error. with pytest.raises(ValueError): client.get_instance( - cloud_redis.GetInstanceRequest(), + cloud_redis_pb2.GetInstanceRequest(), name='name_value', ) @@ -5018,13 +5010,13 @@ def test_get_instance_auth_string_rest_use_cached_wrapped_rpc(): assert mock_rpc.call_count == 2 -def test_get_instance_auth_string_rest_required_fields(request_type=cloud_redis.GetInstanceAuthStringRequest): +def test_get_instance_auth_string_rest_required_fields(request_type=cloud_redis_pb2.GetInstanceAuthStringRequest): transport_class = transports.CloudRedisRestTransport request_init = {} request_init["name"] = "" request = request_type(**request_init) - pb_request = request_type.pb(request) + pb_request = request jsonified_request = json.loads(json_format.MessageToJson( pb_request, use_integers_for_enums=False @@ -5053,7 +5045,7 @@ def test_get_instance_auth_string_rest_required_fields(request_type=cloud_redis. request = request_type(**request_init) # Designate an appropriate value for the returned response. - return_value = cloud_redis.InstanceAuthString() + return_value = cloud_redis_pb2.InstanceAuthString() # Mock the http request call within the method and fake a response. with mock.patch.object(Session, 'request') as req: # We need to mock transcode() because providing default values @@ -5062,7 +5054,7 @@ def test_get_instance_auth_string_rest_required_fields(request_type=cloud_redis. with mock.patch.object(path_template, 'transcode') as transcode: # A uri without fields and an empty body will force all the # request fields to show up in the query_params. - pb_request = request_type.pb(request) + pb_request = request transcode_result = { 'uri': 'v1/sample_method', 'method': "get", @@ -5073,8 +5065,6 @@ def test_get_instance_auth_string_rest_required_fields(request_type=cloud_redis. response_value = Response() response_value.status_code = 200 - # Convert return value to protobuf type - return_value = cloud_redis.InstanceAuthString.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode('UTF-8') @@ -5104,7 +5094,7 @@ def test_get_instance_auth_string_rest_flattened(): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), 'request') as req: # Designate an appropriate value for the returned response. - return_value = cloud_redis.InstanceAuthString() + return_value = cloud_redis_pb2.InstanceAuthString() # get arguments that satisfy an http rule for this method sample_request = {'name': 'projects/sample1/locations/sample2/instances/sample3'} @@ -5118,8 +5108,6 @@ def test_get_instance_auth_string_rest_flattened(): # Wrap the value into a proper Response obj response_value = Response() response_value.status_code = 200 - # Convert return value to protobuf type - return_value = cloud_redis.InstanceAuthString.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode('UTF-8') req.return_value = response_value @@ -5143,7 +5131,7 @@ def test_get_instance_auth_string_rest_flattened_error(transport: str = 'rest'): # fields is an error. with pytest.raises(ValueError): client.get_instance_auth_string( - cloud_redis.GetInstanceAuthStringRequest(), + cloud_redis_pb2.GetInstanceAuthStringRequest(), name='name_value', ) @@ -5186,14 +5174,14 @@ def test_create_instance_rest_use_cached_wrapped_rpc(): assert mock_rpc.call_count == 2 -def test_create_instance_rest_required_fields(request_type=cloud_redis.CreateInstanceRequest): +def test_create_instance_rest_required_fields(request_type=cloud_redis_pb2.CreateInstanceRequest): transport_class = transports.CloudRedisRestTransport request_init = {} request_init["parent"] = "" request_init["instance_id"] = "" request = request_type(**request_init) - pb_request = request_type.pb(request) + pb_request = request jsonified_request = json.loads(json_format.MessageToJson( pb_request, use_integers_for_enums=False @@ -5239,7 +5227,7 @@ def test_create_instance_rest_required_fields(request_type=cloud_redis.CreateIns with mock.patch.object(path_template, 'transcode') as transcode: # A uri without fields and an empty body will force all the # request fields to show up in the query_params. - pb_request = request_type.pb(request) + pb_request = request transcode_result = { 'uri': 'v1/sample_method', 'method': "post", @@ -5292,7 +5280,7 @@ def test_create_instance_rest_flattened(): mock_args = dict( parent='parent_value', instance_id='instance_id_value', - instance=cloud_redis.Instance(name='name_value'), + instance=cloud_redis_pb2.Instance(name='name_value'), ) mock_args.update(sample_request) @@ -5322,10 +5310,10 @@ def test_create_instance_rest_flattened_error(transport: str = 'rest'): # fields is an error. with pytest.raises(ValueError): client.create_instance( - cloud_redis.CreateInstanceRequest(), + cloud_redis_pb2.CreateInstanceRequest(), parent='parent_value', instance_id='instance_id_value', - instance=cloud_redis.Instance(name='name_value'), + instance=cloud_redis_pb2.Instance(name='name_value'), ) @@ -5367,12 +5355,12 @@ def test_update_instance_rest_use_cached_wrapped_rpc(): assert mock_rpc.call_count == 2 -def test_update_instance_rest_required_fields(request_type=cloud_redis.UpdateInstanceRequest): +def test_update_instance_rest_required_fields(request_type=cloud_redis_pb2.UpdateInstanceRequest): transport_class = transports.CloudRedisRestTransport request_init = {} request = request_type(**request_init) - pb_request = request_type.pb(request) + pb_request = request jsonified_request = json.loads(json_format.MessageToJson( pb_request, use_integers_for_enums=False @@ -5408,7 +5396,7 @@ def test_update_instance_rest_required_fields(request_type=cloud_redis.UpdateIns with mock.patch.object(path_template, 'transcode') as transcode: # A uri without fields and an empty body will force all the # request fields to show up in the query_params. - pb_request = request_type.pb(request) + pb_request = request transcode_result = { 'uri': 'v1/sample_method', 'method': "patch", @@ -5456,7 +5444,7 @@ def test_update_instance_rest_flattened(): # get truthy value for each flattened field mock_args = dict( update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - instance=cloud_redis.Instance(name='name_value'), + instance=cloud_redis_pb2.Instance(name='name_value'), ) mock_args.update(sample_request) @@ -5486,9 +5474,9 @@ def test_update_instance_rest_flattened_error(transport: str = 'rest'): # fields is an error. with pytest.raises(ValueError): client.update_instance( - cloud_redis.UpdateInstanceRequest(), + cloud_redis_pb2.UpdateInstanceRequest(), update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - instance=cloud_redis.Instance(name='name_value'), + instance=cloud_redis_pb2.Instance(name='name_value'), ) @@ -5530,14 +5518,14 @@ def test_upgrade_instance_rest_use_cached_wrapped_rpc(): assert mock_rpc.call_count == 2 -def test_upgrade_instance_rest_required_fields(request_type=cloud_redis.UpgradeInstanceRequest): +def test_upgrade_instance_rest_required_fields(request_type=cloud_redis_pb2.UpgradeInstanceRequest): transport_class = transports.CloudRedisRestTransport request_init = {} request_init["name"] = "" request_init["redis_version"] = "" request = request_type(**request_init) - pb_request = request_type.pb(request) + pb_request = request jsonified_request = json.loads(json_format.MessageToJson( pb_request, use_integers_for_enums=False @@ -5578,7 +5566,7 @@ def test_upgrade_instance_rest_required_fields(request_type=cloud_redis.UpgradeI with mock.patch.object(path_template, 'transcode') as transcode: # A uri without fields and an empty body will force all the # request fields to show up in the query_params. - pb_request = request_type.pb(request) + pb_request = request transcode_result = { 'uri': 'v1/sample_method', 'method': "post", @@ -5656,7 +5644,7 @@ def test_upgrade_instance_rest_flattened_error(transport: str = 'rest'): # fields is an error. with pytest.raises(ValueError): client.upgrade_instance( - cloud_redis.UpgradeInstanceRequest(), + cloud_redis_pb2.UpgradeInstanceRequest(), name='name_value', redis_version='redis_version_value', ) @@ -5700,13 +5688,13 @@ def test_import_instance_rest_use_cached_wrapped_rpc(): assert mock_rpc.call_count == 2 -def test_import_instance_rest_required_fields(request_type=cloud_redis.ImportInstanceRequest): +def test_import_instance_rest_required_fields(request_type=cloud_redis_pb2.ImportInstanceRequest): transport_class = transports.CloudRedisRestTransport request_init = {} request_init["name"] = "" request = request_type(**request_init) - pb_request = request_type.pb(request) + pb_request = request jsonified_request = json.loads(json_format.MessageToJson( pb_request, use_integers_for_enums=False @@ -5744,7 +5732,7 @@ def test_import_instance_rest_required_fields(request_type=cloud_redis.ImportIns with mock.patch.object(path_template, 'transcode') as transcode: # A uri without fields and an empty body will force all the # request fields to show up in the query_params. - pb_request = request_type.pb(request) + pb_request = request transcode_result = { 'uri': 'v1/sample_method', 'method': "post", @@ -5792,7 +5780,7 @@ def test_import_instance_rest_flattened(): # get truthy value for each flattened field mock_args = dict( name='name_value', - input_config=cloud_redis.InputConfig(gcs_source=cloud_redis.GcsSource(uri='uri_value')), + input_config=cloud_redis_pb2.InputConfig(gcs_source=cloud_redis_pb2.GcsSource(uri='uri_value')), ) mock_args.update(sample_request) @@ -5822,9 +5810,9 @@ def test_import_instance_rest_flattened_error(transport: str = 'rest'): # fields is an error. with pytest.raises(ValueError): client.import_instance( - cloud_redis.ImportInstanceRequest(), + cloud_redis_pb2.ImportInstanceRequest(), name='name_value', - input_config=cloud_redis.InputConfig(gcs_source=cloud_redis.GcsSource(uri='uri_value')), + input_config=cloud_redis_pb2.InputConfig(gcs_source=cloud_redis_pb2.GcsSource(uri='uri_value')), ) @@ -5866,13 +5854,13 @@ def test_export_instance_rest_use_cached_wrapped_rpc(): assert mock_rpc.call_count == 2 -def test_export_instance_rest_required_fields(request_type=cloud_redis.ExportInstanceRequest): +def test_export_instance_rest_required_fields(request_type=cloud_redis_pb2.ExportInstanceRequest): transport_class = transports.CloudRedisRestTransport request_init = {} request_init["name"] = "" request = request_type(**request_init) - pb_request = request_type.pb(request) + pb_request = request jsonified_request = json.loads(json_format.MessageToJson( pb_request, use_integers_for_enums=False @@ -5910,7 +5898,7 @@ def test_export_instance_rest_required_fields(request_type=cloud_redis.ExportIns with mock.patch.object(path_template, 'transcode') as transcode: # A uri without fields and an empty body will force all the # request fields to show up in the query_params. - pb_request = request_type.pb(request) + pb_request = request transcode_result = { 'uri': 'v1/sample_method', 'method': "post", @@ -5958,7 +5946,7 @@ def test_export_instance_rest_flattened(): # get truthy value for each flattened field mock_args = dict( name='name_value', - output_config=cloud_redis.OutputConfig(gcs_destination=cloud_redis.GcsDestination(uri='uri_value')), + output_config=cloud_redis_pb2.OutputConfig(gcs_destination=cloud_redis_pb2.GcsDestination(uri='uri_value')), ) mock_args.update(sample_request) @@ -5988,9 +5976,9 @@ def test_export_instance_rest_flattened_error(transport: str = 'rest'): # fields is an error. with pytest.raises(ValueError): client.export_instance( - cloud_redis.ExportInstanceRequest(), + cloud_redis_pb2.ExportInstanceRequest(), name='name_value', - output_config=cloud_redis.OutputConfig(gcs_destination=cloud_redis.GcsDestination(uri='uri_value')), + output_config=cloud_redis_pb2.OutputConfig(gcs_destination=cloud_redis_pb2.GcsDestination(uri='uri_value')), ) @@ -6032,13 +6020,13 @@ def test_failover_instance_rest_use_cached_wrapped_rpc(): assert mock_rpc.call_count == 2 -def test_failover_instance_rest_required_fields(request_type=cloud_redis.FailoverInstanceRequest): +def test_failover_instance_rest_required_fields(request_type=cloud_redis_pb2.FailoverInstanceRequest): transport_class = transports.CloudRedisRestTransport request_init = {} request_init["name"] = "" request = request_type(**request_init) - pb_request = request_type.pb(request) + pb_request = request jsonified_request = json.loads(json_format.MessageToJson( pb_request, use_integers_for_enums=False @@ -6076,7 +6064,7 @@ def test_failover_instance_rest_required_fields(request_type=cloud_redis.Failove with mock.patch.object(path_template, 'transcode') as transcode: # A uri without fields and an empty body will force all the # request fields to show up in the query_params. - pb_request = request_type.pb(request) + pb_request = request transcode_result = { 'uri': 'v1/sample_method', 'method': "post", @@ -6124,7 +6112,7 @@ def test_failover_instance_rest_flattened(): # get truthy value for each flattened field mock_args = dict( name='name_value', - data_protection_mode=cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS, + data_protection_mode=cloud_redis_pb2.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS, ) mock_args.update(sample_request) @@ -6154,9 +6142,9 @@ def test_failover_instance_rest_flattened_error(transport: str = 'rest'): # fields is an error. with pytest.raises(ValueError): client.failover_instance( - cloud_redis.FailoverInstanceRequest(), + cloud_redis_pb2.FailoverInstanceRequest(), name='name_value', - data_protection_mode=cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS, + data_protection_mode=cloud_redis_pb2.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS, ) @@ -6198,13 +6186,13 @@ def test_delete_instance_rest_use_cached_wrapped_rpc(): assert mock_rpc.call_count == 2 -def test_delete_instance_rest_required_fields(request_type=cloud_redis.DeleteInstanceRequest): +def test_delete_instance_rest_required_fields(request_type=cloud_redis_pb2.DeleteInstanceRequest): transport_class = transports.CloudRedisRestTransport request_init = {} request_init["name"] = "" request = request_type(**request_init) - pb_request = request_type.pb(request) + pb_request = request jsonified_request = json.loads(json_format.MessageToJson( pb_request, use_integers_for_enums=False @@ -6242,7 +6230,7 @@ def test_delete_instance_rest_required_fields(request_type=cloud_redis.DeleteIns with mock.patch.object(path_template, 'transcode') as transcode: # A uri without fields and an empty body will force all the # request fields to show up in the query_params. - pb_request = request_type.pb(request) + pb_request = request transcode_result = { 'uri': 'v1/sample_method', 'method': "delete", @@ -6318,7 +6306,7 @@ def test_delete_instance_rest_flattened_error(transport: str = 'rest'): # fields is an error. with pytest.raises(ValueError): client.delete_instance( - cloud_redis.DeleteInstanceRequest(), + cloud_redis_pb2.DeleteInstanceRequest(), name='name_value', ) @@ -6361,13 +6349,13 @@ def test_reschedule_maintenance_rest_use_cached_wrapped_rpc(): assert mock_rpc.call_count == 2 -def test_reschedule_maintenance_rest_required_fields(request_type=cloud_redis.RescheduleMaintenanceRequest): +def test_reschedule_maintenance_rest_required_fields(request_type=cloud_redis_pb2.RescheduleMaintenanceRequest): transport_class = transports.CloudRedisRestTransport request_init = {} request_init["name"] = "" request = request_type(**request_init) - pb_request = request_type.pb(request) + pb_request = request jsonified_request = json.loads(json_format.MessageToJson( pb_request, use_integers_for_enums=False @@ -6405,7 +6393,7 @@ def test_reschedule_maintenance_rest_required_fields(request_type=cloud_redis.Re with mock.patch.object(path_template, 'transcode') as transcode: # A uri without fields and an empty body will force all the # request fields to show up in the query_params. - pb_request = request_type.pb(request) + pb_request = request transcode_result = { 'uri': 'v1/sample_method', 'method': "post", @@ -6453,7 +6441,7 @@ def test_reschedule_maintenance_rest_flattened(): # get truthy value for each flattened field mock_args = dict( name='name_value', - reschedule_type=cloud_redis.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE, + reschedule_type=cloud_redis_pb2.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE, schedule_time=timestamp_pb2.Timestamp(seconds=751), ) mock_args.update(sample_request) @@ -6484,9 +6472,9 @@ def test_reschedule_maintenance_rest_flattened_error(transport: str = 'rest'): # fields is an error. with pytest.raises(ValueError): client.reschedule_maintenance( - cloud_redis.RescheduleMaintenanceRequest(), + cloud_redis_pb2.RescheduleMaintenanceRequest(), name='name_value', - reschedule_type=cloud_redis.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE, + reschedule_type=cloud_redis_pb2.RescheduleMaintenanceRequest.RescheduleType.IMMEDIATE, schedule_time=timestamp_pb2.Timestamp(seconds=751), ) @@ -6605,13 +6593,13 @@ def test_list_instances_empty_call_grpc(): with mock.patch.object( type(client.transport.list_instances), '__call__') as call: - call.return_value = cloud_redis.ListInstancesResponse() + call.return_value = cloud_redis_pb2.ListInstancesResponse() client.list_instances(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.ListInstancesRequest() + request_msg = cloud_redis_pb2.ListInstancesRequest() assert args[0] == request_msg @@ -6628,13 +6616,13 @@ def test_get_instance_empty_call_grpc(): with mock.patch.object( type(client.transport.get_instance), '__call__') as call: - call.return_value = cloud_redis.Instance() + call.return_value = cloud_redis_pb2.Instance() client.get_instance(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.GetInstanceRequest() + request_msg = cloud_redis_pb2.GetInstanceRequest() assert args[0] == request_msg @@ -6651,13 +6639,13 @@ def test_get_instance_auth_string_empty_call_grpc(): with mock.patch.object( type(client.transport.get_instance_auth_string), '__call__') as call: - call.return_value = cloud_redis.InstanceAuthString() + call.return_value = cloud_redis_pb2.InstanceAuthString() client.get_instance_auth_string(request=None) # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.GetInstanceAuthStringRequest() + request_msg = cloud_redis_pb2.GetInstanceAuthStringRequest() assert args[0] == request_msg @@ -6680,7 +6668,7 @@ def test_create_instance_empty_call_grpc(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.CreateInstanceRequest() + request_msg = cloud_redis_pb2.CreateInstanceRequest() assert args[0] == request_msg @@ -6703,7 +6691,7 @@ def test_update_instance_empty_call_grpc(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.UpdateInstanceRequest() + request_msg = cloud_redis_pb2.UpdateInstanceRequest() assert args[0] == request_msg @@ -6726,7 +6714,7 @@ def test_upgrade_instance_empty_call_grpc(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.UpgradeInstanceRequest() + request_msg = cloud_redis_pb2.UpgradeInstanceRequest() assert args[0] == request_msg @@ -6749,7 +6737,7 @@ def test_import_instance_empty_call_grpc(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.ImportInstanceRequest() + request_msg = cloud_redis_pb2.ImportInstanceRequest() assert args[0] == request_msg @@ -6772,7 +6760,7 @@ def test_export_instance_empty_call_grpc(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.ExportInstanceRequest() + request_msg = cloud_redis_pb2.ExportInstanceRequest() assert args[0] == request_msg @@ -6795,7 +6783,7 @@ def test_failover_instance_empty_call_grpc(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.FailoverInstanceRequest() + request_msg = cloud_redis_pb2.FailoverInstanceRequest() assert args[0] == request_msg @@ -6818,7 +6806,7 @@ def test_delete_instance_empty_call_grpc(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.DeleteInstanceRequest() + request_msg = cloud_redis_pb2.DeleteInstanceRequest() assert args[0] == request_msg @@ -6841,7 +6829,7 @@ def test_reschedule_maintenance_empty_call_grpc(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.RescheduleMaintenanceRequest() + request_msg = cloud_redis_pb2.RescheduleMaintenanceRequest() assert args[0] == request_msg @@ -6875,7 +6863,7 @@ async def test_list_instances_empty_call_grpc_asyncio(): type(client.transport.list_instances), '__call__') as call: # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis.ListInstancesResponse( + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis_pb2.ListInstancesResponse( next_page_token='next_page_token_value', unreachable=['unreachable_value'], )) @@ -6884,7 +6872,7 @@ async def test_list_instances_empty_call_grpc_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.ListInstancesRequest() + request_msg = cloud_redis_pb2.ListInstancesRequest() assert args[0] == request_msg @@ -6903,7 +6891,7 @@ async def test_get_instance_empty_call_grpc_asyncio(): type(client.transport.get_instance), '__call__') as call: # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis.Instance( + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis_pb2.Instance( name='name_value', display_name='display_name_value', location_id='location_id_value', @@ -6914,21 +6902,21 @@ async def test_get_instance_empty_call_grpc_asyncio(): host='host_value', port=453, current_location_id='current_location_id_value', - state=cloud_redis.Instance.State.CREATING, + state=cloud_redis_pb2.Instance.State.CREATING, status_message='status_message_value', - tier=cloud_redis.Instance.Tier.BASIC, + tier=cloud_redis_pb2.Instance.Tier.BASIC, memory_size_gb=1499, authorized_network='authorized_network_value', persistence_iam_identity='persistence_iam_identity_value', - connect_mode=cloud_redis.Instance.ConnectMode.DIRECT_PEERING, + connect_mode=cloud_redis_pb2.Instance.ConnectMode.DIRECT_PEERING, auth_enabled=True, - transit_encryption_mode=cloud_redis.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION, + transit_encryption_mode=cloud_redis_pb2.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION, replica_count=1384, read_endpoint='read_endpoint_value', read_endpoint_port=1920, - read_replicas_mode=cloud_redis.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED, + read_replicas_mode=cloud_redis_pb2.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED, customer_managed_key='customer_managed_key_value', - suspension_reasons=[cloud_redis.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE], + suspension_reasons=[cloud_redis_pb2.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE], maintenance_version='maintenance_version_value', available_maintenance_versions=['available_maintenance_versions_value'], )) @@ -6937,7 +6925,7 @@ async def test_get_instance_empty_call_grpc_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.GetInstanceRequest() + request_msg = cloud_redis_pb2.GetInstanceRequest() assert args[0] == request_msg @@ -6956,7 +6944,7 @@ async def test_get_instance_auth_string_empty_call_grpc_asyncio(): 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( + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloud_redis_pb2.InstanceAuthString( auth_string='auth_string_value', )) await client.get_instance_auth_string(request=None) @@ -6964,7 +6952,7 @@ async def test_get_instance_auth_string_empty_call_grpc_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.GetInstanceAuthStringRequest() + request_msg = cloud_redis_pb2.GetInstanceAuthStringRequest() assert args[0] == request_msg @@ -6991,7 +6979,7 @@ async def test_create_instance_empty_call_grpc_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.CreateInstanceRequest() + request_msg = cloud_redis_pb2.CreateInstanceRequest() assert args[0] == request_msg @@ -7018,7 +7006,7 @@ async def test_update_instance_empty_call_grpc_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.UpdateInstanceRequest() + request_msg = cloud_redis_pb2.UpdateInstanceRequest() assert args[0] == request_msg @@ -7045,7 +7033,7 @@ async def test_upgrade_instance_empty_call_grpc_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.UpgradeInstanceRequest() + request_msg = cloud_redis_pb2.UpgradeInstanceRequest() assert args[0] == request_msg @@ -7072,7 +7060,7 @@ async def test_import_instance_empty_call_grpc_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.ImportInstanceRequest() + request_msg = cloud_redis_pb2.ImportInstanceRequest() assert args[0] == request_msg @@ -7099,7 +7087,7 @@ async def test_export_instance_empty_call_grpc_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.ExportInstanceRequest() + request_msg = cloud_redis_pb2.ExportInstanceRequest() assert args[0] == request_msg @@ -7126,7 +7114,7 @@ async def test_failover_instance_empty_call_grpc_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.FailoverInstanceRequest() + request_msg = cloud_redis_pb2.FailoverInstanceRequest() assert args[0] == request_msg @@ -7153,7 +7141,7 @@ async def test_delete_instance_empty_call_grpc_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.DeleteInstanceRequest() + request_msg = cloud_redis_pb2.DeleteInstanceRequest() assert args[0] == request_msg @@ -7180,7 +7168,7 @@ async def test_reschedule_maintenance_empty_call_grpc_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.RescheduleMaintenanceRequest() + request_msg = cloud_redis_pb2.RescheduleMaintenanceRequest() assert args[0] == request_msg @@ -7192,7 +7180,7 @@ def test_transport_kind_rest(): assert transport.kind == "rest" -def test_list_instances_rest_bad_request(request_type=cloud_redis.ListInstancesRequest): +def test_list_instances_rest_bad_request(request_type=cloud_redis_pb2.ListInstancesRequest): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -7214,7 +7202,7 @@ def test_list_instances_rest_bad_request(request_type=cloud_redis.ListInstancesR @pytest.mark.parametrize("request_type", [ - cloud_redis.ListInstancesRequest, + cloud_redis_pb2.ListInstancesRequest, dict, ]) def test_list_instances_rest_call_success(request_type): @@ -7230,7 +7218,7 @@ def test_list_instances_rest_call_success(request_type): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), 'request') as req: # Designate an appropriate value for the returned response. - return_value = cloud_redis.ListInstancesResponse( + return_value = cloud_redis_pb2.ListInstancesResponse( next_page_token='next_page_token_value', unreachable=['unreachable_value'], ) @@ -7238,9 +7226,6 @@ def test_list_instances_rest_call_success(request_type): # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = cloud_redis.ListInstancesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode('UTF-8') req.return_value = response_value @@ -7266,7 +7251,7 @@ def test_list_instances_rest_interceptors(null_interceptor): mock.patch.object(transports.CloudRedisRestInterceptor, "pre_list_instances") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.ListInstancesRequest.pb(cloud_redis.ListInstancesRequest()) + pb_message = cloud_redis_pb2.ListInstancesRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -7276,16 +7261,16 @@ def test_list_instances_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = cloud_redis.ListInstancesResponse.to_json(cloud_redis.ListInstancesResponse()) + return_value = json_format.MessageToJson(cloud_redis_pb2.ListInstancesResponse()) req.return_value.content = return_value - request = cloud_redis.ListInstancesRequest() + request = cloud_redis_pb2.ListInstancesRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = cloud_redis.ListInstancesResponse() + post.return_value = cloud_redis_pb2.ListInstancesResponse() client.list_instances(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) @@ -7293,7 +7278,7 @@ def test_list_instances_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_instance_rest_bad_request(request_type=cloud_redis.GetInstanceRequest): +def test_get_instance_rest_bad_request(request_type=cloud_redis_pb2.GetInstanceRequest): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -7315,7 +7300,7 @@ def test_get_instance_rest_bad_request(request_type=cloud_redis.GetInstanceReque @pytest.mark.parametrize("request_type", [ - cloud_redis.GetInstanceRequest, + cloud_redis_pb2.GetInstanceRequest, dict, ]) def test_get_instance_rest_call_success(request_type): @@ -7331,7 +7316,7 @@ def test_get_instance_rest_call_success(request_type): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), 'request') as req: # Designate an appropriate value for the returned response. - return_value = cloud_redis.Instance( + return_value = cloud_redis_pb2.Instance( name='name_value', display_name='display_name_value', location_id='location_id_value', @@ -7342,21 +7327,21 @@ def test_get_instance_rest_call_success(request_type): host='host_value', port=453, current_location_id='current_location_id_value', - state=cloud_redis.Instance.State.CREATING, + state=cloud_redis_pb2.Instance.State.CREATING, status_message='status_message_value', - tier=cloud_redis.Instance.Tier.BASIC, + tier=cloud_redis_pb2.Instance.Tier.BASIC, memory_size_gb=1499, authorized_network='authorized_network_value', persistence_iam_identity='persistence_iam_identity_value', - connect_mode=cloud_redis.Instance.ConnectMode.DIRECT_PEERING, + connect_mode=cloud_redis_pb2.Instance.ConnectMode.DIRECT_PEERING, auth_enabled=True, - transit_encryption_mode=cloud_redis.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION, + transit_encryption_mode=cloud_redis_pb2.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION, replica_count=1384, read_endpoint='read_endpoint_value', read_endpoint_port=1920, - read_replicas_mode=cloud_redis.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED, + read_replicas_mode=cloud_redis_pb2.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED, customer_managed_key='customer_managed_key_value', - suspension_reasons=[cloud_redis.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE], + suspension_reasons=[cloud_redis_pb2.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE], maintenance_version='maintenance_version_value', available_maintenance_versions=['available_maintenance_versions_value'], ) @@ -7364,16 +7349,13 @@ def test_get_instance_rest_call_success(request_type): # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = cloud_redis.Instance.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode('UTF-8') req.return_value = response_value response = client.get_instance(request) # Establish that the response is the type that we expect. - assert isinstance(response, cloud_redis.Instance) + assert isinstance(response, cloud_redis_pb2.Instance) assert response.name == 'name_value' assert response.display_name == 'display_name_value' assert response.location_id == 'location_id_value' @@ -7384,21 +7366,21 @@ def test_get_instance_rest_call_success(request_type): assert response.host == 'host_value' assert response.port == 453 assert response.current_location_id == 'current_location_id_value' - assert response.state == cloud_redis.Instance.State.CREATING + assert response.state == cloud_redis_pb2.Instance.State.CREATING assert response.status_message == 'status_message_value' - assert response.tier == cloud_redis.Instance.Tier.BASIC + assert response.tier == cloud_redis_pb2.Instance.Tier.BASIC assert response.memory_size_gb == 1499 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.connect_mode == cloud_redis_pb2.Instance.ConnectMode.DIRECT_PEERING assert response.auth_enabled is True - assert response.transit_encryption_mode == cloud_redis.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION + assert response.transit_encryption_mode == cloud_redis_pb2.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION assert response.replica_count == 1384 assert response.read_endpoint == 'read_endpoint_value' assert response.read_endpoint_port == 1920 - assert response.read_replicas_mode == cloud_redis.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED + assert response.read_replicas_mode == cloud_redis_pb2.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED assert response.customer_managed_key == 'customer_managed_key_value' - assert response.suspension_reasons == [cloud_redis.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE] + assert response.suspension_reasons == [cloud_redis_pb2.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE] assert response.maintenance_version == 'maintenance_version_value' assert response.available_maintenance_versions == ['available_maintenance_versions_value'] @@ -7417,7 +7399,7 @@ def test_get_instance_rest_interceptors(null_interceptor): mock.patch.object(transports.CloudRedisRestInterceptor, "pre_get_instance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.GetInstanceRequest.pb(cloud_redis.GetInstanceRequest()) + pb_message = cloud_redis_pb2.GetInstanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -7427,16 +7409,16 @@ def test_get_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = cloud_redis.Instance.to_json(cloud_redis.Instance()) + return_value = json_format.MessageToJson(cloud_redis_pb2.Instance()) req.return_value.content = return_value - request = cloud_redis.GetInstanceRequest() + request = cloud_redis_pb2.GetInstanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = cloud_redis.Instance() + post.return_value = cloud_redis_pb2.Instance() client.get_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) @@ -7444,7 +7426,7 @@ def test_get_instance_rest_interceptors(null_interceptor): post.assert_called_once() -def test_get_instance_auth_string_rest_bad_request(request_type=cloud_redis.GetInstanceAuthStringRequest): +def test_get_instance_auth_string_rest_bad_request(request_type=cloud_redis_pb2.GetInstanceAuthStringRequest): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -7466,7 +7448,7 @@ def test_get_instance_auth_string_rest_bad_request(request_type=cloud_redis.GetI @pytest.mark.parametrize("request_type", [ - cloud_redis.GetInstanceAuthStringRequest, + cloud_redis_pb2.GetInstanceAuthStringRequest, dict, ]) def test_get_instance_auth_string_rest_call_success(request_type): @@ -7482,23 +7464,20 @@ def test_get_instance_auth_string_rest_call_success(request_type): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), 'request') as req: # Designate an appropriate value for the returned response. - return_value = cloud_redis.InstanceAuthString( + return_value = cloud_redis_pb2.InstanceAuthString( auth_string='auth_string_value', ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = cloud_redis.InstanceAuthString.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode('UTF-8') req.return_value = response_value response = client.get_instance_auth_string(request) # Establish that the response is the type that we expect. - assert isinstance(response, cloud_redis.InstanceAuthString) + assert isinstance(response, cloud_redis_pb2.InstanceAuthString) assert response.auth_string == 'auth_string_value' @@ -7516,7 +7495,7 @@ def test_get_instance_auth_string_rest_interceptors(null_interceptor): mock.patch.object(transports.CloudRedisRestInterceptor, "pre_get_instance_auth_string") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.GetInstanceAuthStringRequest.pb(cloud_redis.GetInstanceAuthStringRequest()) + pb_message = cloud_redis_pb2.GetInstanceAuthStringRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -7526,16 +7505,16 @@ def test_get_instance_auth_string_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = cloud_redis.InstanceAuthString.to_json(cloud_redis.InstanceAuthString()) + return_value = json_format.MessageToJson(cloud_redis_pb2.InstanceAuthString()) req.return_value.content = return_value - request = cloud_redis.GetInstanceAuthStringRequest() + request = cloud_redis_pb2.GetInstanceAuthStringRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = cloud_redis.InstanceAuthString() + post.return_value = cloud_redis_pb2.InstanceAuthString() client.get_instance_auth_string(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) @@ -7543,7 +7522,7 @@ def test_get_instance_auth_string_rest_interceptors(null_interceptor): post.assert_called_once() -def test_create_instance_rest_bad_request(request_type=cloud_redis.CreateInstanceRequest): +def test_create_instance_rest_bad_request(request_type=cloud_redis_pb2.CreateInstanceRequest): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -7565,7 +7544,7 @@ def test_create_instance_rest_bad_request(request_type=cloud_redis.CreateInstanc @pytest.mark.parametrize("request_type", [ - cloud_redis.CreateInstanceRequest, + cloud_redis_pb2.CreateInstanceRequest, dict, ]) def test_create_instance_rest_call_success(request_type): @@ -7581,65 +7560,6 @@ def test_create_instance_rest_call_success(request_type): # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 - # Determine if the message type is proto-plus or protobuf - test_field = cloud_redis.CreateInstanceRequest.meta.fields["instance"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["instance"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["instance"][field])): - del request_init["instance"][field][i][subfield] - else: - del request_init["instance"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -7674,7 +7594,7 @@ def test_create_instance_rest_interceptors(null_interceptor): mock.patch.object(transports.CloudRedisRestInterceptor, "pre_create_instance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.CreateInstanceRequest.pb(cloud_redis.CreateInstanceRequest()) + pb_message = cloud_redis_pb2.CreateInstanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -7687,7 +7607,7 @@ def test_create_instance_rest_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = cloud_redis.CreateInstanceRequest() + request = cloud_redis_pb2.CreateInstanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), @@ -7701,7 +7621,7 @@ def test_create_instance_rest_interceptors(null_interceptor): post.assert_called_once() -def test_update_instance_rest_bad_request(request_type=cloud_redis.UpdateInstanceRequest): +def test_update_instance_rest_bad_request(request_type=cloud_redis_pb2.UpdateInstanceRequest): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -7723,7 +7643,7 @@ def test_update_instance_rest_bad_request(request_type=cloud_redis.UpdateInstanc @pytest.mark.parametrize("request_type", [ - cloud_redis.UpdateInstanceRequest, + cloud_redis_pb2.UpdateInstanceRequest, dict, ]) def test_update_instance_rest_call_success(request_type): @@ -7739,65 +7659,6 @@ def test_update_instance_rest_call_success(request_type): # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 - # Determine if the message type is proto-plus or protobuf - test_field = cloud_redis.UpdateInstanceRequest.meta.fields["instance"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["instance"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["instance"][field])): - del request_init["instance"][field][i][subfield] - else: - del request_init["instance"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -7832,7 +7693,7 @@ def test_update_instance_rest_interceptors(null_interceptor): mock.patch.object(transports.CloudRedisRestInterceptor, "pre_update_instance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.UpdateInstanceRequest.pb(cloud_redis.UpdateInstanceRequest()) + pb_message = cloud_redis_pb2.UpdateInstanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -7845,7 +7706,7 @@ def test_update_instance_rest_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = cloud_redis.UpdateInstanceRequest() + request = cloud_redis_pb2.UpdateInstanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), @@ -7859,7 +7720,7 @@ def test_update_instance_rest_interceptors(null_interceptor): post.assert_called_once() -def test_upgrade_instance_rest_bad_request(request_type=cloud_redis.UpgradeInstanceRequest): +def test_upgrade_instance_rest_bad_request(request_type=cloud_redis_pb2.UpgradeInstanceRequest): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -7881,7 +7742,7 @@ def test_upgrade_instance_rest_bad_request(request_type=cloud_redis.UpgradeInsta @pytest.mark.parametrize("request_type", [ - cloud_redis.UpgradeInstanceRequest, + cloud_redis_pb2.UpgradeInstanceRequest, dict, ]) def test_upgrade_instance_rest_call_success(request_type): @@ -7926,7 +7787,7 @@ def test_upgrade_instance_rest_interceptors(null_interceptor): mock.patch.object(transports.CloudRedisRestInterceptor, "pre_upgrade_instance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.UpgradeInstanceRequest.pb(cloud_redis.UpgradeInstanceRequest()) + pb_message = cloud_redis_pb2.UpgradeInstanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -7939,7 +7800,7 @@ def test_upgrade_instance_rest_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = cloud_redis.UpgradeInstanceRequest() + request = cloud_redis_pb2.UpgradeInstanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), @@ -7953,7 +7814,7 @@ def test_upgrade_instance_rest_interceptors(null_interceptor): post.assert_called_once() -def test_import_instance_rest_bad_request(request_type=cloud_redis.ImportInstanceRequest): +def test_import_instance_rest_bad_request(request_type=cloud_redis_pb2.ImportInstanceRequest): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -7975,7 +7836,7 @@ def test_import_instance_rest_bad_request(request_type=cloud_redis.ImportInstanc @pytest.mark.parametrize("request_type", [ - cloud_redis.ImportInstanceRequest, + cloud_redis_pb2.ImportInstanceRequest, dict, ]) def test_import_instance_rest_call_success(request_type): @@ -8020,7 +7881,7 @@ def test_import_instance_rest_interceptors(null_interceptor): mock.patch.object(transports.CloudRedisRestInterceptor, "pre_import_instance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.ImportInstanceRequest.pb(cloud_redis.ImportInstanceRequest()) + pb_message = cloud_redis_pb2.ImportInstanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -8033,7 +7894,7 @@ def test_import_instance_rest_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = cloud_redis.ImportInstanceRequest() + request = cloud_redis_pb2.ImportInstanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), @@ -8047,7 +7908,7 @@ def test_import_instance_rest_interceptors(null_interceptor): post.assert_called_once() -def test_export_instance_rest_bad_request(request_type=cloud_redis.ExportInstanceRequest): +def test_export_instance_rest_bad_request(request_type=cloud_redis_pb2.ExportInstanceRequest): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -8069,7 +7930,7 @@ def test_export_instance_rest_bad_request(request_type=cloud_redis.ExportInstanc @pytest.mark.parametrize("request_type", [ - cloud_redis.ExportInstanceRequest, + cloud_redis_pb2.ExportInstanceRequest, dict, ]) def test_export_instance_rest_call_success(request_type): @@ -8114,7 +7975,7 @@ def test_export_instance_rest_interceptors(null_interceptor): mock.patch.object(transports.CloudRedisRestInterceptor, "pre_export_instance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.ExportInstanceRequest.pb(cloud_redis.ExportInstanceRequest()) + pb_message = cloud_redis_pb2.ExportInstanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -8127,7 +7988,7 @@ def test_export_instance_rest_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = cloud_redis.ExportInstanceRequest() + request = cloud_redis_pb2.ExportInstanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), @@ -8141,7 +8002,7 @@ def test_export_instance_rest_interceptors(null_interceptor): post.assert_called_once() -def test_failover_instance_rest_bad_request(request_type=cloud_redis.FailoverInstanceRequest): +def test_failover_instance_rest_bad_request(request_type=cloud_redis_pb2.FailoverInstanceRequest): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -8163,7 +8024,7 @@ def test_failover_instance_rest_bad_request(request_type=cloud_redis.FailoverIns @pytest.mark.parametrize("request_type", [ - cloud_redis.FailoverInstanceRequest, + cloud_redis_pb2.FailoverInstanceRequest, dict, ]) def test_failover_instance_rest_call_success(request_type): @@ -8208,7 +8069,7 @@ def test_failover_instance_rest_interceptors(null_interceptor): mock.patch.object(transports.CloudRedisRestInterceptor, "pre_failover_instance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.FailoverInstanceRequest.pb(cloud_redis.FailoverInstanceRequest()) + pb_message = cloud_redis_pb2.FailoverInstanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -8221,7 +8082,7 @@ def test_failover_instance_rest_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = cloud_redis.FailoverInstanceRequest() + request = cloud_redis_pb2.FailoverInstanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), @@ -8235,7 +8096,7 @@ def test_failover_instance_rest_interceptors(null_interceptor): post.assert_called_once() -def test_delete_instance_rest_bad_request(request_type=cloud_redis.DeleteInstanceRequest): +def test_delete_instance_rest_bad_request(request_type=cloud_redis_pb2.DeleteInstanceRequest): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -8257,7 +8118,7 @@ def test_delete_instance_rest_bad_request(request_type=cloud_redis.DeleteInstanc @pytest.mark.parametrize("request_type", [ - cloud_redis.DeleteInstanceRequest, + cloud_redis_pb2.DeleteInstanceRequest, dict, ]) def test_delete_instance_rest_call_success(request_type): @@ -8302,7 +8163,7 @@ def test_delete_instance_rest_interceptors(null_interceptor): mock.patch.object(transports.CloudRedisRestInterceptor, "pre_delete_instance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.DeleteInstanceRequest.pb(cloud_redis.DeleteInstanceRequest()) + pb_message = cloud_redis_pb2.DeleteInstanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -8315,7 +8176,7 @@ def test_delete_instance_rest_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = cloud_redis.DeleteInstanceRequest() + request = cloud_redis_pb2.DeleteInstanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), @@ -8329,7 +8190,7 @@ def test_delete_instance_rest_interceptors(null_interceptor): post.assert_called_once() -def test_reschedule_maintenance_rest_bad_request(request_type=cloud_redis.RescheduleMaintenanceRequest): +def test_reschedule_maintenance_rest_bad_request(request_type=cloud_redis_pb2.RescheduleMaintenanceRequest): client = CloudRedisClient( credentials=ga_credentials.AnonymousCredentials(), transport="rest" @@ -8351,7 +8212,7 @@ def test_reschedule_maintenance_rest_bad_request(request_type=cloud_redis.Resche @pytest.mark.parametrize("request_type", [ - cloud_redis.RescheduleMaintenanceRequest, + cloud_redis_pb2.RescheduleMaintenanceRequest, dict, ]) def test_reschedule_maintenance_rest_call_success(request_type): @@ -8396,7 +8257,7 @@ def test_reschedule_maintenance_rest_interceptors(null_interceptor): mock.patch.object(transports.CloudRedisRestInterceptor, "pre_reschedule_maintenance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.RescheduleMaintenanceRequest.pb(cloud_redis.RescheduleMaintenanceRequest()) + pb_message = cloud_redis_pb2.RescheduleMaintenanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -8409,7 +8270,7 @@ def test_reschedule_maintenance_rest_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value - request = cloud_redis.RescheduleMaintenanceRequest() + request = cloud_redis_pb2.RescheduleMaintenanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), @@ -8804,7 +8665,7 @@ def test_list_instances_empty_call_rest(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.ListInstancesRequest() + request_msg = cloud_redis_pb2.ListInstancesRequest() assert args[0] == request_msg @@ -8826,7 +8687,7 @@ def test_get_instance_empty_call_rest(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.GetInstanceRequest() + request_msg = cloud_redis_pb2.GetInstanceRequest() assert args[0] == request_msg @@ -8848,7 +8709,7 @@ def test_get_instance_auth_string_empty_call_rest(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.GetInstanceAuthStringRequest() + request_msg = cloud_redis_pb2.GetInstanceAuthStringRequest() assert args[0] == request_msg @@ -8870,7 +8731,7 @@ def test_create_instance_empty_call_rest(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.CreateInstanceRequest() + request_msg = cloud_redis_pb2.CreateInstanceRequest() assert args[0] == request_msg @@ -8892,7 +8753,7 @@ def test_update_instance_empty_call_rest(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.UpdateInstanceRequest() + request_msg = cloud_redis_pb2.UpdateInstanceRequest() assert args[0] == request_msg @@ -8914,7 +8775,7 @@ def test_upgrade_instance_empty_call_rest(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.UpgradeInstanceRequest() + request_msg = cloud_redis_pb2.UpgradeInstanceRequest() assert args[0] == request_msg @@ -8936,7 +8797,7 @@ def test_import_instance_empty_call_rest(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.ImportInstanceRequest() + request_msg = cloud_redis_pb2.ImportInstanceRequest() assert args[0] == request_msg @@ -8958,7 +8819,7 @@ def test_export_instance_empty_call_rest(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.ExportInstanceRequest() + request_msg = cloud_redis_pb2.ExportInstanceRequest() assert args[0] == request_msg @@ -8980,7 +8841,7 @@ def test_failover_instance_empty_call_rest(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.FailoverInstanceRequest() + request_msg = cloud_redis_pb2.FailoverInstanceRequest() assert args[0] == request_msg @@ -9002,7 +8863,7 @@ def test_delete_instance_empty_call_rest(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.DeleteInstanceRequest() + request_msg = cloud_redis_pb2.DeleteInstanceRequest() assert args[0] == request_msg @@ -9024,7 +8885,7 @@ def test_reschedule_maintenance_empty_call_rest(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.RescheduleMaintenanceRequest() + request_msg = cloud_redis_pb2.RescheduleMaintenanceRequest() assert args[0] == request_msg @@ -9055,7 +8916,7 @@ def test_transport_kind_rest_asyncio(): @pytest.mark.asyncio -async def test_list_instances_rest_asyncio_bad_request(request_type=cloud_redis.ListInstancesRequest): +async def test_list_instances_rest_asyncio_bad_request(request_type=cloud_redis_pb2.ListInstancesRequest): if not HAS_ASYNC_REST_EXTRA: pytest.skip("the library must be installed with the `async_rest` extra to test this feature.") client = CloudRedisAsyncClient( @@ -9079,7 +8940,7 @@ async def test_list_instances_rest_asyncio_bad_request(request_type=cloud_redis. @pytest.mark.asyncio @pytest.mark.parametrize("request_type", [ - cloud_redis.ListInstancesRequest, + cloud_redis_pb2.ListInstancesRequest, dict, ]) async def test_list_instances_rest_asyncio_call_success(request_type): @@ -9097,7 +8958,7 @@ async def test_list_instances_rest_asyncio_call_success(request_type): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), 'request') as req: # Designate an appropriate value for the returned response. - return_value = cloud_redis.ListInstancesResponse( + return_value = cloud_redis_pb2.ListInstancesResponse( next_page_token='next_page_token_value', unreachable=['unreachable_value'], ) @@ -9105,9 +8966,6 @@ async def test_list_instances_rest_asyncio_call_success(request_type): # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = cloud_redis.ListInstancesResponse.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.read = mock.AsyncMock(return_value=json_return_value.encode('UTF-8')) req.return_value = response_value @@ -9136,7 +8994,7 @@ async def test_list_instances_rest_asyncio_interceptors(null_interceptor): mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_list_instances") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.ListInstancesRequest.pb(cloud_redis.ListInstancesRequest()) + pb_message = cloud_redis_pb2.ListInstancesRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -9146,16 +9004,16 @@ async def test_list_instances_rest_asyncio_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = cloud_redis.ListInstancesResponse.to_json(cloud_redis.ListInstancesResponse()) + return_value = json_format.MessageToJson(cloud_redis_pb2.ListInstancesResponse()) req.return_value.read = mock.AsyncMock(return_value=return_value) - request = cloud_redis.ListInstancesRequest() + request = cloud_redis_pb2.ListInstancesRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = cloud_redis.ListInstancesResponse() + post.return_value = cloud_redis_pb2.ListInstancesResponse() await client.list_instances(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) @@ -9163,7 +9021,7 @@ async def test_list_instances_rest_asyncio_interceptors(null_interceptor): post.assert_called_once() @pytest.mark.asyncio -async def test_get_instance_rest_asyncio_bad_request(request_type=cloud_redis.GetInstanceRequest): +async def test_get_instance_rest_asyncio_bad_request(request_type=cloud_redis_pb2.GetInstanceRequest): if not HAS_ASYNC_REST_EXTRA: pytest.skip("the library must be installed with the `async_rest` extra to test this feature.") client = CloudRedisAsyncClient( @@ -9187,7 +9045,7 @@ async def test_get_instance_rest_asyncio_bad_request(request_type=cloud_redis.Ge @pytest.mark.asyncio @pytest.mark.parametrize("request_type", [ - cloud_redis.GetInstanceRequest, + cloud_redis_pb2.GetInstanceRequest, dict, ]) async def test_get_instance_rest_asyncio_call_success(request_type): @@ -9205,7 +9063,7 @@ async def test_get_instance_rest_asyncio_call_success(request_type): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), 'request') as req: # Designate an appropriate value for the returned response. - return_value = cloud_redis.Instance( + return_value = cloud_redis_pb2.Instance( name='name_value', display_name='display_name_value', location_id='location_id_value', @@ -9216,21 +9074,21 @@ async def test_get_instance_rest_asyncio_call_success(request_type): host='host_value', port=453, current_location_id='current_location_id_value', - state=cloud_redis.Instance.State.CREATING, + state=cloud_redis_pb2.Instance.State.CREATING, status_message='status_message_value', - tier=cloud_redis.Instance.Tier.BASIC, + tier=cloud_redis_pb2.Instance.Tier.BASIC, memory_size_gb=1499, authorized_network='authorized_network_value', persistence_iam_identity='persistence_iam_identity_value', - connect_mode=cloud_redis.Instance.ConnectMode.DIRECT_PEERING, + connect_mode=cloud_redis_pb2.Instance.ConnectMode.DIRECT_PEERING, auth_enabled=True, - transit_encryption_mode=cloud_redis.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION, + transit_encryption_mode=cloud_redis_pb2.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION, replica_count=1384, read_endpoint='read_endpoint_value', read_endpoint_port=1920, - read_replicas_mode=cloud_redis.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED, + read_replicas_mode=cloud_redis_pb2.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED, customer_managed_key='customer_managed_key_value', - suspension_reasons=[cloud_redis.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE], + suspension_reasons=[cloud_redis_pb2.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE], maintenance_version='maintenance_version_value', available_maintenance_versions=['available_maintenance_versions_value'], ) @@ -9238,16 +9096,13 @@ async def test_get_instance_rest_asyncio_call_success(request_type): # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = cloud_redis.Instance.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.read = mock.AsyncMock(return_value=json_return_value.encode('UTF-8')) req.return_value = response_value response = await client.get_instance(request) # Establish that the response is the type that we expect. - assert isinstance(response, cloud_redis.Instance) + assert isinstance(response, cloud_redis_pb2.Instance) assert response.name == 'name_value' assert response.display_name == 'display_name_value' assert response.location_id == 'location_id_value' @@ -9258,21 +9113,21 @@ async def test_get_instance_rest_asyncio_call_success(request_type): assert response.host == 'host_value' assert response.port == 453 assert response.current_location_id == 'current_location_id_value' - assert response.state == cloud_redis.Instance.State.CREATING + assert response.state == cloud_redis_pb2.Instance.State.CREATING assert response.status_message == 'status_message_value' - assert response.tier == cloud_redis.Instance.Tier.BASIC + assert response.tier == cloud_redis_pb2.Instance.Tier.BASIC assert response.memory_size_gb == 1499 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.connect_mode == cloud_redis_pb2.Instance.ConnectMode.DIRECT_PEERING assert response.auth_enabled is True - assert response.transit_encryption_mode == cloud_redis.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION + assert response.transit_encryption_mode == cloud_redis_pb2.Instance.TransitEncryptionMode.SERVER_AUTHENTICATION assert response.replica_count == 1384 assert response.read_endpoint == 'read_endpoint_value' assert response.read_endpoint_port == 1920 - assert response.read_replicas_mode == cloud_redis.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED + assert response.read_replicas_mode == cloud_redis_pb2.Instance.ReadReplicasMode.READ_REPLICAS_DISABLED assert response.customer_managed_key == 'customer_managed_key_value' - assert response.suspension_reasons == [cloud_redis.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE] + assert response.suspension_reasons == [cloud_redis_pb2.Instance.SuspensionReason.CUSTOMER_MANAGED_KEY_ISSUE] assert response.maintenance_version == 'maintenance_version_value' assert response.available_maintenance_versions == ['available_maintenance_versions_value'] @@ -9294,7 +9149,7 @@ async def test_get_instance_rest_asyncio_interceptors(null_interceptor): mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_get_instance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.GetInstanceRequest.pb(cloud_redis.GetInstanceRequest()) + pb_message = cloud_redis_pb2.GetInstanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -9304,16 +9159,16 @@ async def test_get_instance_rest_asyncio_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = cloud_redis.Instance.to_json(cloud_redis.Instance()) + return_value = json_format.MessageToJson(cloud_redis_pb2.Instance()) req.return_value.read = mock.AsyncMock(return_value=return_value) - request = cloud_redis.GetInstanceRequest() + request = cloud_redis_pb2.GetInstanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = cloud_redis.Instance() + post.return_value = cloud_redis_pb2.Instance() await client.get_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) @@ -9321,7 +9176,7 @@ async def test_get_instance_rest_asyncio_interceptors(null_interceptor): post.assert_called_once() @pytest.mark.asyncio -async def test_get_instance_auth_string_rest_asyncio_bad_request(request_type=cloud_redis.GetInstanceAuthStringRequest): +async def test_get_instance_auth_string_rest_asyncio_bad_request(request_type=cloud_redis_pb2.GetInstanceAuthStringRequest): if not HAS_ASYNC_REST_EXTRA: pytest.skip("the library must be installed with the `async_rest` extra to test this feature.") client = CloudRedisAsyncClient( @@ -9345,7 +9200,7 @@ async def test_get_instance_auth_string_rest_asyncio_bad_request(request_type=cl @pytest.mark.asyncio @pytest.mark.parametrize("request_type", [ - cloud_redis.GetInstanceAuthStringRequest, + cloud_redis_pb2.GetInstanceAuthStringRequest, dict, ]) async def test_get_instance_auth_string_rest_asyncio_call_success(request_type): @@ -9363,23 +9218,20 @@ async def test_get_instance_auth_string_rest_asyncio_call_success(request_type): # Mock the http request call within the method and fake a response. with mock.patch.object(type(client.transport._session), 'request') as req: # Designate an appropriate value for the returned response. - return_value = cloud_redis.InstanceAuthString( + return_value = cloud_redis_pb2.InstanceAuthString( auth_string='auth_string_value', ) # Wrap the value into a proper Response obj response_value = mock.Mock() response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = cloud_redis.InstanceAuthString.pb(return_value) json_return_value = json_format.MessageToJson(return_value) response_value.read = mock.AsyncMock(return_value=json_return_value.encode('UTF-8')) req.return_value = response_value response = await client.get_instance_auth_string(request) # Establish that the response is the type that we expect. - assert isinstance(response, cloud_redis.InstanceAuthString) + assert isinstance(response, cloud_redis_pb2.InstanceAuthString) assert response.auth_string == 'auth_string_value' @@ -9400,7 +9252,7 @@ async def test_get_instance_auth_string_rest_asyncio_interceptors(null_intercept mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_get_instance_auth_string") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.GetInstanceAuthStringRequest.pb(cloud_redis.GetInstanceAuthStringRequest()) + pb_message = cloud_redis_pb2.GetInstanceAuthStringRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -9410,16 +9262,16 @@ async def test_get_instance_auth_string_rest_asyncio_interceptors(null_intercept req.return_value = mock.Mock() req.return_value.status_code = 200 - return_value = cloud_redis.InstanceAuthString.to_json(cloud_redis.InstanceAuthString()) + return_value = json_format.MessageToJson(cloud_redis_pb2.InstanceAuthString()) req.return_value.read = mock.AsyncMock(return_value=return_value) - request = cloud_redis.GetInstanceAuthStringRequest() + request = cloud_redis_pb2.GetInstanceAuthStringRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), ] pre.return_value = request, metadata - post.return_value = cloud_redis.InstanceAuthString() + post.return_value = cloud_redis_pb2.InstanceAuthString() await client.get_instance_auth_string(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) @@ -9427,7 +9279,7 @@ async def test_get_instance_auth_string_rest_asyncio_interceptors(null_intercept post.assert_called_once() @pytest.mark.asyncio -async def test_create_instance_rest_asyncio_bad_request(request_type=cloud_redis.CreateInstanceRequest): +async def test_create_instance_rest_asyncio_bad_request(request_type=cloud_redis_pb2.CreateInstanceRequest): if not HAS_ASYNC_REST_EXTRA: pytest.skip("the library must be installed with the `async_rest` extra to test this feature.") client = CloudRedisAsyncClient( @@ -9451,7 +9303,7 @@ async def test_create_instance_rest_asyncio_bad_request(request_type=cloud_redis @pytest.mark.asyncio @pytest.mark.parametrize("request_type", [ - cloud_redis.CreateInstanceRequest, + cloud_redis_pb2.CreateInstanceRequest, dict, ]) async def test_create_instance_rest_asyncio_call_success(request_type): @@ -9469,65 +9321,6 @@ async def test_create_instance_rest_asyncio_call_success(request_type): # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 - # Determine if the message type is proto-plus or protobuf - test_field = cloud_redis.CreateInstanceRequest.meta.fields["instance"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["instance"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["instance"][field])): - del request_init["instance"][field][i][subfield] - else: - del request_init["instance"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -9565,7 +9358,7 @@ async def test_create_instance_rest_asyncio_interceptors(null_interceptor): mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_create_instance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.CreateInstanceRequest.pb(cloud_redis.CreateInstanceRequest()) + pb_message = cloud_redis_pb2.CreateInstanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -9578,7 +9371,7 @@ async def test_create_instance_rest_asyncio_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.read = mock.AsyncMock(return_value=return_value) - request = cloud_redis.CreateInstanceRequest() + request = cloud_redis_pb2.CreateInstanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), @@ -9592,7 +9385,7 @@ async def test_create_instance_rest_asyncio_interceptors(null_interceptor): post.assert_called_once() @pytest.mark.asyncio -async def test_update_instance_rest_asyncio_bad_request(request_type=cloud_redis.UpdateInstanceRequest): +async def test_update_instance_rest_asyncio_bad_request(request_type=cloud_redis_pb2.UpdateInstanceRequest): if not HAS_ASYNC_REST_EXTRA: pytest.skip("the library must be installed with the `async_rest` extra to test this feature.") client = CloudRedisAsyncClient( @@ -9616,7 +9409,7 @@ async def test_update_instance_rest_asyncio_bad_request(request_type=cloud_redis @pytest.mark.asyncio @pytest.mark.parametrize("request_type", [ - cloud_redis.UpdateInstanceRequest, + cloud_redis_pb2.UpdateInstanceRequest, dict, ]) async def test_update_instance_rest_asyncio_call_success(request_type): @@ -9634,65 +9427,6 @@ async def test_update_instance_rest_asyncio_call_success(request_type): # Delete any fields which are not present in the current runtime dependency # See https://github.com/googleapis/gapic-generator-python/issues/1748 - # Determine if the message type is proto-plus or protobuf - test_field = cloud_redis.UpdateInstanceRequest.meta.fields["instance"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["instance"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["instance"][field])): - del request_init["instance"][field][i][subfield] - else: - del request_init["instance"][field][subfield] request = request_type(**request_init) # Mock the http request call within the method and fake a response. @@ -9730,7 +9464,7 @@ async def test_update_instance_rest_asyncio_interceptors(null_interceptor): mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_update_instance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.UpdateInstanceRequest.pb(cloud_redis.UpdateInstanceRequest()) + pb_message = cloud_redis_pb2.UpdateInstanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -9743,7 +9477,7 @@ async def test_update_instance_rest_asyncio_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.read = mock.AsyncMock(return_value=return_value) - request = cloud_redis.UpdateInstanceRequest() + request = cloud_redis_pb2.UpdateInstanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), @@ -9757,7 +9491,7 @@ async def test_update_instance_rest_asyncio_interceptors(null_interceptor): post.assert_called_once() @pytest.mark.asyncio -async def test_upgrade_instance_rest_asyncio_bad_request(request_type=cloud_redis.UpgradeInstanceRequest): +async def test_upgrade_instance_rest_asyncio_bad_request(request_type=cloud_redis_pb2.UpgradeInstanceRequest): if not HAS_ASYNC_REST_EXTRA: pytest.skip("the library must be installed with the `async_rest` extra to test this feature.") client = CloudRedisAsyncClient( @@ -9781,7 +9515,7 @@ async def test_upgrade_instance_rest_asyncio_bad_request(request_type=cloud_redi @pytest.mark.asyncio @pytest.mark.parametrize("request_type", [ - cloud_redis.UpgradeInstanceRequest, + cloud_redis_pb2.UpgradeInstanceRequest, dict, ]) async def test_upgrade_instance_rest_asyncio_call_success(request_type): @@ -9831,7 +9565,7 @@ async def test_upgrade_instance_rest_asyncio_interceptors(null_interceptor): mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_upgrade_instance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.UpgradeInstanceRequest.pb(cloud_redis.UpgradeInstanceRequest()) + pb_message = cloud_redis_pb2.UpgradeInstanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -9844,7 +9578,7 @@ async def test_upgrade_instance_rest_asyncio_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.read = mock.AsyncMock(return_value=return_value) - request = cloud_redis.UpgradeInstanceRequest() + request = cloud_redis_pb2.UpgradeInstanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), @@ -9858,7 +9592,7 @@ async def test_upgrade_instance_rest_asyncio_interceptors(null_interceptor): post.assert_called_once() @pytest.mark.asyncio -async def test_import_instance_rest_asyncio_bad_request(request_type=cloud_redis.ImportInstanceRequest): +async def test_import_instance_rest_asyncio_bad_request(request_type=cloud_redis_pb2.ImportInstanceRequest): if not HAS_ASYNC_REST_EXTRA: pytest.skip("the library must be installed with the `async_rest` extra to test this feature.") client = CloudRedisAsyncClient( @@ -9882,7 +9616,7 @@ async def test_import_instance_rest_asyncio_bad_request(request_type=cloud_redis @pytest.mark.asyncio @pytest.mark.parametrize("request_type", [ - cloud_redis.ImportInstanceRequest, + cloud_redis_pb2.ImportInstanceRequest, dict, ]) async def test_import_instance_rest_asyncio_call_success(request_type): @@ -9932,7 +9666,7 @@ async def test_import_instance_rest_asyncio_interceptors(null_interceptor): mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_import_instance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.ImportInstanceRequest.pb(cloud_redis.ImportInstanceRequest()) + pb_message = cloud_redis_pb2.ImportInstanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -9945,7 +9679,7 @@ async def test_import_instance_rest_asyncio_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.read = mock.AsyncMock(return_value=return_value) - request = cloud_redis.ImportInstanceRequest() + request = cloud_redis_pb2.ImportInstanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), @@ -9959,7 +9693,7 @@ async def test_import_instance_rest_asyncio_interceptors(null_interceptor): post.assert_called_once() @pytest.mark.asyncio -async def test_export_instance_rest_asyncio_bad_request(request_type=cloud_redis.ExportInstanceRequest): +async def test_export_instance_rest_asyncio_bad_request(request_type=cloud_redis_pb2.ExportInstanceRequest): if not HAS_ASYNC_REST_EXTRA: pytest.skip("the library must be installed with the `async_rest` extra to test this feature.") client = CloudRedisAsyncClient( @@ -9983,7 +9717,7 @@ async def test_export_instance_rest_asyncio_bad_request(request_type=cloud_redis @pytest.mark.asyncio @pytest.mark.parametrize("request_type", [ - cloud_redis.ExportInstanceRequest, + cloud_redis_pb2.ExportInstanceRequest, dict, ]) async def test_export_instance_rest_asyncio_call_success(request_type): @@ -10033,7 +9767,7 @@ async def test_export_instance_rest_asyncio_interceptors(null_interceptor): mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_export_instance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.ExportInstanceRequest.pb(cloud_redis.ExportInstanceRequest()) + pb_message = cloud_redis_pb2.ExportInstanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -10046,7 +9780,7 @@ async def test_export_instance_rest_asyncio_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.read = mock.AsyncMock(return_value=return_value) - request = cloud_redis.ExportInstanceRequest() + request = cloud_redis_pb2.ExportInstanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), @@ -10060,7 +9794,7 @@ async def test_export_instance_rest_asyncio_interceptors(null_interceptor): post.assert_called_once() @pytest.mark.asyncio -async def test_failover_instance_rest_asyncio_bad_request(request_type=cloud_redis.FailoverInstanceRequest): +async def test_failover_instance_rest_asyncio_bad_request(request_type=cloud_redis_pb2.FailoverInstanceRequest): if not HAS_ASYNC_REST_EXTRA: pytest.skip("the library must be installed with the `async_rest` extra to test this feature.") client = CloudRedisAsyncClient( @@ -10084,7 +9818,7 @@ async def test_failover_instance_rest_asyncio_bad_request(request_type=cloud_red @pytest.mark.asyncio @pytest.mark.parametrize("request_type", [ - cloud_redis.FailoverInstanceRequest, + cloud_redis_pb2.FailoverInstanceRequest, dict, ]) async def test_failover_instance_rest_asyncio_call_success(request_type): @@ -10134,7 +9868,7 @@ async def test_failover_instance_rest_asyncio_interceptors(null_interceptor): mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_failover_instance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.FailoverInstanceRequest.pb(cloud_redis.FailoverInstanceRequest()) + pb_message = cloud_redis_pb2.FailoverInstanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -10147,7 +9881,7 @@ async def test_failover_instance_rest_asyncio_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.read = mock.AsyncMock(return_value=return_value) - request = cloud_redis.FailoverInstanceRequest() + request = cloud_redis_pb2.FailoverInstanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), @@ -10161,7 +9895,7 @@ async def test_failover_instance_rest_asyncio_interceptors(null_interceptor): post.assert_called_once() @pytest.mark.asyncio -async def test_delete_instance_rest_asyncio_bad_request(request_type=cloud_redis.DeleteInstanceRequest): +async def test_delete_instance_rest_asyncio_bad_request(request_type=cloud_redis_pb2.DeleteInstanceRequest): if not HAS_ASYNC_REST_EXTRA: pytest.skip("the library must be installed with the `async_rest` extra to test this feature.") client = CloudRedisAsyncClient( @@ -10185,7 +9919,7 @@ async def test_delete_instance_rest_asyncio_bad_request(request_type=cloud_redis @pytest.mark.asyncio @pytest.mark.parametrize("request_type", [ - cloud_redis.DeleteInstanceRequest, + cloud_redis_pb2.DeleteInstanceRequest, dict, ]) async def test_delete_instance_rest_asyncio_call_success(request_type): @@ -10235,7 +9969,7 @@ async def test_delete_instance_rest_asyncio_interceptors(null_interceptor): mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_delete_instance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.DeleteInstanceRequest.pb(cloud_redis.DeleteInstanceRequest()) + pb_message = cloud_redis_pb2.DeleteInstanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -10248,7 +9982,7 @@ async def test_delete_instance_rest_asyncio_interceptors(null_interceptor): return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.read = mock.AsyncMock(return_value=return_value) - request = cloud_redis.DeleteInstanceRequest() + request = cloud_redis_pb2.DeleteInstanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), @@ -10262,7 +9996,7 @@ async def test_delete_instance_rest_asyncio_interceptors(null_interceptor): post.assert_called_once() @pytest.mark.asyncio -async def test_reschedule_maintenance_rest_asyncio_bad_request(request_type=cloud_redis.RescheduleMaintenanceRequest): +async def test_reschedule_maintenance_rest_asyncio_bad_request(request_type=cloud_redis_pb2.RescheduleMaintenanceRequest): if not HAS_ASYNC_REST_EXTRA: pytest.skip("the library must be installed with the `async_rest` extra to test this feature.") client = CloudRedisAsyncClient( @@ -10286,7 +10020,7 @@ async def test_reschedule_maintenance_rest_asyncio_bad_request(request_type=clou @pytest.mark.asyncio @pytest.mark.parametrize("request_type", [ - cloud_redis.RescheduleMaintenanceRequest, + cloud_redis_pb2.RescheduleMaintenanceRequest, dict, ]) async def test_reschedule_maintenance_rest_asyncio_call_success(request_type): @@ -10336,7 +10070,7 @@ async def test_reschedule_maintenance_rest_asyncio_interceptors(null_interceptor mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_reschedule_maintenance") as pre: pre.assert_not_called() post.assert_not_called() - pb_message = cloud_redis.RescheduleMaintenanceRequest.pb(cloud_redis.RescheduleMaintenanceRequest()) + pb_message = cloud_redis_pb2.RescheduleMaintenanceRequest() transcode.return_value = { "method": "post", "uri": "my_uri", @@ -10349,7 +10083,7 @@ async def test_reschedule_maintenance_rest_asyncio_interceptors(null_interceptor return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.read = mock.AsyncMock(return_value=return_value) - request = cloud_redis.RescheduleMaintenanceRequest() + request = cloud_redis_pb2.RescheduleMaintenanceRequest() metadata =[ ("key", "val"), ("cephalopod", "squid"), @@ -10770,7 +10504,7 @@ async def test_list_instances_empty_call_rest_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.ListInstancesRequest() + request_msg = cloud_redis_pb2.ListInstancesRequest() assert args[0] == request_msg @@ -10795,7 +10529,7 @@ async def test_get_instance_empty_call_rest_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.GetInstanceRequest() + request_msg = cloud_redis_pb2.GetInstanceRequest() assert args[0] == request_msg @@ -10820,7 +10554,7 @@ async def test_get_instance_auth_string_empty_call_rest_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.GetInstanceAuthStringRequest() + request_msg = cloud_redis_pb2.GetInstanceAuthStringRequest() assert args[0] == request_msg @@ -10845,7 +10579,7 @@ async def test_create_instance_empty_call_rest_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.CreateInstanceRequest() + request_msg = cloud_redis_pb2.CreateInstanceRequest() assert args[0] == request_msg @@ -10870,7 +10604,7 @@ async def test_update_instance_empty_call_rest_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.UpdateInstanceRequest() + request_msg = cloud_redis_pb2.UpdateInstanceRequest() assert args[0] == request_msg @@ -10895,7 +10629,7 @@ async def test_upgrade_instance_empty_call_rest_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.UpgradeInstanceRequest() + request_msg = cloud_redis_pb2.UpgradeInstanceRequest() assert args[0] == request_msg @@ -10920,7 +10654,7 @@ async def test_import_instance_empty_call_rest_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.ImportInstanceRequest() + request_msg = cloud_redis_pb2.ImportInstanceRequest() assert args[0] == request_msg @@ -10945,7 +10679,7 @@ async def test_export_instance_empty_call_rest_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.ExportInstanceRequest() + request_msg = cloud_redis_pb2.ExportInstanceRequest() assert args[0] == request_msg @@ -10970,7 +10704,7 @@ async def test_failover_instance_empty_call_rest_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.FailoverInstanceRequest() + request_msg = cloud_redis_pb2.FailoverInstanceRequest() assert args[0] == request_msg @@ -10995,7 +10729,7 @@ async def test_delete_instance_empty_call_rest_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.DeleteInstanceRequest() + request_msg = cloud_redis_pb2.DeleteInstanceRequest() assert args[0] == request_msg @@ -11020,7 +10754,7 @@ async def test_reschedule_maintenance_empty_call_rest_asyncio(): # Establish that the underlying stub method was called. call.assert_called() _, args, _ = call.mock_calls[0] - request_msg = cloud_redis.RescheduleMaintenanceRequest() + request_msg = cloud_redis_pb2.RescheduleMaintenanceRequest() assert args[0] == request_msg diff --git a/tests/integration/redis_v1.yaml b/tests/integration/redis_v1.yaml index efb6675bbf..f1287dde75 100644 --- a/tests/integration/redis_v1.yaml +++ b/tests/integration/redis_v1.yaml @@ -80,3 +80,4 @@ publishing: python_settings: experimental_features: rest_async_io_enabled: true + protobuf_pythonic_types_enabled: true From d07ea7584c91b50d43968e4c8e62132140bcb6fd Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 15 Nov 2024 16:19:18 +0000 Subject: [PATCH 02/11] add protobuf types for showcase --- noxfile.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/noxfile.py b/noxfile.py index bbbe8e5fc4..7ace640350 100644 --- a/noxfile.py +++ b/noxfile.py @@ -295,6 +295,12 @@ def showcase_library( *cmd_tup, external=True, ) + shutil.copy("tests/system/resources/echo_pb2.py", f"{tmp_dir}/google/showcase_v1beta1/types/echo_pb2.py") + shutil.copy("tests/system/resources/echo_pb2.pyi", f"{tmp_dir}/google/showcase_v1beta1/types/echo_pb2.pyi") + shutil.copy("tests/system/resources/identity_pb2.py", f"{tmp_dir}/google/showcase_v1beta1/types/identity_pb2.py") + shutil.copy("tests/system/resources/identity_pb2.pyi", f"{tmp_dir}/google/showcase_v1beta1/types/identity_pb2.pyi") + shutil.copy("tests/system/resources/messaging_pb2.py", f"{tmp_dir}/google/showcase_v1beta1/types/messaging_pb2.py") + shutil.copy("tests/system/resources/messaging_pb2.pyi", f"{tmp_dir}/google/showcase_v1beta1/types/messaging_pb2.pyi") # Install the generated showcase library. if templates == "DEFAULT": # Use the constraints file for the specific python runtime version. From 9a6c14561d397980f2fdcfa470f2a46ef67763ec Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 15 Nov 2024 16:19:41 +0000 Subject: [PATCH 03/11] add protobuf types for showcase --- tests/system/resources/echo_pb2.py | 119 +++++++++++++ tests/system/resources/echo_pb2.pyi | 195 +++++++++++++++++++++ tests/system/resources/identity_pb2.py | 84 +++++++++ tests/system/resources/identity_pb2.pyi | 77 +++++++++ tests/system/resources/messaging_pb2.py | 158 +++++++++++++++++ tests/system/resources/messaging_pb2.pyi | 209 +++++++++++++++++++++++ 6 files changed, 842 insertions(+) create mode 100644 tests/system/resources/echo_pb2.py create mode 100644 tests/system/resources/echo_pb2.pyi create mode 100644 tests/system/resources/identity_pb2.py create mode 100644 tests/system/resources/identity_pb2.pyi create mode 100644 tests/system/resources/messaging_pb2.py create mode 100644 tests/system/resources/messaging_pb2.pyi diff --git a/tests/system/resources/echo_pb2.py b/tests/system/resources/echo_pb2.py new file mode 100644 index 0000000000..4e0dd45ba0 --- /dev/null +++ b/tests/system/resources/echo_pb2.py @@ -0,0 +1,119 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE +# source: google/showcase/v1beta1/echo.proto +# Protobuf Python Version: 5.28.3 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, + 5, + 28, + 3, + '', + 'google/showcase/v1beta1/echo.proto' +) +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.api import client_pb2 as google_dot_api_dot_client__pb2 +from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 +from google.api import field_info_pb2 as google_dot_api_dot_field__info__pb2 +from google.api import routing_pb2 as google_dot_api_dot_routing__pb2 +from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 +from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2 +from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 +from google.rpc import status_pb2 as google_dot_rpc_dot_status__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\"google/showcase/v1beta1/echo.proto\x12\x17google.showcase.v1beta1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x1bgoogle/api/field_info.proto\x1a\x18google/api/routing.proto\x1a#google/longrunning/operations.proto\x1a\x19google/protobuf/any.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x17google/rpc/status.proto\"\x88\x02\n\x0b\x45\x63hoRequest\x12\x11\n\x07\x63ontent\x18\x01 \x01(\tH\x00\x12#\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x12.google.rpc.StatusH\x00\x12\x33\n\x08severity\x18\x03 \x01(\x0e\x32!.google.showcase.v1beta1.Severity\x12\x0e\n\x06header\x18\x04 \x01(\t\x12\x14\n\x0cother_header\x18\x05 \x01(\t\x12\x1c\n\nrequest_id\x18\x07 \x01(\tB\x08\xe2\x8c\xcf\xd7\x08\x02\x08\x01\x12\'\n\x10other_request_id\x18\x08 \x01(\tB\x08\xe2\x8c\xcf\xd7\x08\x02\x08\x01H\x01\x88\x01\x01\x42\n\n\x08responseB\x13\n\x11_other_request_id\"\x82\x01\n\x0c\x45\x63hoResponse\x12\x0f\n\x07\x63ontent\x18\x01 \x01(\t\x12\x33\n\x08severity\x18\x02 \x01(\x0e\x32!.google.showcase.v1beta1.Severity\x12\x12\n\nrequest_id\x18\x03 \x01(\t\x12\x18\n\x10other_request_id\x18\x04 \x01(\t\"P\n\x17\x45\x63hoErrorDetailsRequest\x12\x1a\n\x12single_detail_text\x18\x01 \x01(\t\x12\x19\n\x11multi_detail_text\x18\x02 \x03(\t\"\xf2\x02\n\x18\x45\x63hoErrorDetailsResponse\x12U\n\rsingle_detail\x18\x01 \x01(\x0b\x32>.google.showcase.v1beta1.EchoErrorDetailsResponse.SingleDetail\x12[\n\x10multiple_details\x18\x02 \x01(\x0b\x32\x41.google.showcase.v1beta1.EchoErrorDetailsResponse.MultipleDetails\x1aM\n\x0cSingleDetail\x12=\n\x05\x65rror\x18\x01 \x01(\x0b\x32..google.showcase.v1beta1.ErrorWithSingleDetail\x1aS\n\x0fMultipleDetails\x12@\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x31.google.showcase.v1beta1.ErrorWithMultipleDetails\">\n\x15\x45rrorWithSingleDetail\x12%\n\x07\x64\x65tails\x18\x01 \x01(\x0b\x32\x14.google.protobuf.Any\"A\n\x18\x45rrorWithMultipleDetails\x12%\n\x07\x64\x65tails\x18\x01 \x03(\x0b\x32\x14.google.protobuf.Any\"x\n\rExpandRequest\x12\x0f\n\x07\x63ontent\x18\x01 \x01(\t\x12!\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x12.google.rpc.Status\x12\x33\n\x10stream_wait_time\x18\x03 \x01(\x0b\x32\x19.google.protobuf.Duration\"Q\n\x12PagedExpandRequest\x12\x14\n\x07\x63ontent\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x11\n\tpage_size\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\"Y\n\x18PagedExpandLegacyRequest\x12\x14\n\x07\x63ontent\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x13\n\x0bmax_results\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\"h\n\x13PagedExpandResponse\x12\x38\n\tresponses\x18\x01 \x03(\x0b\x32%.google.showcase.v1beta1.EchoResponse\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"(\n\x17PagedExpandResponseList\x12\r\n\x05words\x18\x01 \x03(\t\"\x83\x02\n\x1fPagedExpandLegacyMappedResponse\x12`\n\x0c\x61lphabetized\x18\x01 \x03(\x0b\x32J.google.showcase.v1beta1.PagedExpandLegacyMappedResponse.AlphabetizedEntry\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\x1a\x65\n\x11\x41lphabetizedEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12?\n\x05value\x18\x02 \x01(\x0b\x32\x30.google.showcase.v1beta1.PagedExpandResponseList:\x02\x38\x01\"\xd9\x01\n\x0bWaitRequest\x12.\n\x08\x65nd_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.TimestampH\x00\x12(\n\x03ttl\x18\x04 \x01(\x0b\x32\x19.google.protobuf.DurationH\x00\x12#\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x12.google.rpc.StatusH\x01\x12\x38\n\x07success\x18\x03 \x01(\x0b\x32%.google.showcase.v1beta1.WaitResponseH\x01\x42\x05\n\x03\x65ndB\n\n\x08response\"\x1f\n\x0cWaitResponse\x12\x0f\n\x07\x63ontent\x18\x01 \x01(\t\"<\n\x0cWaitMetadata\x12,\n\x08\x65nd_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\xad\x01\n\x0c\x42lockRequest\x12\x31\n\x0eresponse_delay\x18\x01 \x01(\x0b\x32\x19.google.protobuf.Duration\x12#\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x12.google.rpc.StatusH\x00\x12\x39\n\x07success\x18\x03 \x01(\x0b\x32&.google.showcase.v1beta1.BlockResponseH\x00\x42\n\n\x08response\" \n\rBlockResponse\x12\x0f\n\x07\x63ontent\x18\x01 \x01(\t*D\n\x08Severity\x12\x0f\n\x0bUNNECESSARY\x10\x00\x12\r\n\tNECESSARY\x10\x01\x12\n\n\x06URGENT\x10\x02\x12\x0c\n\x08\x43RITICAL\x10\x03\x32\xb2\r\n\x04\x45\x63ho\x12\x94\x03\n\x04\x45\x63ho\x12$.google.showcase.v1beta1.EchoRequest\x1a%.google.showcase.v1beta1.EchoResponse\"\xbe\x02\x82\xd3\xe4\x93\x02\x17\"\x12/v1beta1/echo:echo:\x01*\x8a\xd3\xe4\x93\x02\x9a\x02\x12\x08\n\x06header\x12\x19\n\x06header\x12\x0f{routing_id=**}\x12+\n\x06header\x12!{table_name=regions/*/zones/*/**}\x12\"\n\x06header\x12\x18{super_id=projects/*}/**\x12\x30\n\x06header\x12&{table_name=projects/*/instances/*/**}\x12\x31\n\x06header\x12\'projects/*/{instance_id=instances/*}/**\x12\x18\n\x0cother_header\x12\x08{baz=**}\x12#\n\x0cother_header\x12\x13{qux=projects/*}/**\x12\x9f\x01\n\x10\x45\x63hoErrorDetails\x12\x30.google.showcase.v1beta1.EchoErrorDetailsRequest\x1a\x31.google.showcase.v1beta1.EchoErrorDetailsResponse\"&\x82\xd3\xe4\x93\x02 \"\x1b/v1beta1/echo:error-details:\x01*\x12\x8a\x01\n\x06\x45xpand\x12&.google.showcase.v1beta1.ExpandRequest\x1a%.google.showcase.v1beta1.EchoResponse\"/\xda\x41\rcontent,error\x82\xd3\xe4\x93\x02\x19\"\x14/v1beta1/echo:expand:\x01*0\x01\x12z\n\x07\x43ollect\x12$.google.showcase.v1beta1.EchoRequest\x1a%.google.showcase.v1beta1.EchoResponse\" \x82\xd3\xe4\x93\x02\x1a\"\x15/v1beta1/echo:collect:\x01*(\x01\x12W\n\x04\x43hat\x12$.google.showcase.v1beta1.EchoRequest\x1a%.google.showcase.v1beta1.EchoResponse(\x01\x30\x01\x12\x8e\x01\n\x0bPagedExpand\x12+.google.showcase.v1beta1.PagedExpandRequest\x1a,.google.showcase.v1beta1.PagedExpandResponse\"$\x82\xd3\xe4\x93\x02\x1e\"\x19/v1beta1/echo:pagedExpand:\x01*\x12\xa0\x01\n\x11PagedExpandLegacy\x12\x31.google.showcase.v1beta1.PagedExpandLegacyRequest\x1a,.google.showcase.v1beta1.PagedExpandResponse\"*\x82\xd3\xe4\x93\x02$\"\x1f/v1beta1/echo:pagedExpandLegacy:\x01*\x12\xb2\x01\n\x17PagedExpandLegacyMapped\x12+.google.showcase.v1beta1.PagedExpandRequest\x1a\x38.google.showcase.v1beta1.PagedExpandLegacyMappedResponse\"0\x82\xd3\xe4\x93\x02*\"%/v1beta1/echo:pagedExpandLegacyMapped:\x01*\x12\x89\x01\n\x04Wait\x12$.google.showcase.v1beta1.WaitRequest\x1a\x1d.google.longrunning.Operation\"<\xca\x41\x1c\n\x0cWaitResponse\x12\x0cWaitMetadata\x82\xd3\xe4\x93\x02\x17\"\x12/v1beta1/echo:wait:\x01*\x12v\n\x05\x42lock\x12%.google.showcase.v1beta1.BlockRequest\x1a&.google.showcase.v1beta1.BlockResponse\"\x1e\x82\xd3\xe4\x93\x02\x18\"\x13/v1beta1/echo:block:\x01*\x1a\"\xca\x41\x0elocalhost:7469\x8a\xd4\xdb\xd2\x0f\x0bv1_20240408Bq\n\x1b\x63om.google.showcase.v1beta1P\x01Z4github.com/googleapis/gapic-showcase/server/genproto\xea\x02\x19Google::Showcase::V1beta1b\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'google.showcase.v1beta1.echo_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + _globals['DESCRIPTOR']._loaded_options = None + _globals['DESCRIPTOR']._serialized_options = b'\n\033com.google.showcase.v1beta1P\001Z4github.com/googleapis/gapic-showcase/server/genproto\352\002\031Google::Showcase::V1beta1' + _globals['_ECHOREQUEST'].fields_by_name['request_id']._loaded_options = None + _globals['_ECHOREQUEST'].fields_by_name['request_id']._serialized_options = b'\342\214\317\327\010\002\010\001' + _globals['_ECHOREQUEST'].fields_by_name['other_request_id']._loaded_options = None + _globals['_ECHOREQUEST'].fields_by_name['other_request_id']._serialized_options = b'\342\214\317\327\010\002\010\001' + _globals['_PAGEDEXPANDREQUEST'].fields_by_name['content']._loaded_options = None + _globals['_PAGEDEXPANDREQUEST'].fields_by_name['content']._serialized_options = b'\340A\002' + _globals['_PAGEDEXPANDLEGACYREQUEST'].fields_by_name['content']._loaded_options = None + _globals['_PAGEDEXPANDLEGACYREQUEST'].fields_by_name['content']._serialized_options = b'\340A\002' + _globals['_PAGEDEXPANDLEGACYMAPPEDRESPONSE_ALPHABETIZEDENTRY']._loaded_options = None + _globals['_PAGEDEXPANDLEGACYMAPPEDRESPONSE_ALPHABETIZEDENTRY']._serialized_options = b'8\001' + _globals['_ECHO']._loaded_options = None + _globals['_ECHO']._serialized_options = b'\312A\016localhost:7469\212\324\333\322\017\013v1_20240408' + _globals['_ECHO'].methods_by_name['Echo']._loaded_options = None + _globals['_ECHO'].methods_by_name['Echo']._serialized_options = b'\202\323\344\223\002\027\"\022/v1beta1/echo:echo:\001*\212\323\344\223\002\232\002\022\010\n\006header\022\031\n\006header\022\017{routing_id=**}\022+\n\006header\022!{table_name=regions/*/zones/*/**}\022\"\n\006header\022\030{super_id=projects/*}/**\0220\n\006header\022&{table_name=projects/*/instances/*/**}\0221\n\006header\022\'projects/*/{instance_id=instances/*}/**\022\030\n\014other_header\022\010{baz=**}\022#\n\014other_header\022\023{qux=projects/*}/**' + _globals['_ECHO'].methods_by_name['EchoErrorDetails']._loaded_options = None + _globals['_ECHO'].methods_by_name['EchoErrorDetails']._serialized_options = b'\202\323\344\223\002 \"\033/v1beta1/echo:error-details:\001*' + _globals['_ECHO'].methods_by_name['Expand']._loaded_options = None + _globals['_ECHO'].methods_by_name['Expand']._serialized_options = b'\332A\rcontent,error\202\323\344\223\002\031\"\024/v1beta1/echo:expand:\001*' + _globals['_ECHO'].methods_by_name['Collect']._loaded_options = None + _globals['_ECHO'].methods_by_name['Collect']._serialized_options = b'\202\323\344\223\002\032\"\025/v1beta1/echo:collect:\001*' + _globals['_ECHO'].methods_by_name['PagedExpand']._loaded_options = None + _globals['_ECHO'].methods_by_name['PagedExpand']._serialized_options = b'\202\323\344\223\002\036\"\031/v1beta1/echo:pagedExpand:\001*' + _globals['_ECHO'].methods_by_name['PagedExpandLegacy']._loaded_options = None + _globals['_ECHO'].methods_by_name['PagedExpandLegacy']._serialized_options = b'\202\323\344\223\002$\"\037/v1beta1/echo:pagedExpandLegacy:\001*' + _globals['_ECHO'].methods_by_name['PagedExpandLegacyMapped']._loaded_options = None + _globals['_ECHO'].methods_by_name['PagedExpandLegacyMapped']._serialized_options = b'\202\323\344\223\002*\"%/v1beta1/echo:pagedExpandLegacyMapped:\001*' + _globals['_ECHO'].methods_by_name['Wait']._loaded_options = None + _globals['_ECHO'].methods_by_name['Wait']._serialized_options = b'\312A\034\n\014WaitResponse\022\014WaitMetadata\202\323\344\223\002\027\"\022/v1beta1/echo:wait:\001*' + _globals['_ECHO'].methods_by_name['Block']._loaded_options = None + _globals['_ECHO'].methods_by_name['Block']._serialized_options = b'\202\323\344\223\002\030\"\023/v1beta1/echo:block:\001*' + _globals['_SEVERITY']._serialized_start=2577 + _globals['_SEVERITY']._serialized_end=2645 + _globals['_ECHOREQUEST']._serialized_start=361 + _globals['_ECHOREQUEST']._serialized_end=625 + _globals['_ECHORESPONSE']._serialized_start=628 + _globals['_ECHORESPONSE']._serialized_end=758 + _globals['_ECHOERRORDETAILSREQUEST']._serialized_start=760 + _globals['_ECHOERRORDETAILSREQUEST']._serialized_end=840 + _globals['_ECHOERRORDETAILSRESPONSE']._serialized_start=843 + _globals['_ECHOERRORDETAILSRESPONSE']._serialized_end=1213 + _globals['_ECHOERRORDETAILSRESPONSE_SINGLEDETAIL']._serialized_start=1051 + _globals['_ECHOERRORDETAILSRESPONSE_SINGLEDETAIL']._serialized_end=1128 + _globals['_ECHOERRORDETAILSRESPONSE_MULTIPLEDETAILS']._serialized_start=1130 + _globals['_ECHOERRORDETAILSRESPONSE_MULTIPLEDETAILS']._serialized_end=1213 + _globals['_ERRORWITHSINGLEDETAIL']._serialized_start=1215 + _globals['_ERRORWITHSINGLEDETAIL']._serialized_end=1277 + _globals['_ERRORWITHMULTIPLEDETAILS']._serialized_start=1279 + _globals['_ERRORWITHMULTIPLEDETAILS']._serialized_end=1344 + _globals['_EXPANDREQUEST']._serialized_start=1346 + _globals['_EXPANDREQUEST']._serialized_end=1466 + _globals['_PAGEDEXPANDREQUEST']._serialized_start=1468 + _globals['_PAGEDEXPANDREQUEST']._serialized_end=1549 + _globals['_PAGEDEXPANDLEGACYREQUEST']._serialized_start=1551 + _globals['_PAGEDEXPANDLEGACYREQUEST']._serialized_end=1640 + _globals['_PAGEDEXPANDRESPONSE']._serialized_start=1642 + _globals['_PAGEDEXPANDRESPONSE']._serialized_end=1746 + _globals['_PAGEDEXPANDRESPONSELIST']._serialized_start=1748 + _globals['_PAGEDEXPANDRESPONSELIST']._serialized_end=1788 + _globals['_PAGEDEXPANDLEGACYMAPPEDRESPONSE']._serialized_start=1791 + _globals['_PAGEDEXPANDLEGACYMAPPEDRESPONSE']._serialized_end=2050 + _globals['_PAGEDEXPANDLEGACYMAPPEDRESPONSE_ALPHABETIZEDENTRY']._serialized_start=1949 + _globals['_PAGEDEXPANDLEGACYMAPPEDRESPONSE_ALPHABETIZEDENTRY']._serialized_end=2050 + _globals['_WAITREQUEST']._serialized_start=2053 + _globals['_WAITREQUEST']._serialized_end=2270 + _globals['_WAITRESPONSE']._serialized_start=2272 + _globals['_WAITRESPONSE']._serialized_end=2303 + _globals['_WAITMETADATA']._serialized_start=2305 + _globals['_WAITMETADATA']._serialized_end=2365 + _globals['_BLOCKREQUEST']._serialized_start=2368 + _globals['_BLOCKREQUEST']._serialized_end=2541 + _globals['_BLOCKRESPONSE']._serialized_start=2543 + _globals['_BLOCKRESPONSE']._serialized_end=2575 + _globals['_ECHO']._serialized_start=2648 + _globals['_ECHO']._serialized_end=4362 +# @@protoc_insertion_point(module_scope) diff --git a/tests/system/resources/echo_pb2.pyi b/tests/system/resources/echo_pb2.pyi new file mode 100644 index 0000000000..220a7ddd64 --- /dev/null +++ b/tests/system/resources/echo_pb2.pyi @@ -0,0 +1,195 @@ +from google.api import annotations_pb2 as _annotations_pb2 +from google.api import client_pb2 as _client_pb2 +from google.api import field_behavior_pb2 as _field_behavior_pb2 +from google.api import field_info_pb2 as _field_info_pb2 +from google.api import routing_pb2 as _routing_pb2 +from google.longrunning import operations_pb2 as _operations_pb2 +from google.protobuf import any_pb2 as _any_pb2 +from google.protobuf import duration_pb2 as _duration_pb2 +from google.protobuf import timestamp_pb2 as _timestamp_pb2 +from google.rpc import status_pb2 as _status_pb2 +from google.protobuf.internal import containers as _containers +from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union + +DESCRIPTOR: _descriptor.FileDescriptor + +class Severity(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + UNNECESSARY: _ClassVar[Severity] + NECESSARY: _ClassVar[Severity] + URGENT: _ClassVar[Severity] + CRITICAL: _ClassVar[Severity] +UNNECESSARY: Severity +NECESSARY: Severity +URGENT: Severity +CRITICAL: Severity + +class EchoRequest(_message.Message): + __slots__ = ("content", "error", "severity", "header", "other_header", "request_id", "other_request_id") + CONTENT_FIELD_NUMBER: _ClassVar[int] + ERROR_FIELD_NUMBER: _ClassVar[int] + SEVERITY_FIELD_NUMBER: _ClassVar[int] + HEADER_FIELD_NUMBER: _ClassVar[int] + OTHER_HEADER_FIELD_NUMBER: _ClassVar[int] + REQUEST_ID_FIELD_NUMBER: _ClassVar[int] + OTHER_REQUEST_ID_FIELD_NUMBER: _ClassVar[int] + content: str + error: _status_pb2.Status + severity: Severity + header: str + other_header: str + request_id: str + other_request_id: str + def __init__(self, content: _Optional[str] = ..., error: _Optional[_Union[_status_pb2.Status, _Mapping]] = ..., severity: _Optional[_Union[Severity, str]] = ..., header: _Optional[str] = ..., other_header: _Optional[str] = ..., request_id: _Optional[str] = ..., other_request_id: _Optional[str] = ...) -> None: ... + +class EchoResponse(_message.Message): + __slots__ = ("content", "severity", "request_id", "other_request_id") + CONTENT_FIELD_NUMBER: _ClassVar[int] + SEVERITY_FIELD_NUMBER: _ClassVar[int] + REQUEST_ID_FIELD_NUMBER: _ClassVar[int] + OTHER_REQUEST_ID_FIELD_NUMBER: _ClassVar[int] + content: str + severity: Severity + request_id: str + other_request_id: str + def __init__(self, content: _Optional[str] = ..., severity: _Optional[_Union[Severity, str]] = ..., request_id: _Optional[str] = ..., other_request_id: _Optional[str] = ...) -> None: ... + +class EchoErrorDetailsRequest(_message.Message): + __slots__ = ("single_detail_text", "multi_detail_text") + SINGLE_DETAIL_TEXT_FIELD_NUMBER: _ClassVar[int] + MULTI_DETAIL_TEXT_FIELD_NUMBER: _ClassVar[int] + single_detail_text: str + multi_detail_text: _containers.RepeatedScalarFieldContainer[str] + def __init__(self, single_detail_text: _Optional[str] = ..., multi_detail_text: _Optional[_Iterable[str]] = ...) -> None: ... + +class EchoErrorDetailsResponse(_message.Message): + __slots__ = ("single_detail", "multiple_details") + class SingleDetail(_message.Message): + __slots__ = ("error",) + ERROR_FIELD_NUMBER: _ClassVar[int] + error: ErrorWithSingleDetail + def __init__(self, error: _Optional[_Union[ErrorWithSingleDetail, _Mapping]] = ...) -> None: ... + class MultipleDetails(_message.Message): + __slots__ = ("error",) + ERROR_FIELD_NUMBER: _ClassVar[int] + error: ErrorWithMultipleDetails + def __init__(self, error: _Optional[_Union[ErrorWithMultipleDetails, _Mapping]] = ...) -> None: ... + SINGLE_DETAIL_FIELD_NUMBER: _ClassVar[int] + MULTIPLE_DETAILS_FIELD_NUMBER: _ClassVar[int] + single_detail: EchoErrorDetailsResponse.SingleDetail + multiple_details: EchoErrorDetailsResponse.MultipleDetails + def __init__(self, single_detail: _Optional[_Union[EchoErrorDetailsResponse.SingleDetail, _Mapping]] = ..., multiple_details: _Optional[_Union[EchoErrorDetailsResponse.MultipleDetails, _Mapping]] = ...) -> None: ... + +class ErrorWithSingleDetail(_message.Message): + __slots__ = ("details",) + DETAILS_FIELD_NUMBER: _ClassVar[int] + details: _any_pb2.Any + def __init__(self, details: _Optional[_Union[_any_pb2.Any, _Mapping]] = ...) -> None: ... + +class ErrorWithMultipleDetails(_message.Message): + __slots__ = ("details",) + DETAILS_FIELD_NUMBER: _ClassVar[int] + details: _containers.RepeatedCompositeFieldContainer[_any_pb2.Any] + def __init__(self, details: _Optional[_Iterable[_Union[_any_pb2.Any, _Mapping]]] = ...) -> None: ... + +class ExpandRequest(_message.Message): + __slots__ = ("content", "error", "stream_wait_time") + CONTENT_FIELD_NUMBER: _ClassVar[int] + ERROR_FIELD_NUMBER: _ClassVar[int] + STREAM_WAIT_TIME_FIELD_NUMBER: _ClassVar[int] + content: str + error: _status_pb2.Status + stream_wait_time: _duration_pb2.Duration + def __init__(self, content: _Optional[str] = ..., error: _Optional[_Union[_status_pb2.Status, _Mapping]] = ..., stream_wait_time: _Optional[_Union[_duration_pb2.Duration, _Mapping]] = ...) -> None: ... + +class PagedExpandRequest(_message.Message): + __slots__ = ("content", "page_size", "page_token") + CONTENT_FIELD_NUMBER: _ClassVar[int] + PAGE_SIZE_FIELD_NUMBER: _ClassVar[int] + PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + content: str + page_size: int + page_token: str + def __init__(self, content: _Optional[str] = ..., page_size: _Optional[int] = ..., page_token: _Optional[str] = ...) -> None: ... + +class PagedExpandLegacyRequest(_message.Message): + __slots__ = ("content", "max_results", "page_token") + CONTENT_FIELD_NUMBER: _ClassVar[int] + MAX_RESULTS_FIELD_NUMBER: _ClassVar[int] + PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + content: str + max_results: int + page_token: str + def __init__(self, content: _Optional[str] = ..., max_results: _Optional[int] = ..., page_token: _Optional[str] = ...) -> None: ... + +class PagedExpandResponse(_message.Message): + __slots__ = ("responses", "next_page_token") + RESPONSES_FIELD_NUMBER: _ClassVar[int] + NEXT_PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + responses: _containers.RepeatedCompositeFieldContainer[EchoResponse] + next_page_token: str + def __init__(self, responses: _Optional[_Iterable[_Union[EchoResponse, _Mapping]]] = ..., next_page_token: _Optional[str] = ...) -> None: ... + +class PagedExpandResponseList(_message.Message): + __slots__ = ("words",) + WORDS_FIELD_NUMBER: _ClassVar[int] + words: _containers.RepeatedScalarFieldContainer[str] + def __init__(self, words: _Optional[_Iterable[str]] = ...) -> None: ... + +class PagedExpandLegacyMappedResponse(_message.Message): + __slots__ = ("alphabetized", "next_page_token") + class AlphabetizedEntry(_message.Message): + __slots__ = ("key", "value") + KEY_FIELD_NUMBER: _ClassVar[int] + VALUE_FIELD_NUMBER: _ClassVar[int] + key: str + value: PagedExpandResponseList + def __init__(self, key: _Optional[str] = ..., value: _Optional[_Union[PagedExpandResponseList, _Mapping]] = ...) -> None: ... + ALPHABETIZED_FIELD_NUMBER: _ClassVar[int] + NEXT_PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + alphabetized: _containers.MessageMap[str, PagedExpandResponseList] + next_page_token: str + def __init__(self, alphabetized: _Optional[_Mapping[str, PagedExpandResponseList]] = ..., next_page_token: _Optional[str] = ...) -> None: ... + +class WaitRequest(_message.Message): + __slots__ = ("end_time", "ttl", "error", "success") + END_TIME_FIELD_NUMBER: _ClassVar[int] + TTL_FIELD_NUMBER: _ClassVar[int] + ERROR_FIELD_NUMBER: _ClassVar[int] + SUCCESS_FIELD_NUMBER: _ClassVar[int] + end_time: _timestamp_pb2.Timestamp + ttl: _duration_pb2.Duration + error: _status_pb2.Status + success: WaitResponse + def __init__(self, end_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., ttl: _Optional[_Union[_duration_pb2.Duration, _Mapping]] = ..., error: _Optional[_Union[_status_pb2.Status, _Mapping]] = ..., success: _Optional[_Union[WaitResponse, _Mapping]] = ...) -> None: ... + +class WaitResponse(_message.Message): + __slots__ = ("content",) + CONTENT_FIELD_NUMBER: _ClassVar[int] + content: str + def __init__(self, content: _Optional[str] = ...) -> None: ... + +class WaitMetadata(_message.Message): + __slots__ = ("end_time",) + END_TIME_FIELD_NUMBER: _ClassVar[int] + end_time: _timestamp_pb2.Timestamp + def __init__(self, end_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ... + +class BlockRequest(_message.Message): + __slots__ = ("response_delay", "error", "success") + RESPONSE_DELAY_FIELD_NUMBER: _ClassVar[int] + ERROR_FIELD_NUMBER: _ClassVar[int] + SUCCESS_FIELD_NUMBER: _ClassVar[int] + response_delay: _duration_pb2.Duration + error: _status_pb2.Status + success: BlockResponse + def __init__(self, response_delay: _Optional[_Union[_duration_pb2.Duration, _Mapping]] = ..., error: _Optional[_Union[_status_pb2.Status, _Mapping]] = ..., success: _Optional[_Union[BlockResponse, _Mapping]] = ...) -> None: ... + +class BlockResponse(_message.Message): + __slots__ = ("content",) + CONTENT_FIELD_NUMBER: _ClassVar[int] + content: str + def __init__(self, content: _Optional[str] = ...) -> None: ... diff --git a/tests/system/resources/identity_pb2.py b/tests/system/resources/identity_pb2.py new file mode 100644 index 0000000000..43047f9a82 --- /dev/null +++ b/tests/system/resources/identity_pb2.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE +# source: google/showcase/v1beta1/identity.proto +# Protobuf Python Version: 5.28.3 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, + 5, + 28, + 3, + '', + 'google/showcase/v1beta1/identity.proto' +) +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.api import client_pb2 as google_dot_api_dot_client__pb2 +from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 +from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from google.protobuf import field_mask_pb2 as google_dot_protobuf_dot_field__mask__pb2 +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n&google/showcase/v1beta1/identity.proto\x12\x17google.showcase.v1beta1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x84\x03\n\x04User\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x19\n\x0c\x64isplay_name\x18\x02 \x01(\tB\x03\xe0\x41\x02\x12\x12\n\x05\x65mail\x18\x03 \x01(\tB\x03\xe0\x41\x02\x12\x34\n\x0b\x63reate_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x03\x12\x34\n\x0bupdate_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x03\x12\x10\n\x03\x61ge\x18\x06 \x01(\x05H\x00\x88\x01\x01\x12\x18\n\x0bheight_feet\x18\x07 \x01(\x01H\x01\x88\x01\x01\x12\x15\n\x08nickname\x18\x08 \x01(\tH\x02\x88\x01\x01\x12!\n\x14\x65nable_notifications\x18\t \x01(\x08H\x03\x88\x01\x01:/\xea\x41,\n\x1cshowcase.googleapis.com/User\x12\x0cusers/{user}B\x06\n\x04_ageB\x0e\n\x0c_height_feetB\x0b\n\t_nicknameB\x17\n\x15_enable_notifications\"@\n\x11\x43reateUserRequest\x12+\n\x04user\x18\x01 \x01(\x0b\x32\x1d.google.showcase.v1beta1.User\"D\n\x0eGetUserRequest\x12\x32\n\x04name\x18\x01 \x01(\tB$\xe0\x41\x02\xfa\x41\x1e\n\x1cshowcase.googleapis.com/User\"q\n\x11UpdateUserRequest\x12+\n\x04user\x18\x01 \x01(\x0b\x32\x1d.google.showcase.v1beta1.User\x12/\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMask\"G\n\x11\x44\x65leteUserRequest\x12\x32\n\x04name\x18\x01 \x01(\tB$\xe0\x41\x02\xfa\x41\x1e\n\x1cshowcase.googleapis.com/User\"9\n\x10ListUsersRequest\x12\x11\n\tpage_size\x18\x01 \x01(\x05\x12\x12\n\npage_token\x18\x02 \x01(\t\"Z\n\x11ListUsersResponse\x12,\n\x05users\x18\x01 \x03(\x0b\x32\x1d.google.showcase.v1beta1.User\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t2\x8a\x06\n\x08Identity\x12\xf3\x01\n\nCreateUser\x12*.google.showcase.v1beta1.CreateUserRequest\x1a\x1d.google.showcase.v1beta1.User\"\x99\x01\xda\x41\x1cuser.display_name,user.email\xda\x41^user.display_name,user.email,user.age,user.nickname,user.enable_notifications,user.height_feet\x82\xd3\xe4\x93\x02\x13\"\x0e/v1beta1/users:\x01*\x12y\n\x07GetUser\x12\'.google.showcase.v1beta1.GetUserRequest\x1a\x1d.google.showcase.v1beta1.User\"&\xda\x41\x04name\x82\xd3\xe4\x93\x02\x19\x12\x17/v1beta1/{name=users/*}\x12\x83\x01\n\nUpdateUser\x12*.google.showcase.v1beta1.UpdateUserRequest\x1a\x1d.google.showcase.v1beta1.User\"*\x82\xd3\xe4\x93\x02$2\x1c/v1beta1/{user.name=users/*}:\x04user\x12x\n\nDeleteUser\x12*.google.showcase.v1beta1.DeleteUserRequest\x1a\x16.google.protobuf.Empty\"&\xda\x41\x04name\x82\xd3\xe4\x93\x02\x19*\x17/v1beta1/{name=users/*}\x12z\n\tListUsers\x12).google.showcase.v1beta1.ListUsersRequest\x1a*.google.showcase.v1beta1.ListUsersResponse\"\x16\x82\xd3\xe4\x93\x02\x10\x12\x0e/v1beta1/users\x1a\x11\xca\x41\x0elocalhost:7469Bq\n\x1b\x63om.google.showcase.v1beta1P\x01Z4github.com/googleapis/gapic-showcase/server/genproto\xea\x02\x19Google::Showcase::V1beta1b\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'google.showcase.v1beta1.identity_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + _globals['DESCRIPTOR']._loaded_options = None + _globals['DESCRIPTOR']._serialized_options = b'\n\033com.google.showcase.v1beta1P\001Z4github.com/googleapis/gapic-showcase/server/genproto\352\002\031Google::Showcase::V1beta1' + _globals['_USER'].fields_by_name['display_name']._loaded_options = None + _globals['_USER'].fields_by_name['display_name']._serialized_options = b'\340A\002' + _globals['_USER'].fields_by_name['email']._loaded_options = None + _globals['_USER'].fields_by_name['email']._serialized_options = b'\340A\002' + _globals['_USER'].fields_by_name['create_time']._loaded_options = None + _globals['_USER'].fields_by_name['create_time']._serialized_options = b'\340A\003' + _globals['_USER'].fields_by_name['update_time']._loaded_options = None + _globals['_USER'].fields_by_name['update_time']._serialized_options = b'\340A\003' + _globals['_USER']._loaded_options = None + _globals['_USER']._serialized_options = b'\352A,\n\034showcase.googleapis.com/User\022\014users/{user}' + _globals['_GETUSERREQUEST'].fields_by_name['name']._loaded_options = None + _globals['_GETUSERREQUEST'].fields_by_name['name']._serialized_options = b'\340A\002\372A\036\n\034showcase.googleapis.com/User' + _globals['_DELETEUSERREQUEST'].fields_by_name['name']._loaded_options = None + _globals['_DELETEUSERREQUEST'].fields_by_name['name']._serialized_options = b'\340A\002\372A\036\n\034showcase.googleapis.com/User' + _globals['_IDENTITY']._loaded_options = None + _globals['_IDENTITY']._serialized_options = b'\312A\016localhost:7469' + _globals['_IDENTITY'].methods_by_name['CreateUser']._loaded_options = None + _globals['_IDENTITY'].methods_by_name['CreateUser']._serialized_options = b'\332A\034user.display_name,user.email\332A^user.display_name,user.email,user.age,user.nickname,user.enable_notifications,user.height_feet\202\323\344\223\002\023\"\016/v1beta1/users:\001*' + _globals['_IDENTITY'].methods_by_name['GetUser']._loaded_options = None + _globals['_IDENTITY'].methods_by_name['GetUser']._serialized_options = b'\332A\004name\202\323\344\223\002\031\022\027/v1beta1/{name=users/*}' + _globals['_IDENTITY'].methods_by_name['UpdateUser']._loaded_options = None + _globals['_IDENTITY'].methods_by_name['UpdateUser']._serialized_options = b'\202\323\344\223\002$2\034/v1beta1/{user.name=users/*}:\004user' + _globals['_IDENTITY'].methods_by_name['DeleteUser']._loaded_options = None + _globals['_IDENTITY'].methods_by_name['DeleteUser']._serialized_options = b'\332A\004name\202\323\344\223\002\031*\027/v1beta1/{name=users/*}' + _globals['_IDENTITY'].methods_by_name['ListUsers']._loaded_options = None + _globals['_IDENTITY'].methods_by_name['ListUsers']._serialized_options = b'\202\323\344\223\002\020\022\016/v1beta1/users' + _globals['_USER']._serialized_start=279 + _globals['_USER']._serialized_end=667 + _globals['_CREATEUSERREQUEST']._serialized_start=669 + _globals['_CREATEUSERREQUEST']._serialized_end=733 + _globals['_GETUSERREQUEST']._serialized_start=735 + _globals['_GETUSERREQUEST']._serialized_end=803 + _globals['_UPDATEUSERREQUEST']._serialized_start=805 + _globals['_UPDATEUSERREQUEST']._serialized_end=918 + _globals['_DELETEUSERREQUEST']._serialized_start=920 + _globals['_DELETEUSERREQUEST']._serialized_end=991 + _globals['_LISTUSERSREQUEST']._serialized_start=993 + _globals['_LISTUSERSREQUEST']._serialized_end=1050 + _globals['_LISTUSERSRESPONSE']._serialized_start=1052 + _globals['_LISTUSERSRESPONSE']._serialized_end=1142 + _globals['_IDENTITY']._serialized_start=1145 + _globals['_IDENTITY']._serialized_end=1923 +# @@protoc_insertion_point(module_scope) diff --git a/tests/system/resources/identity_pb2.pyi b/tests/system/resources/identity_pb2.pyi new file mode 100644 index 0000000000..95bec4773b --- /dev/null +++ b/tests/system/resources/identity_pb2.pyi @@ -0,0 +1,77 @@ +from google.api import annotations_pb2 as _annotations_pb2 +from google.api import client_pb2 as _client_pb2 +from google.api import field_behavior_pb2 as _field_behavior_pb2 +from google.api import resource_pb2 as _resource_pb2 +from google.protobuf import empty_pb2 as _empty_pb2 +from google.protobuf import field_mask_pb2 as _field_mask_pb2 +from google.protobuf import timestamp_pb2 as _timestamp_pb2 +from google.protobuf.internal import containers as _containers +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union + +DESCRIPTOR: _descriptor.FileDescriptor + +class User(_message.Message): + __slots__ = ("name", "display_name", "email", "create_time", "update_time", "age", "height_feet", "nickname", "enable_notifications") + NAME_FIELD_NUMBER: _ClassVar[int] + DISPLAY_NAME_FIELD_NUMBER: _ClassVar[int] + EMAIL_FIELD_NUMBER: _ClassVar[int] + CREATE_TIME_FIELD_NUMBER: _ClassVar[int] + UPDATE_TIME_FIELD_NUMBER: _ClassVar[int] + AGE_FIELD_NUMBER: _ClassVar[int] + HEIGHT_FEET_FIELD_NUMBER: _ClassVar[int] + NICKNAME_FIELD_NUMBER: _ClassVar[int] + ENABLE_NOTIFICATIONS_FIELD_NUMBER: _ClassVar[int] + name: str + display_name: str + email: str + create_time: _timestamp_pb2.Timestamp + update_time: _timestamp_pb2.Timestamp + age: int + height_feet: float + nickname: str + enable_notifications: bool + def __init__(self, name: _Optional[str] = ..., display_name: _Optional[str] = ..., email: _Optional[str] = ..., create_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., update_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., age: _Optional[int] = ..., height_feet: _Optional[float] = ..., nickname: _Optional[str] = ..., enable_notifications: bool = ...) -> None: ... + +class CreateUserRequest(_message.Message): + __slots__ = ("user",) + USER_FIELD_NUMBER: _ClassVar[int] + user: User + def __init__(self, user: _Optional[_Union[User, _Mapping]] = ...) -> None: ... + +class GetUserRequest(_message.Message): + __slots__ = ("name",) + NAME_FIELD_NUMBER: _ClassVar[int] + name: str + def __init__(self, name: _Optional[str] = ...) -> None: ... + +class UpdateUserRequest(_message.Message): + __slots__ = ("user", "update_mask") + USER_FIELD_NUMBER: _ClassVar[int] + UPDATE_MASK_FIELD_NUMBER: _ClassVar[int] + user: User + update_mask: _field_mask_pb2.FieldMask + def __init__(self, user: _Optional[_Union[User, _Mapping]] = ..., update_mask: _Optional[_Union[_field_mask_pb2.FieldMask, _Mapping]] = ...) -> None: ... + +class DeleteUserRequest(_message.Message): + __slots__ = ("name",) + NAME_FIELD_NUMBER: _ClassVar[int] + name: str + def __init__(self, name: _Optional[str] = ...) -> None: ... + +class ListUsersRequest(_message.Message): + __slots__ = ("page_size", "page_token") + PAGE_SIZE_FIELD_NUMBER: _ClassVar[int] + PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + page_size: int + page_token: str + def __init__(self, page_size: _Optional[int] = ..., page_token: _Optional[str] = ...) -> None: ... + +class ListUsersResponse(_message.Message): + __slots__ = ("users", "next_page_token") + USERS_FIELD_NUMBER: _ClassVar[int] + NEXT_PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + users: _containers.RepeatedCompositeFieldContainer[User] + next_page_token: str + def __init__(self, users: _Optional[_Iterable[_Union[User, _Mapping]]] = ..., next_page_token: _Optional[str] = ...) -> None: ... diff --git a/tests/system/resources/messaging_pb2.py b/tests/system/resources/messaging_pb2.py new file mode 100644 index 0000000000..94066c475e --- /dev/null +++ b/tests/system/resources/messaging_pb2.py @@ -0,0 +1,158 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE +# source: google/showcase/v1beta1/messaging.proto +# Protobuf Python Version: 5.28.3 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, + 5, + 28, + 3, + '', + 'google/showcase/v1beta1/messaging.proto' +) +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.api import client_pb2 as google_dot_api_dot_client__pb2 +from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 +from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 +from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from google.protobuf import field_mask_pb2 as google_dot_protobuf_dot_field__mask__pb2 +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 +from google.rpc import error_details_pb2 as google_dot_rpc_dot_error__details__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\'google/showcase/v1beta1/messaging.proto\x12\x17google.showcase.v1beta1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a#google/longrunning/operations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1egoogle/rpc/error_details.proto\"\xe1\x01\n\x04Room\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x19\n\x0c\x64isplay_name\x18\x02 \x01(\tB\x03\xe0\x41\x02\x12\x13\n\x0b\x64\x65scription\x18\x03 \x01(\t\x12\x34\n\x0b\x63reate_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x03\x12\x34\n\x0bupdate_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x03:/\xea\x41,\n\x1cshowcase.googleapis.com/Room\x12\x0crooms/{room}\"@\n\x11\x43reateRoomRequest\x12+\n\x04room\x18\x01 \x01(\x0b\x32\x1d.google.showcase.v1beta1.Room\"D\n\x0eGetRoomRequest\x12\x32\n\x04name\x18\x01 \x01(\tB$\xe0\x41\x02\xfa\x41\x1e\n\x1cshowcase.googleapis.com/Room\"q\n\x11UpdateRoomRequest\x12+\n\x04room\x18\x01 \x01(\x0b\x32\x1d.google.showcase.v1beta1.Room\x12/\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMask\"G\n\x11\x44\x65leteRoomRequest\x12\x32\n\x04name\x18\x01 \x01(\tB$\xe0\x41\x02\xfa\x41\x1e\n\x1cshowcase.googleapis.com/Room\"9\n\x10ListRoomsRequest\x12\x11\n\tpage_size\x18\x01 \x01(\x05\x12\x12\n\npage_token\x18\x02 \x01(\t\"Z\n\x11ListRoomsResponse\x12,\n\x05rooms\x18\x01 \x03(\x0b\x32\x1d.google.showcase.v1beta1.Room\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"\xf6\x03\n\x05\x42lurb\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x32\n\x04user\x18\x02 \x01(\tB$\xe0\x41\x02\xfa\x41\x1e\n\x1cshowcase.googleapis.com/User\x12\x0e\n\x04text\x18\x03 \x01(\tH\x00\x12\x0f\n\x05image\x18\x04 \x01(\x0cH\x00\x12\x34\n\x0b\x63reate_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x03\x12\x34\n\x0bupdate_time\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x03\x12\x18\n\x0elegacy_room_id\x18\x07 \x01(\tH\x01\x12\x18\n\x0elegacy_user_id\x18\x08 \x01(\tH\x01:\xd1\x01\xea\x41\xcd\x01\n\x1dshowcase.googleapis.com/Blurb\x12\x38users/{user}/profile/blurbs/legacy/{legacy_user}~{blurb}\x12#users/{user}/profile/blurbs/{blurb}\x12\x1brooms/{room}/blurbs/{blurb}\x12\x30rooms/{room}/blurbs/legacy/{legacy_room}.{blurb}B\t\n\x07\x63ontentB\x0b\n\tlegacy_id\"z\n\x12\x43reateBlurbRequest\x12\x35\n\x06parent\x18\x01 \x01(\tB%\xe0\x41\x02\xfa\x41\x1f\x12\x1dshowcase.googleapis.com/Blurb\x12-\n\x05\x62lurb\x18\x02 \x01(\x0b\x32\x1e.google.showcase.v1beta1.Blurb\"F\n\x0fGetBlurbRequest\x12\x33\n\x04name\x18\x01 \x01(\tB%\xe0\x41\x02\xfa\x41\x1f\n\x1dshowcase.googleapis.com/Blurb\"t\n\x12UpdateBlurbRequest\x12-\n\x05\x62lurb\x18\x01 \x01(\x0b\x32\x1e.google.showcase.v1beta1.Blurb\x12/\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMask\"I\n\x12\x44\x65leteBlurbRequest\x12\x33\n\x04name\x18\x01 \x01(\tB%\xe0\x41\x02\xfa\x41\x1f\n\x1dshowcase.googleapis.com/Blurb\"q\n\x11ListBlurbsRequest\x12\x35\n\x06parent\x18\x01 \x01(\tB%\xe0\x41\x02\xfa\x41\x1f\x12\x1dshowcase.googleapis.com/Blurb\x12\x11\n\tpage_size\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\"]\n\x12ListBlurbsResponse\x12.\n\x06\x62lurbs\x18\x01 \x03(\x0b\x32\x1e.google.showcase.v1beta1.Blurb\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"\x84\x01\n\x13SearchBlurbsRequest\x12\x12\n\x05query\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x32\n\x06parent\x18\x02 \x01(\tB\"\xfa\x41\x1f\x12\x1dshowcase.googleapis.com/Blurb\x12\x11\n\tpage_size\x18\x03 \x01(\x05\x12\x12\n\npage_token\x18\x04 \x01(\t\"A\n\x14SearchBlurbsMetadata\x12)\n\nretry_info\x18\x01 \x01(\x0b\x32\x15.google.rpc.RetryInfo\"_\n\x14SearchBlurbsResponse\x12.\n\x06\x62lurbs\x18\x01 \x03(\x0b\x32\x1e.google.showcase.v1beta1.Blurb\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"\x80\x01\n\x13StreamBlurbsRequest\x12\x33\n\x04name\x18\x01 \x01(\tB%\xe0\x41\x02\xfa\x41\x1f\x12\x1dshowcase.googleapis.com/Blurb\x12\x34\n\x0b\x65xpire_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x02\"\xd1\x01\n\x14StreamBlurbsResponse\x12-\n\x05\x62lurb\x18\x01 \x01(\x0b\x32\x1e.google.showcase.v1beta1.Blurb\x12\x44\n\x06\x61\x63tion\x18\x02 \x01(\x0e\x32\x34.google.showcase.v1beta1.StreamBlurbsResponse.Action\"D\n\x06\x41\x63tion\x12\x16\n\x12\x41\x43TION_UNSPECIFIED\x10\x00\x12\n\n\x06\x43REATE\x10\x01\x12\n\n\x06UPDATE\x10\x02\x12\n\n\x06\x44\x45LETE\x10\x03\"#\n\x12SendBlurbsResponse\x12\r\n\x05names\x18\x01 \x03(\t\"\xda\x01\n\x0e\x43onnectRequest\x12G\n\x06\x63onfig\x18\x01 \x01(\x0b\x32\x35.google.showcase.v1beta1.ConnectRequest.ConnectConfigH\x00\x12/\n\x05\x62lurb\x18\x02 \x01(\x0b\x32\x1e.google.showcase.v1beta1.BlurbH\x00\x1a\x43\n\rConnectConfig\x12\x32\n\x06parent\x18\x01 \x01(\tB\"\xfa\x41\x1f\x12\x1dshowcase.googleapis.com/BlurbB\t\n\x07request2\xb4\x13\n\tMessaging\x12\x97\x01\n\nCreateRoom\x12*.google.showcase.v1beta1.CreateRoomRequest\x1a\x1d.google.showcase.v1beta1.Room\">\xda\x41\"room.display_name,room.description\x82\xd3\xe4\x93\x02\x13\"\x0e/v1beta1/rooms:\x01*\x12y\n\x07GetRoom\x12\'.google.showcase.v1beta1.GetRoomRequest\x1a\x1d.google.showcase.v1beta1.Room\"&\xda\x41\x04name\x82\xd3\xe4\x93\x02\x19\x12\x17/v1beta1/{name=rooms/*}\x12\x83\x01\n\nUpdateRoom\x12*.google.showcase.v1beta1.UpdateRoomRequest\x1a\x1d.google.showcase.v1beta1.Room\"*\x82\xd3\xe4\x93\x02$2\x1c/v1beta1/{room.name=rooms/*}:\x04room\x12x\n\nDeleteRoom\x12*.google.showcase.v1beta1.DeleteRoomRequest\x1a\x16.google.protobuf.Empty\"&\xda\x41\x04name\x82\xd3\xe4\x93\x02\x19*\x17/v1beta1/{name=rooms/*}\x12z\n\tListRooms\x12).google.showcase.v1beta1.ListRoomsRequest\x1a*.google.showcase.v1beta1.ListRoomsResponse\"\x16\x82\xd3\xe4\x93\x02\x10\x12\x0e/v1beta1/rooms\x12\xf6\x01\n\x0b\x43reateBlurb\x12+.google.showcase.v1beta1.CreateBlurbRequest\x1a\x1e.google.showcase.v1beta1.Blurb\"\x99\x01\xda\x41\x1cparent,blurb.user,blurb.text\xda\x41\x1dparent,blurb.user,blurb.image\x82\xd3\xe4\x93\x02T\" /v1beta1/{parent=rooms/*}/blurbs:\x01*Z-\"(/v1beta1/{parent=users/*/profile}/blurbs:\x01*\x12\xb1\x01\n\x08GetBlurb\x12(.google.showcase.v1beta1.GetBlurbRequest\x1a\x1e.google.showcase.v1beta1.Blurb\"[\xda\x41\x04name\x82\xd3\xe4\x93\x02N\x12 /v1beta1/{name=rooms/*/blurbs/*}Z*\x12(/v1beta1/{name=users/*/profile/blurbs/*}\x12\xca\x01\n\x0bUpdateBlurb\x12+.google.showcase.v1beta1.UpdateBlurbRequest\x1a\x1e.google.showcase.v1beta1.Blurb\"n\x82\xd3\xe4\x93\x02h2&/v1beta1/{blurb.name=rooms/*/blurbs/*}:\x05\x62lurbZ72./v1beta1/{blurb.name=users/*/profile/blurbs/*}:\x05\x62lurb\x12\xaf\x01\n\x0b\x44\x65leteBlurb\x12+.google.showcase.v1beta1.DeleteBlurbRequest\x1a\x16.google.protobuf.Empty\"[\xda\x41\x04name\x82\xd3\xe4\x93\x02N* /v1beta1/{name=rooms/*/blurbs/*}Z**(/v1beta1/{name=users/*/profile/blurbs/*}\x12\xc4\x01\n\nListBlurbs\x12*.google.showcase.v1beta1.ListBlurbsRequest\x1a+.google.showcase.v1beta1.ListBlurbsResponse\"]\xda\x41\x06parent\x82\xd3\xe4\x93\x02N\x12 /v1beta1/{parent=rooms/*}/blurbsZ*\x12(/v1beta1/{parent=users/*/profile}/blurbs\x12\x81\x02\n\x0cSearchBlurbs\x12,.google.showcase.v1beta1.SearchBlurbsRequest\x1a\x1d.google.longrunning.Operation\"\xa3\x01\xca\x41,\n\x14SearchBlurbsResponse\x12\x14SearchBlurbsMetadata\xda\x41\x0cparent,query\x82\xd3\xe4\x93\x02_\"\'/v1beta1/{parent=rooms/*}/blurbs:search:\x01*Z1\"//v1beta1/{parent=users/*/profile}/blurbs:search\x12\xd3\x01\n\x0cStreamBlurbs\x12,.google.showcase.v1beta1.StreamBlurbsRequest\x1a-.google.showcase.v1beta1.StreamBlurbsResponse\"d\x82\xd3\xe4\x93\x02^\"%/v1beta1/{name=rooms/*}/blurbs:stream:\x01*Z2\"-/v1beta1/{name=users/*/profile}/blurbs:stream:\x01*0\x01\x12\xce\x01\n\nSendBlurbs\x12+.google.showcase.v1beta1.CreateBlurbRequest\x1a+.google.showcase.v1beta1.SendBlurbsResponse\"d\x82\xd3\xe4\x93\x02^\"%/v1beta1/{parent=rooms/*}/blurbs:send:\x01*Z2\"-/v1beta1/{parent=users/*/profile}/blurbs:send:\x01*(\x01\x12\x65\n\x07\x43onnect\x12\'.google.showcase.v1beta1.ConnectRequest\x1a-.google.showcase.v1beta1.StreamBlurbsResponse(\x01\x30\x01\x1a\x11\xca\x41\x0elocalhost:7469Bq\n\x1b\x63om.google.showcase.v1beta1P\x01Z4github.com/googleapis/gapic-showcase/server/genproto\xea\x02\x19Google::Showcase::V1beta1b\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'google.showcase.v1beta1.messaging_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + _globals['DESCRIPTOR']._loaded_options = None + _globals['DESCRIPTOR']._serialized_options = b'\n\033com.google.showcase.v1beta1P\001Z4github.com/googleapis/gapic-showcase/server/genproto\352\002\031Google::Showcase::V1beta1' + _globals['_ROOM'].fields_by_name['display_name']._loaded_options = None + _globals['_ROOM'].fields_by_name['display_name']._serialized_options = b'\340A\002' + _globals['_ROOM'].fields_by_name['create_time']._loaded_options = None + _globals['_ROOM'].fields_by_name['create_time']._serialized_options = b'\340A\003' + _globals['_ROOM'].fields_by_name['update_time']._loaded_options = None + _globals['_ROOM'].fields_by_name['update_time']._serialized_options = b'\340A\003' + _globals['_ROOM']._loaded_options = None + _globals['_ROOM']._serialized_options = b'\352A,\n\034showcase.googleapis.com/Room\022\014rooms/{room}' + _globals['_GETROOMREQUEST'].fields_by_name['name']._loaded_options = None + _globals['_GETROOMREQUEST'].fields_by_name['name']._serialized_options = b'\340A\002\372A\036\n\034showcase.googleapis.com/Room' + _globals['_DELETEROOMREQUEST'].fields_by_name['name']._loaded_options = None + _globals['_DELETEROOMREQUEST'].fields_by_name['name']._serialized_options = b'\340A\002\372A\036\n\034showcase.googleapis.com/Room' + _globals['_BLURB'].fields_by_name['user']._loaded_options = None + _globals['_BLURB'].fields_by_name['user']._serialized_options = b'\340A\002\372A\036\n\034showcase.googleapis.com/User' + _globals['_BLURB'].fields_by_name['create_time']._loaded_options = None + _globals['_BLURB'].fields_by_name['create_time']._serialized_options = b'\340A\003' + _globals['_BLURB'].fields_by_name['update_time']._loaded_options = None + _globals['_BLURB'].fields_by_name['update_time']._serialized_options = b'\340A\003' + _globals['_BLURB']._loaded_options = None + _globals['_BLURB']._serialized_options = b'\352A\315\001\n\035showcase.googleapis.com/Blurb\0228users/{user}/profile/blurbs/legacy/{legacy_user}~{blurb}\022#users/{user}/profile/blurbs/{blurb}\022\033rooms/{room}/blurbs/{blurb}\0220rooms/{room}/blurbs/legacy/{legacy_room}.{blurb}' + _globals['_CREATEBLURBREQUEST'].fields_by_name['parent']._loaded_options = None + _globals['_CREATEBLURBREQUEST'].fields_by_name['parent']._serialized_options = b'\340A\002\372A\037\022\035showcase.googleapis.com/Blurb' + _globals['_GETBLURBREQUEST'].fields_by_name['name']._loaded_options = None + _globals['_GETBLURBREQUEST'].fields_by_name['name']._serialized_options = b'\340A\002\372A\037\n\035showcase.googleapis.com/Blurb' + _globals['_DELETEBLURBREQUEST'].fields_by_name['name']._loaded_options = None + _globals['_DELETEBLURBREQUEST'].fields_by_name['name']._serialized_options = b'\340A\002\372A\037\n\035showcase.googleapis.com/Blurb' + _globals['_LISTBLURBSREQUEST'].fields_by_name['parent']._loaded_options = None + _globals['_LISTBLURBSREQUEST'].fields_by_name['parent']._serialized_options = b'\340A\002\372A\037\022\035showcase.googleapis.com/Blurb' + _globals['_SEARCHBLURBSREQUEST'].fields_by_name['query']._loaded_options = None + _globals['_SEARCHBLURBSREQUEST'].fields_by_name['query']._serialized_options = b'\340A\002' + _globals['_SEARCHBLURBSREQUEST'].fields_by_name['parent']._loaded_options = None + _globals['_SEARCHBLURBSREQUEST'].fields_by_name['parent']._serialized_options = b'\372A\037\022\035showcase.googleapis.com/Blurb' + _globals['_STREAMBLURBSREQUEST'].fields_by_name['name']._loaded_options = None + _globals['_STREAMBLURBSREQUEST'].fields_by_name['name']._serialized_options = b'\340A\002\372A\037\022\035showcase.googleapis.com/Blurb' + _globals['_STREAMBLURBSREQUEST'].fields_by_name['expire_time']._loaded_options = None + _globals['_STREAMBLURBSREQUEST'].fields_by_name['expire_time']._serialized_options = b'\340A\002' + _globals['_CONNECTREQUEST_CONNECTCONFIG'].fields_by_name['parent']._loaded_options = None + _globals['_CONNECTREQUEST_CONNECTCONFIG'].fields_by_name['parent']._serialized_options = b'\372A\037\022\035showcase.googleapis.com/Blurb' + _globals['_MESSAGING']._loaded_options = None + _globals['_MESSAGING']._serialized_options = b'\312A\016localhost:7469' + _globals['_MESSAGING'].methods_by_name['CreateRoom']._loaded_options = None + _globals['_MESSAGING'].methods_by_name['CreateRoom']._serialized_options = b'\332A\"room.display_name,room.description\202\323\344\223\002\023\"\016/v1beta1/rooms:\001*' + _globals['_MESSAGING'].methods_by_name['GetRoom']._loaded_options = None + _globals['_MESSAGING'].methods_by_name['GetRoom']._serialized_options = b'\332A\004name\202\323\344\223\002\031\022\027/v1beta1/{name=rooms/*}' + _globals['_MESSAGING'].methods_by_name['UpdateRoom']._loaded_options = None + _globals['_MESSAGING'].methods_by_name['UpdateRoom']._serialized_options = b'\202\323\344\223\002$2\034/v1beta1/{room.name=rooms/*}:\004room' + _globals['_MESSAGING'].methods_by_name['DeleteRoom']._loaded_options = None + _globals['_MESSAGING'].methods_by_name['DeleteRoom']._serialized_options = b'\332A\004name\202\323\344\223\002\031*\027/v1beta1/{name=rooms/*}' + _globals['_MESSAGING'].methods_by_name['ListRooms']._loaded_options = None + _globals['_MESSAGING'].methods_by_name['ListRooms']._serialized_options = b'\202\323\344\223\002\020\022\016/v1beta1/rooms' + _globals['_MESSAGING'].methods_by_name['CreateBlurb']._loaded_options = None + _globals['_MESSAGING'].methods_by_name['CreateBlurb']._serialized_options = b'\332A\034parent,blurb.user,blurb.text\332A\035parent,blurb.user,blurb.image\202\323\344\223\002T\" /v1beta1/{parent=rooms/*}/blurbs:\001*Z-\"(/v1beta1/{parent=users/*/profile}/blurbs:\001*' + _globals['_MESSAGING'].methods_by_name['GetBlurb']._loaded_options = None + _globals['_MESSAGING'].methods_by_name['GetBlurb']._serialized_options = b'\332A\004name\202\323\344\223\002N\022 /v1beta1/{name=rooms/*/blurbs/*}Z*\022(/v1beta1/{name=users/*/profile/blurbs/*}' + _globals['_MESSAGING'].methods_by_name['UpdateBlurb']._loaded_options = None + _globals['_MESSAGING'].methods_by_name['UpdateBlurb']._serialized_options = b'\202\323\344\223\002h2&/v1beta1/{blurb.name=rooms/*/blurbs/*}:\005blurbZ72./v1beta1/{blurb.name=users/*/profile/blurbs/*}:\005blurb' + _globals['_MESSAGING'].methods_by_name['DeleteBlurb']._loaded_options = None + _globals['_MESSAGING'].methods_by_name['DeleteBlurb']._serialized_options = b'\332A\004name\202\323\344\223\002N* /v1beta1/{name=rooms/*/blurbs/*}Z**(/v1beta1/{name=users/*/profile/blurbs/*}' + _globals['_MESSAGING'].methods_by_name['ListBlurbs']._loaded_options = None + _globals['_MESSAGING'].methods_by_name['ListBlurbs']._serialized_options = b'\332A\006parent\202\323\344\223\002N\022 /v1beta1/{parent=rooms/*}/blurbsZ*\022(/v1beta1/{parent=users/*/profile}/blurbs' + _globals['_MESSAGING'].methods_by_name['SearchBlurbs']._loaded_options = None + _globals['_MESSAGING'].methods_by_name['SearchBlurbs']._serialized_options = b'\312A,\n\024SearchBlurbsResponse\022\024SearchBlurbsMetadata\332A\014parent,query\202\323\344\223\002_\"\'/v1beta1/{parent=rooms/*}/blurbs:search:\001*Z1\"//v1beta1/{parent=users/*/profile}/blurbs:search' + _globals['_MESSAGING'].methods_by_name['StreamBlurbs']._loaded_options = None + _globals['_MESSAGING'].methods_by_name['StreamBlurbs']._serialized_options = b'\202\323\344\223\002^\"%/v1beta1/{name=rooms/*}/blurbs:stream:\001*Z2\"-/v1beta1/{name=users/*/profile}/blurbs:stream:\001*' + _globals['_MESSAGING'].methods_by_name['SendBlurbs']._loaded_options = None + _globals['_MESSAGING'].methods_by_name['SendBlurbs']._serialized_options = b'\202\323\344\223\002^\"%/v1beta1/{parent=rooms/*}/blurbs:send:\001*Z2\"-/v1beta1/{parent=users/*/profile}/blurbs:send:\001*' + _globals['_ROOM']._serialized_start=349 + _globals['_ROOM']._serialized_end=574 + _globals['_CREATEROOMREQUEST']._serialized_start=576 + _globals['_CREATEROOMREQUEST']._serialized_end=640 + _globals['_GETROOMREQUEST']._serialized_start=642 + _globals['_GETROOMREQUEST']._serialized_end=710 + _globals['_UPDATEROOMREQUEST']._serialized_start=712 + _globals['_UPDATEROOMREQUEST']._serialized_end=825 + _globals['_DELETEROOMREQUEST']._serialized_start=827 + _globals['_DELETEROOMREQUEST']._serialized_end=898 + _globals['_LISTROOMSREQUEST']._serialized_start=900 + _globals['_LISTROOMSREQUEST']._serialized_end=957 + _globals['_LISTROOMSRESPONSE']._serialized_start=959 + _globals['_LISTROOMSRESPONSE']._serialized_end=1049 + _globals['_BLURB']._serialized_start=1052 + _globals['_BLURB']._serialized_end=1554 + _globals['_CREATEBLURBREQUEST']._serialized_start=1556 + _globals['_CREATEBLURBREQUEST']._serialized_end=1678 + _globals['_GETBLURBREQUEST']._serialized_start=1680 + _globals['_GETBLURBREQUEST']._serialized_end=1750 + _globals['_UPDATEBLURBREQUEST']._serialized_start=1752 + _globals['_UPDATEBLURBREQUEST']._serialized_end=1868 + _globals['_DELETEBLURBREQUEST']._serialized_start=1870 + _globals['_DELETEBLURBREQUEST']._serialized_end=1943 + _globals['_LISTBLURBSREQUEST']._serialized_start=1945 + _globals['_LISTBLURBSREQUEST']._serialized_end=2058 + _globals['_LISTBLURBSRESPONSE']._serialized_start=2060 + _globals['_LISTBLURBSRESPONSE']._serialized_end=2153 + _globals['_SEARCHBLURBSREQUEST']._serialized_start=2156 + _globals['_SEARCHBLURBSREQUEST']._serialized_end=2288 + _globals['_SEARCHBLURBSMETADATA']._serialized_start=2290 + _globals['_SEARCHBLURBSMETADATA']._serialized_end=2355 + _globals['_SEARCHBLURBSRESPONSE']._serialized_start=2357 + _globals['_SEARCHBLURBSRESPONSE']._serialized_end=2452 + _globals['_STREAMBLURBSREQUEST']._serialized_start=2455 + _globals['_STREAMBLURBSREQUEST']._serialized_end=2583 + _globals['_STREAMBLURBSRESPONSE']._serialized_start=2586 + _globals['_STREAMBLURBSRESPONSE']._serialized_end=2795 + _globals['_STREAMBLURBSRESPONSE_ACTION']._serialized_start=2727 + _globals['_STREAMBLURBSRESPONSE_ACTION']._serialized_end=2795 + _globals['_SENDBLURBSRESPONSE']._serialized_start=2797 + _globals['_SENDBLURBSRESPONSE']._serialized_end=2832 + _globals['_CONNECTREQUEST']._serialized_start=2835 + _globals['_CONNECTREQUEST']._serialized_end=3053 + _globals['_CONNECTREQUEST_CONNECTCONFIG']._serialized_start=2975 + _globals['_CONNECTREQUEST_CONNECTCONFIG']._serialized_end=3042 + _globals['_MESSAGING']._serialized_start=3056 + _globals['_MESSAGING']._serialized_end=5540 +# @@protoc_insertion_point(module_scope) diff --git a/tests/system/resources/messaging_pb2.pyi b/tests/system/resources/messaging_pb2.pyi new file mode 100644 index 0000000000..b57c2f496d --- /dev/null +++ b/tests/system/resources/messaging_pb2.pyi @@ -0,0 +1,209 @@ +from google.api import annotations_pb2 as _annotations_pb2 +from google.api import client_pb2 as _client_pb2 +from google.api import field_behavior_pb2 as _field_behavior_pb2 +from google.api import resource_pb2 as _resource_pb2 +from google.longrunning import operations_pb2 as _operations_pb2 +from google.protobuf import empty_pb2 as _empty_pb2 +from google.protobuf import field_mask_pb2 as _field_mask_pb2 +from google.protobuf import timestamp_pb2 as _timestamp_pb2 +from google.rpc import error_details_pb2 as _error_details_pb2 +from google.protobuf.internal import containers as _containers +from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union + +DESCRIPTOR: _descriptor.FileDescriptor + +class Room(_message.Message): + __slots__ = ("name", "display_name", "description", "create_time", "update_time") + NAME_FIELD_NUMBER: _ClassVar[int] + DISPLAY_NAME_FIELD_NUMBER: _ClassVar[int] + DESCRIPTION_FIELD_NUMBER: _ClassVar[int] + CREATE_TIME_FIELD_NUMBER: _ClassVar[int] + UPDATE_TIME_FIELD_NUMBER: _ClassVar[int] + name: str + display_name: str + description: str + create_time: _timestamp_pb2.Timestamp + update_time: _timestamp_pb2.Timestamp + def __init__(self, name: _Optional[str] = ..., display_name: _Optional[str] = ..., description: _Optional[str] = ..., create_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., update_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ... + +class CreateRoomRequest(_message.Message): + __slots__ = ("room",) + ROOM_FIELD_NUMBER: _ClassVar[int] + room: Room + def __init__(self, room: _Optional[_Union[Room, _Mapping]] = ...) -> None: ... + +class GetRoomRequest(_message.Message): + __slots__ = ("name",) + NAME_FIELD_NUMBER: _ClassVar[int] + name: str + def __init__(self, name: _Optional[str] = ...) -> None: ... + +class UpdateRoomRequest(_message.Message): + __slots__ = ("room", "update_mask") + ROOM_FIELD_NUMBER: _ClassVar[int] + UPDATE_MASK_FIELD_NUMBER: _ClassVar[int] + room: Room + update_mask: _field_mask_pb2.FieldMask + def __init__(self, room: _Optional[_Union[Room, _Mapping]] = ..., update_mask: _Optional[_Union[_field_mask_pb2.FieldMask, _Mapping]] = ...) -> None: ... + +class DeleteRoomRequest(_message.Message): + __slots__ = ("name",) + NAME_FIELD_NUMBER: _ClassVar[int] + name: str + def __init__(self, name: _Optional[str] = ...) -> None: ... + +class ListRoomsRequest(_message.Message): + __slots__ = ("page_size", "page_token") + PAGE_SIZE_FIELD_NUMBER: _ClassVar[int] + PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + page_size: int + page_token: str + def __init__(self, page_size: _Optional[int] = ..., page_token: _Optional[str] = ...) -> None: ... + +class ListRoomsResponse(_message.Message): + __slots__ = ("rooms", "next_page_token") + ROOMS_FIELD_NUMBER: _ClassVar[int] + NEXT_PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + rooms: _containers.RepeatedCompositeFieldContainer[Room] + next_page_token: str + def __init__(self, rooms: _Optional[_Iterable[_Union[Room, _Mapping]]] = ..., next_page_token: _Optional[str] = ...) -> None: ... + +class Blurb(_message.Message): + __slots__ = ("name", "user", "text", "image", "create_time", "update_time", "legacy_room_id", "legacy_user_id") + NAME_FIELD_NUMBER: _ClassVar[int] + USER_FIELD_NUMBER: _ClassVar[int] + TEXT_FIELD_NUMBER: _ClassVar[int] + IMAGE_FIELD_NUMBER: _ClassVar[int] + CREATE_TIME_FIELD_NUMBER: _ClassVar[int] + UPDATE_TIME_FIELD_NUMBER: _ClassVar[int] + LEGACY_ROOM_ID_FIELD_NUMBER: _ClassVar[int] + LEGACY_USER_ID_FIELD_NUMBER: _ClassVar[int] + name: str + user: str + text: str + image: bytes + create_time: _timestamp_pb2.Timestamp + update_time: _timestamp_pb2.Timestamp + legacy_room_id: str + legacy_user_id: str + def __init__(self, name: _Optional[str] = ..., user: _Optional[str] = ..., text: _Optional[str] = ..., image: _Optional[bytes] = ..., create_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., update_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., legacy_room_id: _Optional[str] = ..., legacy_user_id: _Optional[str] = ...) -> None: ... + +class CreateBlurbRequest(_message.Message): + __slots__ = ("parent", "blurb") + PARENT_FIELD_NUMBER: _ClassVar[int] + BLURB_FIELD_NUMBER: _ClassVar[int] + parent: str + blurb: Blurb + def __init__(self, parent: _Optional[str] = ..., blurb: _Optional[_Union[Blurb, _Mapping]] = ...) -> None: ... + +class GetBlurbRequest(_message.Message): + __slots__ = ("name",) + NAME_FIELD_NUMBER: _ClassVar[int] + name: str + def __init__(self, name: _Optional[str] = ...) -> None: ... + +class UpdateBlurbRequest(_message.Message): + __slots__ = ("blurb", "update_mask") + BLURB_FIELD_NUMBER: _ClassVar[int] + UPDATE_MASK_FIELD_NUMBER: _ClassVar[int] + blurb: Blurb + update_mask: _field_mask_pb2.FieldMask + def __init__(self, blurb: _Optional[_Union[Blurb, _Mapping]] = ..., update_mask: _Optional[_Union[_field_mask_pb2.FieldMask, _Mapping]] = ...) -> None: ... + +class DeleteBlurbRequest(_message.Message): + __slots__ = ("name",) + NAME_FIELD_NUMBER: _ClassVar[int] + name: str + def __init__(self, name: _Optional[str] = ...) -> None: ... + +class ListBlurbsRequest(_message.Message): + __slots__ = ("parent", "page_size", "page_token") + PARENT_FIELD_NUMBER: _ClassVar[int] + PAGE_SIZE_FIELD_NUMBER: _ClassVar[int] + PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + parent: str + page_size: int + page_token: str + def __init__(self, parent: _Optional[str] = ..., page_size: _Optional[int] = ..., page_token: _Optional[str] = ...) -> None: ... + +class ListBlurbsResponse(_message.Message): + __slots__ = ("blurbs", "next_page_token") + BLURBS_FIELD_NUMBER: _ClassVar[int] + NEXT_PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + blurbs: _containers.RepeatedCompositeFieldContainer[Blurb] + next_page_token: str + def __init__(self, blurbs: _Optional[_Iterable[_Union[Blurb, _Mapping]]] = ..., next_page_token: _Optional[str] = ...) -> None: ... + +class SearchBlurbsRequest(_message.Message): + __slots__ = ("query", "parent", "page_size", "page_token") + QUERY_FIELD_NUMBER: _ClassVar[int] + PARENT_FIELD_NUMBER: _ClassVar[int] + PAGE_SIZE_FIELD_NUMBER: _ClassVar[int] + PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + query: str + parent: str + page_size: int + page_token: str + def __init__(self, query: _Optional[str] = ..., parent: _Optional[str] = ..., page_size: _Optional[int] = ..., page_token: _Optional[str] = ...) -> None: ... + +class SearchBlurbsMetadata(_message.Message): + __slots__ = ("retry_info",) + RETRY_INFO_FIELD_NUMBER: _ClassVar[int] + retry_info: _error_details_pb2.RetryInfo + def __init__(self, retry_info: _Optional[_Union[_error_details_pb2.RetryInfo, _Mapping]] = ...) -> None: ... + +class SearchBlurbsResponse(_message.Message): + __slots__ = ("blurbs", "next_page_token") + BLURBS_FIELD_NUMBER: _ClassVar[int] + NEXT_PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int] + blurbs: _containers.RepeatedCompositeFieldContainer[Blurb] + next_page_token: str + def __init__(self, blurbs: _Optional[_Iterable[_Union[Blurb, _Mapping]]] = ..., next_page_token: _Optional[str] = ...) -> None: ... + +class StreamBlurbsRequest(_message.Message): + __slots__ = ("name", "expire_time") + NAME_FIELD_NUMBER: _ClassVar[int] + EXPIRE_TIME_FIELD_NUMBER: _ClassVar[int] + name: str + expire_time: _timestamp_pb2.Timestamp + def __init__(self, name: _Optional[str] = ..., expire_time: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ...) -> None: ... + +class StreamBlurbsResponse(_message.Message): + __slots__ = ("blurb", "action") + class Action(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): + __slots__ = () + ACTION_UNSPECIFIED: _ClassVar[StreamBlurbsResponse.Action] + CREATE: _ClassVar[StreamBlurbsResponse.Action] + UPDATE: _ClassVar[StreamBlurbsResponse.Action] + DELETE: _ClassVar[StreamBlurbsResponse.Action] + ACTION_UNSPECIFIED: StreamBlurbsResponse.Action + CREATE: StreamBlurbsResponse.Action + UPDATE: StreamBlurbsResponse.Action + DELETE: StreamBlurbsResponse.Action + BLURB_FIELD_NUMBER: _ClassVar[int] + ACTION_FIELD_NUMBER: _ClassVar[int] + blurb: Blurb + action: StreamBlurbsResponse.Action + def __init__(self, blurb: _Optional[_Union[Blurb, _Mapping]] = ..., action: _Optional[_Union[StreamBlurbsResponse.Action, str]] = ...) -> None: ... + +class SendBlurbsResponse(_message.Message): + __slots__ = ("names",) + NAMES_FIELD_NUMBER: _ClassVar[int] + names: _containers.RepeatedScalarFieldContainer[str] + def __init__(self, names: _Optional[_Iterable[str]] = ...) -> None: ... + +class ConnectRequest(_message.Message): + __slots__ = ("config", "blurb") + class ConnectConfig(_message.Message): + __slots__ = ("parent",) + PARENT_FIELD_NUMBER: _ClassVar[int] + parent: str + def __init__(self, parent: _Optional[str] = ...) -> None: ... + CONFIG_FIELD_NUMBER: _ClassVar[int] + BLURB_FIELD_NUMBER: _ClassVar[int] + config: ConnectRequest.ConnectConfig + blurb: Blurb + def __init__(self, config: _Optional[_Union[ConnectRequest.ConnectConfig, _Mapping]] = ..., blurb: _Optional[_Union[Blurb, _Mapping]] = ...) -> None: ... From 5fc7d97ea185855022ff329237bebfc9c15c58a9 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 15 Nov 2024 16:21:00 +0000 Subject: [PATCH 04/11] add comment --- noxfile.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/noxfile.py b/noxfile.py index 7ace640350..4ac798118b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -294,13 +294,15 @@ def showcase_library( session.run( *cmd_tup, external=True, ) - - shutil.copy("tests/system/resources/echo_pb2.py", f"{tmp_dir}/google/showcase_v1beta1/types/echo_pb2.py") - shutil.copy("tests/system/resources/echo_pb2.pyi", f"{tmp_dir}/google/showcase_v1beta1/types/echo_pb2.pyi") - shutil.copy("tests/system/resources/identity_pb2.py", f"{tmp_dir}/google/showcase_v1beta1/types/identity_pb2.py") - shutil.copy("tests/system/resources/identity_pb2.pyi", f"{tmp_dir}/google/showcase_v1beta1/types/identity_pb2.pyi") - shutil.copy("tests/system/resources/messaging_pb2.py", f"{tmp_dir}/google/showcase_v1beta1/types/messaging_pb2.py") - shutil.copy("tests/system/resources/messaging_pb2.pyi", f"{tmp_dir}/google/showcase_v1beta1/types/messaging_pb2.pyi") + # Temporary code to facilitate testing of nextgen protobuf API + # Piggy back on `rest_async_io_enabled` temporarily + if rest_async_io_enabled: + shutil.copy("tests/system/resources/echo_pb2.py", f"{tmp_dir}/google/showcase_v1beta1/types/echo_pb2.py") + shutil.copy("tests/system/resources/echo_pb2.pyi", f"{tmp_dir}/google/showcase_v1beta1/types/echo_pb2.pyi") + shutil.copy("tests/system/resources/identity_pb2.py", f"{tmp_dir}/google/showcase_v1beta1/types/identity_pb2.py") + shutil.copy("tests/system/resources/identity_pb2.pyi", f"{tmp_dir}/google/showcase_v1beta1/types/identity_pb2.pyi") + shutil.copy("tests/system/resources/messaging_pb2.py", f"{tmp_dir}/google/showcase_v1beta1/types/messaging_pb2.py") + shutil.copy("tests/system/resources/messaging_pb2.pyi", f"{tmp_dir}/google/showcase_v1beta1/types/messaging_pb2.pyi") # Install the generated showcase library. if templates == "DEFAULT": # Use the constraints file for the specific python runtime version. From d83a47b36d5992523e99b8446d213be7c076b6fb Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 15 Nov 2024 17:26:04 +0000 Subject: [PATCH 05/11] Bump minimum protobuf to 5.27.x --- .github/workflows/tests.yaml | 8 +++--- gapic/templates/mypy.ini.j2 | 2 +- gapic/templates/noxfile.py.j2 | 1 - gapic/templates/setup.py.j2 | 13 +++++----- .../templates/testing/constraints-3.7.txt.j2 | 19 -------------- .../templates/testing/constraints-3.8.txt.j2 | 26 ++++++++++++++++--- mypy.ini | 2 +- noxfile.py | 7 +++-- setup.py | 8 +++--- 9 files changed, 42 insertions(+), 44 deletions(-) delete mode 100644 gapic/templates/testing/constraints-3.7.txt.j2 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 3328d87b28..7fb53d263d 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -56,7 +56,7 @@ jobs: # Run showcase tests on the lowest and highest supported runtimes matrix: # TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `showcase_w_rest_async` target when async rest is GA. - python: ["3.7", "3.13"] + python: ["3.8", "3.13"] target: [showcase, showcase_alternative_templates, showcase_w_rest_async] runs-on: ubuntu-latest steps: @@ -140,7 +140,7 @@ jobs: showcase-unit: strategy: matrix: - python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] # TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `_w_rest_async` variant when async rest is GA. variant: ['', _alternative_templates, _mixins, _alternative_templates_mixins, _w_rest_async] runs-on: ubuntu-latest @@ -240,7 +240,7 @@ jobs: unit: strategy: matrix: - python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -261,7 +261,7 @@ jobs: fragment: strategy: matrix: - python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] variant: ['', _alternative_templates] runs-on: ubuntu-latest steps: diff --git a/gapic/templates/mypy.ini.j2 b/gapic/templates/mypy.ini.j2 index 574c5aed39..beaa679a8d 100644 --- a/gapic/templates/mypy.ini.j2 +++ b/gapic/templates/mypy.ini.j2 @@ -1,3 +1,3 @@ [mypy] -python_version = 3.7 +python_version = 3.8 namespace_packages = True diff --git a/gapic/templates/noxfile.py.j2 b/gapic/templates/noxfile.py.j2 index 18505d5434..bcde650ec6 100644 --- a/gapic/templates/noxfile.py.j2 +++ b/gapic/templates/noxfile.py.j2 @@ -13,7 +13,6 @@ import sys import nox # type: ignore ALL_PYTHON = [ - "3.7", "3.8", "3.9", "3.10", diff --git a/gapic/templates/setup.py.j2 b/gapic/templates/setup.py.j2 index 7ebab02cbf..fe147f0d71 100644 --- a/gapic/templates/setup.py.j2 +++ b/gapic/templates/setup.py.j2 @@ -32,14 +32,16 @@ else: release_status = "Development Status :: 5 - Production/Stable" dependencies = [ - "google-api-core[grpc] >= 1.34.1, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*", + {# google-api-core >= 2.19.1 is needed for protobuf 5.x support #} + "google-api-core[grpc] >= 2.19.1, <3.0.0dev", # Exclude incompatible versions of `google-auth` # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", - "proto-plus >= 1.22.3, <2.0.0dev", + {# proto-plus >= 1.24.0 is needed for protobuf 5.x support #} + "proto-plus >= 1.24.0, <2.0.0dev", "proto-plus >= 1.25.0, <2.0.0dev; python_version >= '3.13'", - {# Explicitly exclude protobuf versions mentioned in https://cloud.google.com/support/bulletins#GCP-2022-019 #} - "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", + # protobuf >= 5.27.0 is needed which supports `google.protobuf.runtime_version` + "protobuf>=5.27.0,<6.0.0dev", {% for package_tuple, package_info in pypi_packages.items() %} {# Quick check to make sure the package is different from this setup.py #} {% if api.naming.warehouse_package_name != package_info.package_name %} @@ -86,7 +88,6 @@ setuptools.setup( "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -98,7 +99,7 @@ setuptools.setup( ], platforms="Posix; MacOS X; Windows", packages=packages, - python_requires=">=3.7", + python_requires=">=3.8", install_requires=dependencies, extras_require=extras, include_package_data=True, diff --git a/gapic/templates/testing/constraints-3.7.txt.j2 b/gapic/templates/testing/constraints-3.7.txt.j2 deleted file mode 100644 index 3dbaa6f382..0000000000 --- a/gapic/templates/testing/constraints-3.7.txt.j2 +++ /dev/null @@ -1,19 +0,0 @@ -{% from '_pypi_packages.j2' import pypi_packages %} -# This constraints file is used to check that lower bounds -# are correct in setup.py -# List all library dependencies and extras in this file. -# Pin the version to the lower bound. -# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", -# Then this file should have google-cloud-foo==1.14.0 -google-api-core==1.34.1 -google-auth==2.14.1 -proto-plus==1.22.3 -protobuf==3.20.2 -{% for package_tuple, package_info in pypi_packages.items() %} -{# Quick check to make sure the package is different from this setup.py #} -{% if api.naming.warehouse_package_name != package_info.package_name %} -{% if api.requires_package(package_tuple) %} -{{ package_info.package_name }}=={{ package_info.lower_bound }} -{% endif %} -{% endif %} -{% endfor %} diff --git a/gapic/templates/testing/constraints-3.8.txt.j2 b/gapic/templates/testing/constraints-3.8.txt.j2 index e0f6dc7590..626efb5a28 100644 --- a/gapic/templates/testing/constraints-3.8.txt.j2 +++ b/gapic/templates/testing/constraints-3.8.txt.j2 @@ -1,4 +1,22 @@ -# -*- coding: utf-8 -*- -{% block constraints %} -{% include "testing/_default_constraints.j2" %} -{% endblock %} \ No newline at end of file +{% from '_pypi_packages.j2' import pypi_packages %} +# This constraints file is used to check that lower bounds +# are correct in setup.py +# List all library dependencies and extras in this file. +# Pin the version to the lower bound. +# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", +# Then this file should have google-cloud-foo==1.14.0 +# google-api-core >= 2.19.1 is needed for protobuf 5.x support +google-api-core==2.19.1 +google-auth==2.14.1 +# proto-plus >= 1.24.0 is needed for protobuf 5.x support +proto-plus==1.24.0 +# protobuf 5.27.0 is needed which supports `google.protobuf.runtime_version` +protobuf==5.27.2 +{% for package_tuple, package_info in pypi_packages.items() %} +{# Quick check to make sure the package is different from this setup.py #} +{% if api.naming.warehouse_package_name != package_info.package_name %} +{% if api.requires_package(package_tuple) %} +{{ package_info.package_name }}=={{ package_info.lower_bound }} +{% endif %} +{% endif %} +{% endfor %} diff --git a/mypy.ini b/mypy.ini index 78cfb8988b..f8584b421d 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,2 +1,2 @@ [mypy] -python_version = 3.7 +python_version = 3.8 diff --git a/noxfile.py b/noxfile.py index 4ac798118b..a3e2d8a598 100644 --- a/noxfile.py +++ b/noxfile.py @@ -34,7 +34,6 @@ ALL_PYTHON = ( - "3.7", "3.8", "3.9", "3.10", @@ -314,11 +313,11 @@ def showcase_library( f"{tmp_dir}/testing/constraints-{session.python}.txt" ) # Install the library with a constraints file. - if session.python == "3.7": + if session.python == "3.8": session.install("-e", tmp_dir, "-r", constraints_path) if rest_async_io_enabled: # NOTE: We re-install `google-api-core` and `google-auth` to override the respective - # versions for each specified in constraints-3.7.txt. This is needed because async REST + # versions for each specified in constraints-3.8.txt. This is needed because async REST # is not supported with the minimum version of `google-api-core` and `google-auth`. # TODO(https://github.com/googleapis/gapic-generator-python/issues/2211): Remove hardcoded dependencies # from here and add a new constraints file for testing the minimum supported versions for async REST feature. @@ -454,7 +453,7 @@ def run_showcase_unit_tests(session, fail_under=100, rest_async_io_enabled=False # Run the tests. # NOTE: async rest is not supported against the minimum supported version of google-api-core. # Therefore, we ignore the coverage requirement in this case. - if session.python == "3.7" and rest_async_io_enabled: + if session.python == "3.8" and rest_async_io_enabled: session.run( "py.test", *( diff --git a/setup.py b/setup.py index 0a7a1ee290..109a9eb132 100644 --- a/setup.py +++ b/setup.py @@ -28,14 +28,15 @@ # Ensure that the lower bounds of these dependencies match what we have in the # templated setup.py.j2: https://github.com/googleapis/gapic-generator-python/blob/main/gapic/templates/setup.py.j2 "click >= 6.7", - "google-api-core[grpc] >= 1.34.1, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*", + # google-api-core >= 2.19.1 Required for protobuf 5.x support + "google-api-core[grpc] >= 2.19.1, <3.0.0dev", "googleapis-common-protos >= 1.55.0", "grpcio >= 1.24.3", # 2.11.0 is required which adds the `default` argument to `jinja-filters.map()` # https://jinja.palletsprojects.com/en/3.0.x/templates/#jinja-filters.map # https://jinja.palletsprojects.com/en/2.11.x/changelog/#version-2-11-0 "jinja2 >= 2.11", - "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", + "protobuf>=5.27.0,<6.0.0dev", "pypandoc >= 1.4", "PyYAML >= 5.1.1", "grpc-google-iam-v1 >= 0.12.4, < 1.0.0dev", @@ -70,7 +71,6 @@ "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -82,7 +82,7 @@ "Topic :: Software Development :: Libraries :: Python Modules", ], platforms="Posix; MacOS X", - python_requires=">=3.7", + python_requires=">=3.8", install_requires=dependencies, include_package_data=True, zip_safe=False, From d25f59172dd3ea589a607d3af72a8149cd1dd5e7 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 15 Nov 2024 17:32:29 +0000 Subject: [PATCH 06/11] turn off fail-fast for showcase --- .github/workflows/tests.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 7fb53d263d..3a34fc34cf 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -53,6 +53,7 @@ jobs: run: nox -s mypy-${{ matrix.python }} showcase: strategy: + fail-fast: false # Run showcase tests on the lowest and highest supported runtimes matrix: # TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `showcase_w_rest_async` target when async rest is GA. @@ -138,6 +139,7 @@ jobs: nox -s ${{ matrix.target }} # TODO(yon-mg): add compute unit tests showcase-unit: + fail-fast: false strategy: matrix: python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] From 948a7d2bfaa5be6fb0d528ba4fd3a26a631ab325 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 15 Nov 2024 17:32:58 +0000 Subject: [PATCH 07/11] turn off fail-fast for showcase --- .github/workflows/tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 3a34fc34cf..64c02436be 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -139,8 +139,8 @@ jobs: nox -s ${{ matrix.target }} # TODO(yon-mg): add compute unit tests showcase-unit: - fail-fast: false - strategy: + strategy: + fail-fast: false matrix: python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] # TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `_w_rest_async` variant when async rest is GA. From 3c67fbe6e31f06f37de815e0ba3862cfaa0d6004 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 15 Nov 2024 17:34:50 +0000 Subject: [PATCH 08/11] formatting --- .github/workflows/tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 64c02436be..1f30aba3a1 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -139,8 +139,8 @@ jobs: nox -s ${{ matrix.target }} # TODO(yon-mg): add compute unit tests showcase-unit: - strategy: - fail-fast: false + strategy: + fail-fast: false matrix: python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] # TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `_w_rest_async` variant when async rest is GA. From 434de97591202a4627c34a014d7e6f3d5ed5c3ef Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 19 Nov 2024 19:35:12 +0000 Subject: [PATCH 09/11] update init.py --- .../%name_%version/%sub/__init__.py.j2 | 3 + .../%name_%version/%sub/types/__init__.py.j2 | 5 +- .../redis/google/cloud/redis/__init__.py | 54 ++++++++--------- .../redis/google/cloud/redis_v1/__init__.py | 1 + .../google/cloud/redis_v1/types/__init__.py | 60 +++++++++++++++++++ tests/integration/goldens/redis/mypy.ini | 2 +- tests/integration/goldens/redis/noxfile.py | 1 - tests/integration/goldens/redis/setup.py | 10 ++-- .../goldens/redis/testing/constraints-3.8.txt | 17 ++++-- 9 files changed, 110 insertions(+), 43 deletions(-) diff --git a/gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2 b/gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2 index c2766e9396..978d5ee653 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2 @@ -29,6 +29,9 @@ from .services.{{ service.name|snake_case }} import {{ service.async_client_name -#} {% for proto in api.protos.values()|sort(attribute='name') if proto.meta.address.subpackage == api.subpackage_view %} +{%if protobuf_pythonic_types_enabled %} +from .types import {{ proto.module_name }}_pb2 +{% endif %} {% for message in proto.messages.values()|sort(attribute='name') %} from .types.{{ proto.module_name }}{%if protobuf_pythonic_types_enabled %}_pb2{% endif %} import {{ message.name }} {% endfor %} diff --git a/gapic/templates/%namespace/%name_%version/%sub/types/__init__.py.j2 b/gapic/templates/%namespace/%name_%version/%sub/types/__init__.py.j2 index c02a338fcb..2afc75ceff 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/types/__init__.py.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/types/__init__.py.j2 @@ -4,9 +4,8 @@ {% set protobuf_pythonic_types_enabled = api.all_library_settings[api.naming.proto_package].python_settings.experimental_features.protobuf_pythonic_types_enabled %} -{% if not protobuf_pythonic_types_enabled %} {% for _, proto in api.protos|dictsort if proto.file_to_generate and proto.messages or proto.enums %} -from .{{proto.module_name }} import ( +from .{{proto.module_name }}{%if protobuf_pythonic_types_enabled %}_pb2{% endif %} import ( {% for _, message in proto.messages|dictsort %} {{message.name }}, {% endfor %} @@ -27,6 +26,4 @@ __all__ = ( {% endfor %} ) -{% endif %}{# not protobuf_pythonic_types_enabled #} - {% endblock %} diff --git a/tests/integration/goldens/redis/google/cloud/redis/__init__.py b/tests/integration/goldens/redis/google/cloud/redis/__init__.py index ededc2d374..5c5a53a536 100755 --- a/tests/integration/goldens/redis/google/cloud/redis/__init__.py +++ b/tests/integration/goldens/redis/google/cloud/redis/__init__.py @@ -21,33 +21,33 @@ from google.cloud.redis_v1.services.cloud_redis.client import CloudRedisClient from google.cloud.redis_v1.services.cloud_redis.async_client import CloudRedisAsyncClient -from google.cloud.redis_v1.types.cloud_redis import CreateInstanceRequest -from google.cloud.redis_v1.types.cloud_redis import DeleteInstanceRequest -from google.cloud.redis_v1.types.cloud_redis import ExportInstanceRequest -from google.cloud.redis_v1.types.cloud_redis import FailoverInstanceRequest -from google.cloud.redis_v1.types.cloud_redis import GcsDestination -from google.cloud.redis_v1.types.cloud_redis import GcsSource -from google.cloud.redis_v1.types.cloud_redis import GetInstanceAuthStringRequest -from google.cloud.redis_v1.types.cloud_redis import GetInstanceRequest -from google.cloud.redis_v1.types.cloud_redis import ImportInstanceRequest -from google.cloud.redis_v1.types.cloud_redis import InputConfig -from google.cloud.redis_v1.types.cloud_redis import Instance -from google.cloud.redis_v1.types.cloud_redis import InstanceAuthString -from google.cloud.redis_v1.types.cloud_redis import ListInstancesRequest -from google.cloud.redis_v1.types.cloud_redis import ListInstancesResponse -from google.cloud.redis_v1.types.cloud_redis import LocationMetadata -from google.cloud.redis_v1.types.cloud_redis import MaintenancePolicy -from google.cloud.redis_v1.types.cloud_redis import MaintenanceSchedule -from google.cloud.redis_v1.types.cloud_redis import NodeInfo -from google.cloud.redis_v1.types.cloud_redis import OperationMetadata -from google.cloud.redis_v1.types.cloud_redis import OutputConfig -from google.cloud.redis_v1.types.cloud_redis import PersistenceConfig -from google.cloud.redis_v1.types.cloud_redis import RescheduleMaintenanceRequest -from google.cloud.redis_v1.types.cloud_redis import TlsCertificate -from google.cloud.redis_v1.types.cloud_redis import UpdateInstanceRequest -from google.cloud.redis_v1.types.cloud_redis import UpgradeInstanceRequest -from google.cloud.redis_v1.types.cloud_redis import WeeklyMaintenanceWindow -from google.cloud.redis_v1.types.cloud_redis import ZoneMetadata +from google.cloud.redis_v1.types.cloud_redis_pb2 import CreateInstanceRequest +from google.cloud.redis_v1.types.cloud_redis_pb2 import DeleteInstanceRequest +from google.cloud.redis_v1.types.cloud_redis_pb2 import ExportInstanceRequest +from google.cloud.redis_v1.types.cloud_redis_pb2 import FailoverInstanceRequest +from google.cloud.redis_v1.types.cloud_redis_pb2 import GcsDestination +from google.cloud.redis_v1.types.cloud_redis_pb2 import GcsSource +from google.cloud.redis_v1.types.cloud_redis_pb2 import GetInstanceAuthStringRequest +from google.cloud.redis_v1.types.cloud_redis_pb2 import GetInstanceRequest +from google.cloud.redis_v1.types.cloud_redis_pb2 import ImportInstanceRequest +from google.cloud.redis_v1.types.cloud_redis_pb2 import InputConfig +from google.cloud.redis_v1.types.cloud_redis_pb2 import Instance +from google.cloud.redis_v1.types.cloud_redis_pb2 import InstanceAuthString +from google.cloud.redis_v1.types.cloud_redis_pb2 import ListInstancesRequest +from google.cloud.redis_v1.types.cloud_redis_pb2 import ListInstancesResponse +from google.cloud.redis_v1.types.cloud_redis_pb2 import LocationMetadata +from google.cloud.redis_v1.types.cloud_redis_pb2 import MaintenancePolicy +from google.cloud.redis_v1.types.cloud_redis_pb2 import MaintenanceSchedule +from google.cloud.redis_v1.types.cloud_redis_pb2 import NodeInfo +from google.cloud.redis_v1.types.cloud_redis_pb2 import OperationMetadata +from google.cloud.redis_v1.types.cloud_redis_pb2 import OutputConfig +from google.cloud.redis_v1.types.cloud_redis_pb2 import PersistenceConfig +from google.cloud.redis_v1.types.cloud_redis_pb2 import RescheduleMaintenanceRequest +from google.cloud.redis_v1.types.cloud_redis_pb2 import TlsCertificate +from google.cloud.redis_v1.types.cloud_redis_pb2 import UpdateInstanceRequest +from google.cloud.redis_v1.types.cloud_redis_pb2 import UpgradeInstanceRequest +from google.cloud.redis_v1.types.cloud_redis_pb2 import WeeklyMaintenanceWindow +from google.cloud.redis_v1.types.cloud_redis_pb2 import ZoneMetadata __all__ = ('CloudRedisClient', 'CloudRedisAsyncClient', diff --git a/tests/integration/goldens/redis/google/cloud/redis_v1/__init__.py b/tests/integration/goldens/redis/google/cloud/redis_v1/__init__.py index 03e1bd1f38..a21a6e5161 100755 --- a/tests/integration/goldens/redis/google/cloud/redis_v1/__init__.py +++ b/tests/integration/goldens/redis/google/cloud/redis_v1/__init__.py @@ -21,6 +21,7 @@ from .services.cloud_redis import CloudRedisClient from .services.cloud_redis import CloudRedisAsyncClient +from .types import cloud_redis_pb2 from .types.cloud_redis_pb2 import CreateInstanceRequest from .types.cloud_redis_pb2 import DeleteInstanceRequest from .types.cloud_redis_pb2 import ExportInstanceRequest diff --git a/tests/integration/goldens/redis/google/cloud/redis_v1/types/__init__.py b/tests/integration/goldens/redis/google/cloud/redis_v1/types/__init__.py index 8f6cf06824..5b15e816f7 100755 --- a/tests/integration/goldens/redis/google/cloud/redis_v1/types/__init__.py +++ b/tests/integration/goldens/redis/google/cloud/redis_v1/types/__init__.py @@ -13,3 +13,63 @@ # See the License for the specific language governing permissions and # limitations under the License. # + +from .cloud_redis_pb2 import ( + CreateInstanceRequest, + DeleteInstanceRequest, + ExportInstanceRequest, + FailoverInstanceRequest, + GcsDestination, + GcsSource, + GetInstanceAuthStringRequest, + GetInstanceRequest, + ImportInstanceRequest, + InputConfig, + Instance, + InstanceAuthString, + ListInstancesRequest, + ListInstancesResponse, + LocationMetadata, + MaintenancePolicy, + MaintenanceSchedule, + NodeInfo, + OperationMetadata, + OutputConfig, + PersistenceConfig, + RescheduleMaintenanceRequest, + TlsCertificate, + UpdateInstanceRequest, + UpgradeInstanceRequest, + WeeklyMaintenanceWindow, + ZoneMetadata, +) + +__all__ = ( + 'CreateInstanceRequest', + 'DeleteInstanceRequest', + 'ExportInstanceRequest', + 'FailoverInstanceRequest', + 'GcsDestination', + 'GcsSource', + 'GetInstanceAuthStringRequest', + 'GetInstanceRequest', + 'ImportInstanceRequest', + 'InputConfig', + 'Instance', + 'InstanceAuthString', + 'ListInstancesRequest', + 'ListInstancesResponse', + 'LocationMetadata', + 'MaintenancePolicy', + 'MaintenanceSchedule', + 'NodeInfo', + 'OperationMetadata', + 'OutputConfig', + 'PersistenceConfig', + 'RescheduleMaintenanceRequest', + 'TlsCertificate', + 'UpdateInstanceRequest', + 'UpgradeInstanceRequest', + 'WeeklyMaintenanceWindow', + 'ZoneMetadata', +) diff --git a/tests/integration/goldens/redis/mypy.ini b/tests/integration/goldens/redis/mypy.ini index 574c5aed39..beaa679a8d 100755 --- a/tests/integration/goldens/redis/mypy.ini +++ b/tests/integration/goldens/redis/mypy.ini @@ -1,3 +1,3 @@ [mypy] -python_version = 3.7 +python_version = 3.8 namespace_packages = True diff --git a/tests/integration/goldens/redis/noxfile.py b/tests/integration/goldens/redis/noxfile.py index 755a3329f3..d9a11c629e 100755 --- a/tests/integration/goldens/redis/noxfile.py +++ b/tests/integration/goldens/redis/noxfile.py @@ -24,7 +24,6 @@ import nox # type: ignore ALL_PYTHON = [ - "3.7", "3.8", "3.9", "3.10", diff --git a/tests/integration/goldens/redis/setup.py b/tests/integration/goldens/redis/setup.py index 220725b65c..60c7b53e12 100755 --- a/tests/integration/goldens/redis/setup.py +++ b/tests/integration/goldens/redis/setup.py @@ -39,13 +39,14 @@ release_status = "Development Status :: 5 - Production/Stable" dependencies = [ - "google-api-core[grpc] >= 1.34.1, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*", + "google-api-core[grpc] >= 2.19.1, <3.0.0dev", # Exclude incompatible versions of `google-auth` # See https://github.com/googleapis/google-cloud-python/issues/12364 "google-auth >= 2.14.1, <3.0.0dev,!=2.24.0,!=2.25.0", - "proto-plus >= 1.22.3, <2.0.0dev", + "proto-plus >= 1.24.0, <2.0.0dev", "proto-plus >= 1.25.0, <2.0.0dev; python_version >= '3.13'", - "protobuf>=3.20.2,<6.0.0dev,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", + # protobuf >= 5.27.0 is needed which supports `google.protobuf.runtime_version` + "protobuf>=5.27.0,<6.0.0dev", ] extras = { "async_rest": [ @@ -82,7 +83,6 @@ "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -94,7 +94,7 @@ ], platforms="Posix; MacOS X; Windows", packages=packages, - python_requires=">=3.7", + python_requires=">=3.8", install_requires=dependencies, extras_require=extras, include_package_data=True, diff --git a/tests/integration/goldens/redis/testing/constraints-3.8.txt b/tests/integration/goldens/redis/testing/constraints-3.8.txt index ed7f9aed25..9e2925a4be 100755 --- a/tests/integration/goldens/redis/testing/constraints-3.8.txt +++ b/tests/integration/goldens/redis/testing/constraints-3.8.txt @@ -1,6 +1,13 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. +# This constraints file is used to check that lower bounds +# are correct in setup.py # List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf +# Pin the version to the lower bound. +# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", +# Then this file should have google-cloud-foo==1.14.0 +# google-api-core >= 2.19.1 is needed for protobuf 5.x support +google-api-core==2.19.1 +google-auth==2.14.1 +# proto-plus >= 1.24.0 is needed for protobuf 5.x support +proto-plus==1.24.0 +# protobuf 5.27.0 is needed which supports `google.protobuf.runtime_version` +protobuf==5.27.2 From 1521fcb99530cc48a002b6ee7641df5d61ab29fb Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 26 Aug 2025 16:48:39 -0400 Subject: [PATCH 10/11] fix import --- gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2 | 3 --- 1 file changed, 3 deletions(-) diff --git a/gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2 b/gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2 index 978d5ee653..c2766e9396 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2 @@ -29,9 +29,6 @@ from .services.{{ service.name|snake_case }} import {{ service.async_client_name -#} {% for proto in api.protos.values()|sort(attribute='name') if proto.meta.address.subpackage == api.subpackage_view %} -{%if protobuf_pythonic_types_enabled %} -from .types import {{ proto.module_name }}_pb2 -{% endif %} {% for message in proto.messages.values()|sort(attribute='name') %} from .types.{{ proto.module_name }}{%if protobuf_pythonic_types_enabled %}_pb2{% endif %} import {{ message.name }} {% endfor %} From 39607c1fd7bfec99522c21ee78e148cdee7bd964 Mon Sep 17 00:00:00 2001 From: Ben Karl Date: Mon, 1 Dec 2025 16:19:44 +0000 Subject: [PATCH 11/11] Delete file that prevents Ads library from generating --- .../templates/%namespace/%name/__init__.py.j2 | 75 ------------------- 1 file changed, 75 deletions(-) delete mode 100644 gapic/templates/%namespace/%name/__init__.py.j2 diff --git a/gapic/templates/%namespace/%name/__init__.py.j2 b/gapic/templates/%namespace/%name/__init__.py.j2 deleted file mode 100644 index 0299a9151c..0000000000 --- a/gapic/templates/%namespace/%name/__init__.py.j2 +++ /dev/null @@ -1,75 +0,0 @@ -{% extends '_base.py.j2' %} -{% block content %} - -{% set protobuf_pythonic_types_enabled = api.all_library_settings[api.naming.proto_package].python_settings.experimental_features.protobuf_pythonic_types_enabled %} -{% set package_path = api.naming.module_namespace|join('.') + "." + api.naming.module_name %} -from {{package_path}} import gapic_version as package_version - -__version__ = package_version.__version__ - -{# Import subpackages. -#} -{% for subpackage in api.subpackages|dictsort %} -from {% if api.naming.module_namespace %}{{ api.naming.module_namespace|join('.') }}.{% endif %} - {{- api.naming.versioned_module_name }} import {{ subpackage }} -{% endfor %} - -{# Import services for this package. #} -{% for service in api.services.values()|sort(attribute='name') - if service.meta.address.subpackage == api.subpackage_view %} -from {% if api.naming.module_namespace %}{{ api.naming.module_namespace|join('.') }}.{% endif %} - {{- api.naming.versioned_module_name }}.services.{{ service.name|snake_case }}.client import {{ service.client_name }} -{% if 'grpc' in opts.transport %} -from {% if api.naming.module_namespace %}{{ api.naming.module_namespace|join('.') }}.{% endif %} - {{- api.naming.versioned_module_name }}.services.{{ service.name|snake_case }}.async_client import {{ service.async_client_name }} -{% endif %} -{% endfor %} - -{# Import messages and enums from each proto. - It is safe to import all of the messages into the same namespace here, - because protocol buffers itself enforces selector uniqueness within - a proto package. -#} -{# Import messages from each proto. - It is safe to import all of the messages into the same namespace here, - because protocol buffers itself enforces selector uniqueness within - a proto package. - #} -{% for proto in api.protos.values()|sort(attribute='module_name') - if proto.meta.address.subpackage == api.subpackage_view %} - {% for message in proto.messages.values()|sort(attribute='name') %} -from {% if api.naming.module_namespace %}{{ api.naming.module_namespace|join('.') }}.{% endif %} - {{- api.naming.versioned_module_name }}.types.{{ proto.module_name }}{%if protobuf_pythonic_types_enabled %}_pb2{% endif %} import {{ message.name }} -{% endfor %} -{% for enum in proto.enums.values()|sort(attribute='name') %} -from {% if api.naming.module_namespace %}{{ api.naming.module_namespace|join('.') }}.{% endif %} - {{- api.naming.versioned_module_name }}.types.{{ proto.module_name }}{%if protobuf_pythonic_types_enabled %}_pb2{% endif %} import {{ enum.name }} -{% endfor %}{% endfor %} -{# Define __all__. - This requires the full set of imported names, so we iterate over - them again. -#} - -__all__ = ( -{%- filter indent %} -{% for subpackage, _ in api.subpackages|dictsort %} -'{{ subpackage }}', -{% endfor %} -{% for service in api.services.values()|sort(attribute='name') - if service.meta.address.subpackage == api.subpackage_view %} -'{{ service.client_name }}', - {% if 'grpc' in opts.transport %} -'{{ service.async_client_name }}', - {% endif %} -{% endfor %} -{% for proto in api.protos.values()|sort(attribute='module_name') - if proto.meta.address.subpackage == api.subpackage_view %} -{% for message in proto.messages.values()|sort(attribute='name') %} -'{{ message.name }}', -{% endfor %} -{% for enum in proto.enums.values()|sort(attribute='name') - if proto.meta.address.subpackage == api.subpackage_view %} -'{{ enum.name }}', -{% endfor %}{% endfor %} -{% endfilter %} -) -{% endblock %}