Skip to content

Commit d17f295

Browse files
authored
feat(spanner): add instance replica info; annotate protos, update docstrings (via synth) (#9577)
Closes #9575.
1 parent fdf318c commit d17f295

27 files changed

+1512
-981
lines changed

spanner/google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ def update_database_ddl(
540540
541541
Args:
542542
database (str): Required. The database to update.
543-
statements (list[str]): DDL statements to be applied to the database.
543+
statements (list[str]): Required. DDL statements to be applied to the database.
544544
operation_id (str): If empty, the new update request is assigned an automatically-generated
545545
operation ID. Otherwise, ``operation_id`` is used to construct the name
546546
of the resulting ``Operation``.

spanner/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin.proto

Lines changed: 135 additions & 65 deletions
Large diffs are not rendered by default.

spanner/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2.py

Lines changed: 83 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spanner/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2_grpc.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def CreateDatabase(self, request, context):
9494
have a name of the format `<database_name>/operations/<operation_id>` and
9595
can be used to track preparation of the database. The
9696
[metadata][google.longrunning.Operation.metadata] field type is
97-
[CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata].
98-
The [response][google.longrunning.Operation.response] field type is
97+
[CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata]. The
98+
[response][google.longrunning.Operation.response] field type is
9999
[Database][google.spanner.admin.database.v1.Database], if successful.
100100
"""
101101
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@@ -116,8 +116,7 @@ def UpdateDatabaseDdl(self, request, context):
116116
the format `<database_name>/operations/<operation_id>` and can be used to
117117
track execution of the schema change(s). The
118118
[metadata][google.longrunning.Operation.metadata] field type is
119-
[UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata].
120-
The operation has no response.
119+
[UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The operation has no response.
121120
"""
122121
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
123122
context.set_details("Method not implemented!")
@@ -140,19 +139,20 @@ def GetDatabaseDdl(self, request, context):
140139
raise NotImplementedError("Method not implemented!")
141140

142141
def SetIamPolicy(self, request, context):
143-
"""Sets the access control policy on a database resource. Replaces any
144-
existing policy.
142+
"""Sets the access control policy on a database resource.
143+
Replaces any existing policy.
145144
146-
Authorization requires `spanner.databases.setIamPolicy` permission on
147-
[resource][google.iam.v1.SetIamPolicyRequest.resource].
145+
Authorization requires `spanner.databases.setIamPolicy`
146+
permission on [resource][google.iam.v1.SetIamPolicyRequest.resource].
148147
"""
149148
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
150149
context.set_details("Method not implemented!")
151150
raise NotImplementedError("Method not implemented!")
152151

153152
def GetIamPolicy(self, request, context):
154-
"""Gets the access control policy for a database resource. Returns an empty
155-
policy if a database exists but does not have a policy set.
153+
"""Gets the access control policy for a database resource.
154+
Returns an empty policy if a database exists but does
155+
not have a policy set.
156156
157157
Authorization requires `spanner.databases.getIamPolicy` permission on
158158
[resource][google.iam.v1.GetIamPolicyRequest.resource].
@@ -164,10 +164,10 @@ def GetIamPolicy(self, request, context):
164164
def TestIamPermissions(self, request, context):
165165
"""Returns permissions that the caller has on the specified database resource.
166166
167-
Attempting this RPC on a non-existent Cloud Spanner database will result in
168-
a NOT_FOUND error if the user has `spanner.databases.list` permission on
169-
the containing Cloud Spanner instance. Otherwise returns an empty set of
170-
permissions.
167+
Attempting this RPC on a non-existent Cloud Spanner database will
168+
result in a NOT_FOUND error if the user has
169+
`spanner.databases.list` permission on the containing Cloud
170+
Spanner instance. Otherwise returns an empty set of permissions.
171171
"""
172172
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
173173
context.set_details("Method not implemented!")

spanner/google/cloud/spanner_admin_instance_v1/gapic/enums.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,40 @@ class State(enum.IntEnum):
3636
STATE_UNSPECIFIED = 0
3737
CREATING = 1
3838
READY = 2
39+
40+
41+
class ReplicaInfo(object):
42+
class ReplicaType(enum.IntEnum):
43+
"""
44+
Indicates the type of replica. See the `replica types
45+
documentation <https://cloud.google.com/spanner/docs/replication#replica_types>`__
46+
for more details.
47+
48+
Attributes:
49+
TYPE_UNSPECIFIED (int): Not specified.
50+
READ_WRITE (int): Read-write replicas support both reads and writes. These replicas:
51+
52+
- Maintain a full copy of your data.
53+
- Serve reads.
54+
- Can vote whether to commit a write.
55+
- Participate in leadership election.
56+
- Are eligible to become a leader.
57+
READ_ONLY (int): Read-only replicas only support reads (not writes). Read-only replicas:
58+
59+
- Maintain a full copy of your data.
60+
- Serve reads.
61+
- Do not participate in voting to commit writes.
62+
- Are not eligible to become a leader.
63+
WITNESS (int): Witness replicas don't support reads but do participate in voting to
64+
commit writes. Witness replicas:
65+
66+
- Do not maintain a full copy of data.
67+
- Do not serve reads.
68+
- Vote whether to commit writes.
69+
- Participate in leader election but are not eligible to become leader.
70+
"""
71+
72+
TYPE_UNSPECIFIED = 0
73+
READ_WRITE = 1
74+
READ_ONLY = 2
75+
WITNESS = 3

spanner/google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ def create_instance(
679679
parent (str): Required. The name of the project in which to create the instance.
680680
Values are of the form ``projects/<project>``.
681681
instance_id (str): Required. The ID of the instance to create. Valid identifiers are of the
682-
form ``[a-z][-a-z0-9]*[a-z0-9]`` and must be between 6 and 30 characters
682+
form ``[a-z][-a-z0-9]*[a-z0-9]`` and must be between 2 and 64 characters
683683
in length.
684684
instance (Union[dict, ~google.cloud.spanner_admin_instance_v1.types.Instance]): Required. The instance to create. The name may be omitted, but if
685685
specified must be ``<parent>/instances/<instance_id>``.

0 commit comments

Comments
 (0)