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

Commit d7146eb

Browse files
feat(v1beta1): Support Multiple Read Replicas when creating Instance (#136)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 408360324 Source-Link: googleapis/googleapis@78eb8a2 Source-Link: https://github.com/googleapis/googleapis-gen/commit/89f136d01eb64da196145565f31855cf8c2a3968 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODlmMTM2ZDAxZWI2NGRhMTk2MTQ1NTY1ZjMxODU1Y2Y4YzJhMzk2OCJ9
1 parent 27dfdca commit d7146eb

File tree

8 files changed

+127
-54
lines changed

8 files changed

+127
-54
lines changed

google/cloud/redis_v1beta1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from .types.cloud_redis import ListInstancesRequest
3131
from .types.cloud_redis import ListInstancesResponse
3232
from .types.cloud_redis import LocationMetadata
33+
from .types.cloud_redis import NodeInfo
3334
from .types.cloud_redis import OutputConfig
3435
from .types.cloud_redis import UpdateInstanceRequest
3536
from .types.cloud_redis import UpgradeInstanceRequest
@@ -51,6 +52,7 @@
5152
"ListInstancesRequest",
5253
"ListInstancesResponse",
5354
"LocationMetadata",
55+
"NodeInfo",
5456
"OutputConfig",
5557
"UpdateInstanceRequest",
5658
"UpgradeInstanceRequest",

google/cloud/redis_v1beta1/services/cloud_redis/async_client.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class CloudRedisAsyncClient:
5959
- As such, Redis instances are resources of the form:
6060
``/projects/{project_id}/locations/{location_id}/instances/{instance_id}``
6161
62-
Note that location_id must be refering to a GCP ``region``; for
62+
Note that location_id must be referring to a GCP ``region``; for
6363
example:
6464
6565
- ``projects/redpepper-1290/locations/us-central1/instances/my-redis``
@@ -226,7 +226,7 @@ async def list_instances(
226226
Returns:
227227
google.cloud.redis_v1beta1.services.cloud_redis.pagers.ListInstancesAsyncPager:
228228
Response for
229-
[ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances].
229+
[ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances].
230230
231231
Iterating over this object will yield results and
232232
resolve additional pages automatically.
@@ -364,8 +364,8 @@ async def create_instance(
364364
365365
The creation is executed asynchronously and callers may check
366366
the returned operation to track its progress. Once the operation
367-
is completed the Redis instance will be fully functional.
368-
Completed longrunning.Operation will contain the new instance
367+
is completed the Redis instance will be fully functional. The
368+
completed longrunning.Operation will contain the new instance
369369
object in the response field.
370370
371371
The returned operation is automatically deleted after a few
@@ -498,6 +498,7 @@ async def update_instance(
498498
- ``labels``
499499
- ``memorySizeGb``
500500
- ``redisConfig``
501+
- ``replica_count``
501502
502503
This corresponds to the ``update_mask`` field
503504
on the ``request`` instance; if ``request`` is provided, this
@@ -875,7 +876,7 @@ async def failover_instance(
875876
timeout: float = None,
876877
metadata: Sequence[Tuple[str, str]] = (),
877878
) -> operation_async.AsyncOperation:
878-
r"""Initiates a failover of the master node to current
879+
r"""Initiates a failover of the primary node to current
879880
replica node for a specific STANDARD tier Cloud
880881
Memorystore for Redis instance.
881882

google/cloud/redis_v1beta1/services/cloud_redis/client.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class CloudRedisClient(metaclass=CloudRedisClientMeta):
9494
- As such, Redis instances are resources of the form:
9595
``/projects/{project_id}/locations/{location_id}/instances/{instance_id}``
9696
97-
Note that location_id must be refering to a GCP ``region``; for
97+
Note that location_id must be referring to a GCP ``region``; for
9898
example:
9999
100100
- ``projects/redpepper-1290/locations/us-central1/instances/my-redis``
@@ -416,7 +416,7 @@ def list_instances(
416416
Returns:
417417
google.cloud.redis_v1beta1.services.cloud_redis.pagers.ListInstancesPager:
418418
Response for
419-
[ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances].
419+
[ListInstances][google.cloud.redis.v1beta1.CloudRedis.ListInstances].
420420
421421
Iterating over this object will yield results and
422422
resolve additional pages automatically.
@@ -554,8 +554,8 @@ def create_instance(
554554
555555
The creation is executed asynchronously and callers may check
556556
the returned operation to track its progress. Once the operation
557-
is completed the Redis instance will be fully functional.
558-
Completed longrunning.Operation will contain the new instance
557+
is completed the Redis instance will be fully functional. The
558+
completed longrunning.Operation will contain the new instance
559559
object in the response field.
560560
561561
The returned operation is automatically deleted after a few
@@ -688,6 +688,7 @@ def update_instance(
688688
- ``labels``
689689
- ``memorySizeGb``
690690
- ``redisConfig``
691+
- ``replica_count``
691692
692693
This corresponds to the ``update_mask`` field
693694
on the ``request`` instance; if ``request`` is provided, this
@@ -1065,7 +1066,7 @@ def failover_instance(
10651066
timeout: float = None,
10661067
metadata: Sequence[Tuple[str, str]] = (),
10671068
) -> operation.Operation:
1068-
r"""Initiates a failover of the master node to current
1069+
r"""Initiates a failover of the primary node to current
10691070
replica node for a specific STANDARD tier Cloud
10701071
Memorystore for Redis instance.
10711072

google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class CloudRedisGrpcTransport(CloudRedisTransport):
5050
- As such, Redis instances are resources of the form:
5151
``/projects/{project_id}/locations/{location_id}/instances/{instance_id}``
5252
53-
Note that location_id must be refering to a GCP ``region``; for
53+
Note that location_id must be referring to a GCP ``region``; for
5454
example:
5555
5656
- ``projects/redpepper-1290/locations/us-central1/instances/my-redis``
@@ -339,8 +339,8 @@ def create_instance(
339339
340340
The creation is executed asynchronously and callers may check
341341
the returned operation to track its progress. Once the operation
342-
is completed the Redis instance will be fully functional.
343-
Completed longrunning.Operation will contain the new instance
342+
is completed the Redis instance will be fully functional. The
343+
completed longrunning.Operation will contain the new instance
344344
object in the response field.
345345
346346
The returned operation is automatically deleted after a few
@@ -492,7 +492,7 @@ def failover_instance(
492492
) -> Callable[[cloud_redis.FailoverInstanceRequest], operations_pb2.Operation]:
493493
r"""Return a callable for the failover instance method over gRPC.
494494
495-
Initiates a failover of the master node to current
495+
Initiates a failover of the primary node to current
496496
replica node for a specific STANDARD tier Cloud
497497
Memorystore for Redis instance.
498498

google/cloud/redis_v1beta1/services/cloud_redis/transports/grpc_asyncio.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class CloudRedisGrpcAsyncIOTransport(CloudRedisTransport):
5151
- As such, Redis instances are resources of the form:
5252
``/projects/{project_id}/locations/{location_id}/instances/{instance_id}``
5353
54-
Note that location_id must be refering to a GCP ``region``; for
54+
Note that location_id must be referring to a GCP ``region``; for
5555
example:
5656
5757
- ``projects/redpepper-1290/locations/us-central1/instances/my-redis``
@@ -345,8 +345,8 @@ def create_instance(
345345
346346
The creation is executed asynchronously and callers may check
347347
the returned operation to track its progress. Once the operation
348-
is completed the Redis instance will be fully functional.
349-
Completed longrunning.Operation will contain the new instance
348+
is completed the Redis instance will be fully functional. The
349+
completed longrunning.Operation will contain the new instance
350350
object in the response field.
351351
352352
The returned operation is automatically deleted after a few
@@ -508,7 +508,7 @@ def failover_instance(
508508
]:
509509
r"""Return a callable for the failover instance method over gRPC.
510510
511-
Initiates a failover of the master node to current
511+
Initiates a failover of the primary node to current
512512
replica node for a specific STANDARD tier Cloud
513513
Memorystore for Redis instance.
514514

google/cloud/redis_v1beta1/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
ListInstancesRequest,
2828
ListInstancesResponse,
2929
LocationMetadata,
30+
NodeInfo,
3031
OutputConfig,
3132
UpdateInstanceRequest,
3233
UpgradeInstanceRequest,
@@ -47,6 +48,7 @@
4748
"ListInstancesRequest",
4849
"ListInstancesResponse",
4950
"LocationMetadata",
51+
"NodeInfo",
5052
"OutputConfig",
5153
"UpdateInstanceRequest",
5254
"UpgradeInstanceRequest",

google/cloud/redis_v1beta1/types/cloud_redis.py

Lines changed: 81 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
__protobuf__ = proto.module(
2323
package="google.cloud.redis.v1beta1",
2424
manifest={
25+
"NodeInfo",
2526
"Instance",
2627
"ListInstancesRequest",
2728
"ListInstancesResponse",
@@ -43,6 +44,21 @@
4344
)
4445

4546

47+
class NodeInfo(proto.Message):
48+
r"""Node specific properties.
49+
50+
Attributes:
51+
id (str):
52+
Output only. Node identifying string. e.g.
53+
'node-0', 'node-1'
54+
zone (str):
55+
Output only. Location of the node.
56+
"""
57+
58+
id = proto.Field(proto.STRING, number=1,)
59+
zone = proto.Field(proto.STRING, number=2,)
60+
61+
4662
class Instance(proto.Message):
4763
r"""A Google Cloud Redis instance.
4864
@@ -68,19 +84,21 @@ class Instance(proto.Message):
6884
Resource labels to represent user provided
6985
metadata
7086
location_id (str):
71-
Optional. The zone where the instance will be provisioned.
72-
If not provided, the service will choose a zone for the
73-
instance. For STANDARD_HA tier, instances will be created
74-
across two zones for protection against zonal failures. If
75-
[alternative_location_id][google.cloud.redis.v1beta1.Instance.alternative_location_id]
76-
is also provided, it must be different from
77-
[location_id][google.cloud.redis.v1beta1.Instance.location_id].
87+
Optional. The zone where the instance will be
88+
provisioned. If not provided, the service will
89+
choose a zone from the specified region for the
90+
instance. For standard tier, additional nodes
91+
will be added across multiple zones for
92+
protection against zonal failures. If specified,
93+
at least one node will be provisioned in this
94+
zone.
7895
alternative_location_id (str):
79-
Optional. Only applicable to STANDARD_HA tier which protects
80-
the instance against zonal failures by provisioning it
81-
across two zones. If provided, it must be a different zone
82-
from the one provided in
83-
[location_id][google.cloud.redis.v1beta1.Instance.location_id].
96+
Optional. If specified, at least one node will be
97+
provisioned in this zone in addition to the zone specified
98+
in location_id. Only applicable to standard tier. If
99+
provided, it must be a different zone from the one provided
100+
in [location_id]. Additional nodes beyond the first 2 will
101+
be placed in zones selected by the service.
84102
redis_version (str):
85103
Optional. The version of Redis software. If not provided,
86104
latest supported version will be used. Currently, the
@@ -89,32 +107,29 @@ class Instance(proto.Message):
89107
- ``REDIS_3_2`` for Redis 3.2 compatibility
90108
- ``REDIS_4_0`` for Redis 4.0 compatibility (default)
91109
- ``REDIS_5_0`` for Redis 5.0 compatibility
110+
- ``REDIS_6_X`` for Redis 6.x compatibility
92111
reserved_ip_range (str):
93-
Optional. The CIDR range of internal
94-
addresses that are reserved for this instance.
95-
If not provided, the service will choose an
96-
unused /29 block, for example, 10.0.0.0/29 or
97-
192.168.0.0/29. Ranges must be unique and non-
98-
overlapping with existing subnets in an
99-
authorized network.
112+
Optional. For DIRECT_PEERING mode, the CIDR range of
113+
internal addresses that are reserved for this instance.
114+
Range must be unique and non-overlapping with existing
115+
subnets in an authorized network. For PRIVATE_SERVICE_ACCESS
116+
mode, the name of one allocated IP address ranges associated
117+
with this private service access connection. If not
118+
provided, the service will choose an unused /29 block, for
119+
example, 10.0.0.0/29 or 192.168.0.0/29. For
120+
READ_REPLICAS_ENABLED the default block size is /28.
100121
host (str):
101122
Output only. Hostname or IP address of the
102-
exposed Redis endpoint used by clients to
123+
exposed Redis endpoint used by clients to
103124
connect to the service.
104125
port (int):
105126
Output only. The port number of the exposed
106127
Redis endpoint.
107128
current_location_id (str):
108-
Output only. The current zone where the Redis endpoint is
109-
placed. For Basic Tier instances, this will always be the
110-
same as the
111-
[location_id][google.cloud.redis.v1beta1.Instance.location_id]
112-
provided by the user at creation time. For Standard Tier
113-
instances, this can be either
114-
[location_id][google.cloud.redis.v1beta1.Instance.location_id]
115-
or
116-
[alternative_location_id][google.cloud.redis.v1beta1.Instance.alternative_location_id]
117-
and can change after a failover event.
129+
Output only. The current zone where the Redis primary node
130+
is located. In basic tier, this will always be the same as
131+
[location_id]. In standard tier, this can be the zone of any
132+
node in the instance.
118133
create_time (google.protobuf.timestamp_pb2.Timestamp):
119134
Output only. The time the instance was
120135
created.
@@ -161,9 +176,27 @@ class Instance(proto.Message):
161176
change over time for a given instance so should be checked
162177
before each import/export operation.
163178
connect_mode (google.cloud.redis_v1beta1.types.Instance.ConnectMode):
164-
Optional. The connect mode of Redis instance. If not
165-
provided, default one will be used. Current default:
166-
DIRECT_PEERING.
179+
Optional. The network connect mode of the Redis instance. If
180+
not provided, the connect mode defaults to DIRECT_PEERING.
181+
replica_count (int):
182+
Optional. The number of replica nodes. Valid range for
183+
standard tier is [1-5] and defaults to 1. Valid value for
184+
basic tier is 0 and defaults to 0.
185+
nodes (Sequence[google.cloud.redis_v1beta1.types.NodeInfo]):
186+
Output only. Info per node.
187+
read_endpoint (str):
188+
Output only. Hostname or IP address of the
189+
exposed readonly Redis endpoint. Standard tier
190+
only. Targets all healthy replica nodes in
191+
instance. Replication is asynchronous and
192+
replica nodes will exhibit some lag behind the
193+
primary. Write requests must target 'host'.
194+
read_endpoint_port (int):
195+
Output only. The port number of the exposed
196+
readonly redis endpoint. Standard tier only.
197+
Write requests should target 'port'.
198+
read_replicas_mode (google.cloud.redis_v1beta1.types.Instance.ReadReplicasMode):
199+
Optional. Read replica mode.
167200
"""
168201

169202
class State(proto.Enum):
@@ -190,6 +223,12 @@ class ConnectMode(proto.Enum):
190223
DIRECT_PEERING = 1
191224
PRIVATE_SERVICE_ACCESS = 2
192225

226+
class ReadReplicasMode(proto.Enum):
227+
r"""Read replicas mode."""
228+
READ_REPLICAS_MODE_UNSPECIFIED = 0
229+
READ_REPLICAS_DISABLED = 1
230+
READ_REPLICAS_ENABLED = 2
231+
193232
name = proto.Field(proto.STRING, number=1,)
194233
display_name = proto.Field(proto.STRING, number=2,)
195234
labels = proto.MapField(proto.STRING, proto.STRING, number=3,)
@@ -211,6 +250,11 @@ class ConnectMode(proto.Enum):
211250
authorized_network = proto.Field(proto.STRING, number=20,)
212251
persistence_iam_identity = proto.Field(proto.STRING, number=21,)
213252
connect_mode = proto.Field(proto.ENUM, number=22, enum=ConnectMode,)
253+
replica_count = proto.Field(proto.INT32, number=31,)
254+
nodes = proto.RepeatedField(proto.MESSAGE, number=32, message="NodeInfo",)
255+
read_endpoint = proto.Field(proto.STRING, number=33,)
256+
read_endpoint_port = proto.Field(proto.INT32, number=34,)
257+
read_replicas_mode = proto.Field(proto.ENUM, number=35, enum=ReadReplicasMode,)
214258

215259

216260
class ListInstancesRequest(proto.Message):
@@ -254,9 +298,9 @@ class ListInstancesResponse(proto.Message):
254298
If the ``location_id`` in the parent field of the request is
255299
"-", all regions available to the project are queried, and
256300
the results aggregated. If in such an aggregated query a
257-
location is unavailable, a dummy Redis entry is included in
258-
the response with the ``name`` field set to a value of the
259-
form
301+
location is unavailable, a placeholder Redis entry is
302+
included in the response with the ``name`` field set to a
303+
value of the form
260304
``projects/{project_id}/locations/{location_id}/instances/``-
261305
and the ``status`` field set to ERROR and ``status_message``
262306
field set to "location not available for ListInstances".
@@ -334,6 +378,7 @@ class UpdateInstanceRequest(proto.Message):
334378
- ``labels``
335379
- ``memorySizeGb``
336380
- ``redisConfig``
381+
- ``replica_count``
337382
instance (google.cloud.redis_v1beta1.types.Instance):
338383
Required. Update description. Only fields specified in
339384
update_mask are updated.

0 commit comments

Comments
 (0)