From ec87c082570259d6e16834326859a73f6ee8286a Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 18 Jan 2024 19:59:18 +0530 Subject: [PATCH] feat: add max_commit_delay API (#1078) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(spanner): add proto and enum types PiperOrigin-RevId: 599046867 Source-Link: https://github.com/googleapis/googleapis/commit/64a5bfe1fef67ccad62e49ab398c5c8baa57080c Source-Link: https://github.com/googleapis/googleapis-gen/commit/6e96ab8bb1ec4536c5a0c4d095f53ce0578cb8a4 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNmU5NmFiOGJiMWVjNDUzNmM1YTBjNGQwOTVmNTNjZTA1NzhjYjhhNCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: add max_commit_delay API PiperOrigin-RevId: 599315735 Source-Link: https://github.com/googleapis/googleapis/commit/465a103d01ad515f7bdb48185ffcca9e20aa7e73 Source-Link: https://github.com/googleapis/googleapis-gen/commit/930e2318acbd10fb54d8668d2f2cf19fe413d5a9 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOTMwZTIzMThhY2JkMTBmYjU0ZDg2NjhkMmYyY2YxOWZlNDEzZDVhOSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot Co-authored-by: Sri Harsha CH <57220027+harshachinta@users.noreply.github.com> --- google/cloud/spanner_v1/types/spanner.py | 14 ++++++++++++++ google/cloud/spanner_v1/types/type.py | 18 ++++++++++++++++++ ...adata_google.spanner.admin.database.v1.json | 2 +- ...adata_google.spanner.admin.instance.v1.json | 2 +- .../snippet_metadata_google.spanner.v1.json | 2 +- scripts/fixup_spanner_v1_keywords.py | 2 +- 6 files changed, 36 insertions(+), 4 deletions(-) diff --git a/google/cloud/spanner_v1/types/spanner.py b/google/cloud/spanner_v1/types/spanner.py index 3dbacbe26b..2590c212d2 100644 --- a/google/cloud/spanner_v1/types/spanner.py +++ b/google/cloud/spanner_v1/types/spanner.py @@ -24,6 +24,7 @@ from google.cloud.spanner_v1.types import result_set from google.cloud.spanner_v1.types import transaction as gs_transaction from google.cloud.spanner_v1.types import type as gs_type +from google.protobuf import duration_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore @@ -1434,6 +1435,14 @@ class CommitRequest(proto.Message): be included in the [CommitResponse][google.spanner.v1.CommitResponse.commit_stats]. Default value is ``false``. + max_commit_delay (google.protobuf.duration_pb2.Duration): + Optional. The amount of latency this request + is willing to incur in order to improve + throughput. If this field is not set, Spanner + assumes requests are relatively latency + sensitive and automatically determines an + appropriate delay time. You can specify a + batching delay value between 0 and 500 ms. request_options (google.cloud.spanner_v1.types.RequestOptions): Common options for this request. """ @@ -1462,6 +1471,11 @@ class CommitRequest(proto.Message): proto.BOOL, number=5, ) + max_commit_delay: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=8, + message=duration_pb2.Duration, + ) request_options: "RequestOptions" = proto.Field( proto.MESSAGE, number=6, diff --git a/google/cloud/spanner_v1/types/type.py b/google/cloud/spanner_v1/types/type.py index f25c465dd4..c6ead3bf1e 100644 --- a/google/cloud/spanner_v1/types/type.py +++ b/google/cloud/spanner_v1/types/type.py @@ -94,6 +94,11 @@ class TypeCode(proto.Enum): - Members of a JSON object are not guaranteed to have their order preserved. - JSON array elements will have their order preserved. + PROTO (13): + Encoded as a base64-encoded ``string``, as described in RFC + 4648, section 4. + ENUM (14): + Encoded as ``string``, in decimal format. """ TYPE_CODE_UNSPECIFIED = 0 BOOL = 1 @@ -107,6 +112,8 @@ class TypeCode(proto.Enum): STRUCT = 9 NUMERIC = 10 JSON = 11 + PROTO = 13 + ENUM = 14 class TypeAnnotationCode(proto.Enum): @@ -179,6 +186,13 @@ class Type(proto.Message): typically is not needed to process the content of a value (it doesn't affect serialization) and clients can ignore it on the read path. + proto_type_fqn (str): + If [code][google.spanner.v1.Type.code] == + [PROTO][google.spanner.v1.TypeCode.PROTO] or + [code][google.spanner.v1.Type.code] == + [ENUM][google.spanner.v1.TypeCode.ENUM], then + ``proto_type_fqn`` is the fully qualified name of the proto + type representing the proto/enum definition. """ code: "TypeCode" = proto.Field( @@ -201,6 +215,10 @@ class Type(proto.Message): number=4, enum="TypeAnnotationCode", ) + proto_type_fqn: str = proto.Field( + proto.STRING, + number=5, + ) class StructType(proto.Message): diff --git a/samples/generated_samples/snippet_metadata_google.spanner.admin.database.v1.json b/samples/generated_samples/snippet_metadata_google.spanner.admin.database.v1.json index c6ea090f6d..11932ae5e8 100644 --- a/samples/generated_samples/snippet_metadata_google.spanner.admin.database.v1.json +++ b/samples/generated_samples/snippet_metadata_google.spanner.admin.database.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-spanner-admin-database", - "version": "3.41.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/samples/generated_samples/snippet_metadata_google.spanner.admin.instance.v1.json b/samples/generated_samples/snippet_metadata_google.spanner.admin.instance.v1.json index 340d53926c..9572d4d727 100644 --- a/samples/generated_samples/snippet_metadata_google.spanner.admin.instance.v1.json +++ b/samples/generated_samples/snippet_metadata_google.spanner.admin.instance.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-spanner-admin-instance", - "version": "3.41.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/samples/generated_samples/snippet_metadata_google.spanner.v1.json b/samples/generated_samples/snippet_metadata_google.spanner.v1.json index cb86201769..4384d19e2a 100644 --- a/samples/generated_samples/snippet_metadata_google.spanner.v1.json +++ b/samples/generated_samples/snippet_metadata_google.spanner.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-spanner", - "version": "3.41.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/scripts/fixup_spanner_v1_keywords.py b/scripts/fixup_spanner_v1_keywords.py index f79f70b2dd..939da961f0 100644 --- a/scripts/fixup_spanner_v1_keywords.py +++ b/scripts/fixup_spanner_v1_keywords.py @@ -42,7 +42,7 @@ class spannerCallTransformer(cst.CSTTransformer): 'batch_create_sessions': ('database', 'session_count', 'session_template', ), 'batch_write': ('session', 'mutation_groups', 'request_options', ), 'begin_transaction': ('session', 'options', 'request_options', ), - 'commit': ('session', 'transaction_id', 'single_use_transaction', 'mutations', 'return_commit_stats', 'request_options', ), + 'commit': ('session', 'transaction_id', 'single_use_transaction', 'mutations', 'return_commit_stats', 'max_commit_delay', 'request_options', ), 'create_session': ('database', 'session', ), 'delete_session': ('name', ), 'execute_batch_dml': ('session', 'transaction', 'statements', 'seqno', 'request_options', ),