From b023ab47146159c32ebc64dd09da681ad09c4081 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 9 Feb 2023 20:30:13 +0000 Subject: [PATCH] chore(gitignore): only ignore folders in the top level (#1021) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 507603203 Source-Link: https://togithub.com/googleapis/googleapis/commit/a4f2de456480c0a4ed9feeeaa1f8ee620bbef23a Source-Link: https://togithub.com/googleapis/googleapis-gen/commit/dcf882154e7c710ecf2a1abc77b35c95f9062371 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZGNmODgyMTU0ZTdjNzEwZWNmMmExYWJjNzdiMzVjOTVmOTA2MjM3MSJ9 BEGIN_NESTED_COMMIT chore: update .gitignore to always include protos folder Use gapic-generator-typescript v3.0.0. PiperOrigin-RevId: 507004755 Source-Link: https://togithub.com/googleapis/googleapis/commit/d784f3c1043616fc0646e9ce7afa1b9161cc02de Source-Link: https://togithub.com/googleapis/googleapis-gen/commit/5e64ba8615f65fdedb1fcd6ac792e5ea621027e4 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNWU2NGJhODYxNWY2NWZkZWRiMWZjZDZhYzc5MmU1ZWE2MjEwMjdlNCJ9 END_NESTED_COMMIT BEGIN_NESTED_COMMIT feat: new transaction options for datastoreV1 PiperOrigin-RevId: 501960571 Source-Link: https://togithub.com/googleapis/googleapis/commit/d4599ad2c2374feb1b508096cbd89e6e3079eb24 Source-Link: https://togithub.com/googleapis/googleapis-gen/commit/02ff42cf030965b9006243c697e761fdcabb8ca1 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDJmZjQyY2YwMzA5NjViOTAwNjI0M2M2OTdlNzYxZmRjYWJiOGNhMSJ9 END_NESTED_COMMITBEGIN_NESTED_COMMITfeat: Added SuggestConversationSummary RPC docs: updated go library package PiperOrigin-RevId: 501862436 Source-Link: https://togithub.com/googleapis/googleapis/commit/155e0f4123ba003055587768944a47498c48926b Source-Link: https://togithub.com/googleapis/googleapis-gen/commit/3051f617a991c274c88d27064e803095e4ef9d39 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzA1MWY2MTdhOTkxYzI3NGM4OGQyNzA2NGU4MDMwOTVlNGVmOWQzOSJ9 END_NESTED_COMMITBEGIN_NESTED_COMMITfeat: add dynamic routing header annotation to DatastoreV1 PiperOrigin-RevId: 501591105 Source-Link: https://togithub.com/googleapis/googleapis/commit/c4ebfff4f512a9cb0fc09eb6d82a2987a3524ae0 Source-Link: https://togithub.com/googleapis/googleapis-gen/commit/e2d6011df35c3b7b54ff39098be779c105408b1b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTJkNjAxMWRmMzVjM2I3YjU0ZmYzOTA5OGJlNzc5YzEwNTQwOGIxYiJ9 END_NESTED_COMMITBEGIN_NESTED_COMMITfeat: Added Snooze API support PiperOrigin-RevId: 500543032 Source-Link: https://togithub.com/googleapis/googleapis/commit/d4864bf1425882fddb80ffb627c385ec22d1fd00 Source-Link: https://togithub.com/googleapis/googleapis-gen/commit/245031557f8852e8e089a6511f63fc226703fef9 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjQ1MDMxNTU3Zjg4NTJlOGUwODlhNjUxMWY2M2ZjMjI2NzAzZmVmOSJ9 END_NESTED_COMMITBEGIN_NESTED_COMMITchore: Enable requesting numeric enums in "transport=rest" responses for services supporting this (Java, Go, Python, PHP, TypeScript, C#, and Ruby), even if they do not yet turn on REST transport chore: disallow "transport=rest" for services where numeric enums are not confirmed to be supported (except in PHP and Java) PiperOrigin-RevId: 493113566 Source-Link: https://togithub.com/googleapis/googleapis/commit/758f0d1217d9c7fe398aa5efb1057ce4b6409e55 Source-Link: https://togithub.com/googleapis/googleapis-gen/commit/78bd8f05e1276363eb14eae70e91fe4bc20703ab Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNzhiZDhmMDVlMTI3NjM2M2ViMTRlYWU3MGU5MWZlNGJjMjA3MDNhYiJ9 END_NESTED_COMMIT --- .gitignore | 12 +- .jsdoc.js | 4 +- protos/google/datastore/v1/datastore.proto | 133 ++++- protos/protos.d.ts | 237 +++++++- protos/protos.js | 656 ++++++++++++++++++++- protos/protos.json | 160 ++++- src/v1/datastore_admin_client.ts | 5 +- src/v1/datastore_client.ts | 219 ++++++- system-test/fixtures/sample/src/index.js | 2 +- system-test/fixtures/sample/src/index.ts | 2 +- system-test/install.ts | 2 +- test/gapic_datastore_admin_v1.ts | 2 +- test/gapic_datastore_v1.ts | 274 +++------ 13 files changed, 1444 insertions(+), 264 deletions(-) diff --git a/.gitignore b/.gitignore index 5d32b2378..d4f03a0df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,11 @@ **/*.log **/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ +/.coverage +/coverage +/.nyc_output +/docs/ +/out/ +/build/ system-test/secrets.js system-test/*key.json *.lock diff --git a/.jsdoc.js b/.jsdoc.js index a3585eb98..1cdb0dacb 100644 --- a/.jsdoc.js +++ b/.jsdoc.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ module.exports = { includePattern: '\\.js$' }, templates: { - copyright: 'Copyright 2022 Google LLC', + copyright: 'Copyright 2023 Google LLC', includeDate: false, sourceFiles: false, systemName: '@google-cloud/datastore', diff --git a/protos/google/datastore/v1/datastore.proto b/protos/google/datastore/v1/datastore.proto index e891e058f..23a740ae4 100644 --- a/protos/google/datastore/v1/datastore.proto +++ b/protos/google/datastore/v1/datastore.proto @@ -19,6 +19,7 @@ package google.datastore.v1; import "google/api/annotations.proto"; import "google/api/client.proto"; import "google/api/field_behavior.proto"; +import "google/api/routing.proto"; import "google/datastore/v1/aggregation_result.proto"; import "google/datastore/v1/entity.proto"; import "google/datastore/v1/query.proto"; @@ -51,6 +52,10 @@ service Datastore { post: "/v1/projects/{project_id}:lookup" body: "*" }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; option (google.api.method_signature) = "project_id,read_options,keys"; } @@ -60,22 +65,36 @@ service Datastore { post: "/v1/projects/{project_id}:runQuery" body: "*" }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; } // Runs an aggregation query. - rpc RunAggregationQuery(RunAggregationQueryRequest) returns (RunAggregationQueryResponse) { + rpc RunAggregationQuery(RunAggregationQueryRequest) + returns (RunAggregationQueryResponse) { option (google.api.http) = { post: "/v1/projects/{project_id}:runAggregationQuery" body: "*" }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; } // Begins a new transaction. - rpc BeginTransaction(BeginTransactionRequest) returns (BeginTransactionResponse) { + rpc BeginTransaction(BeginTransactionRequest) + returns (BeginTransactionResponse) { option (google.api.http) = { post: "/v1/projects/{project_id}:beginTransaction" body: "*" }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; option (google.api.method_signature) = "project_id"; } @@ -86,7 +105,12 @@ service Datastore { post: "/v1/projects/{project_id}:commit" body: "*" }; - option (google.api.method_signature) = "project_id,mode,transaction,mutations"; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; + option (google.api.method_signature) = + "project_id,mode,transaction,mutations"; option (google.api.method_signature) = "project_id,mode,mutations"; } @@ -96,6 +120,10 @@ service Datastore { post: "/v1/projects/{project_id}:rollback" body: "*" }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; option (google.api.method_signature) = "project_id,transaction"; } @@ -106,6 +134,10 @@ service Datastore { post: "/v1/projects/{project_id}:allocateIds" body: "*" }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; option (google.api.method_signature) = "project_id,keys"; } @@ -116,6 +148,10 @@ service Datastore { post: "/v1/projects/{project_id}:reserveIds" body: "*" }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; option (google.api.method_signature) = "project_id,keys"; } } @@ -155,6 +191,13 @@ message LookupResponse { // order of the keys in the input. repeated Key deferred = 3; + // The identifier of the transaction that was started as part of this Lookup + // request. + // + // Set only when [ReadOptions.begin_transaction][] was set in + // [LookupRequest.read_options][google.datastore.v1.LookupRequest.read_options]. + bytes transaction = 5; + // The time at which these entities were read or found missing. google.protobuf.Timestamp read_time = 7; } @@ -189,16 +232,25 @@ message RunQueryRequest { } } -// The response for [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery]. +// The response for +// [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery]. message RunQueryResponse { // A batch of query results (always present). QueryResultBatch batch = 1; // The parsed form of the `GqlQuery` from the request, if it was set. Query query = 2; + + // The identifier of the transaction that was started as part of this + // RunQuery request. + // + // Set only when [ReadOptions.begin_transaction][] was set in + // [RunQueryRequest.read_options][google.datastore.v1.RunQueryRequest.read_options]. + bytes transaction = 5; } -// The request for [Datastore.RunAggregationQuery][google.datastore.v1.Datastore.RunAggregationQuery]. +// The request for +// [Datastore.RunAggregationQuery][google.datastore.v1.Datastore.RunAggregationQuery]. message RunAggregationQueryRequest { // Required. The ID of the project against which to make the request. string project_id = 8 [(google.api.field_behavior) = REQUIRED]; @@ -228,16 +280,25 @@ message RunAggregationQueryRequest { } } -// The response for [Datastore.RunAggregationQuery][google.datastore.v1.Datastore.RunAggregationQuery]. +// The response for +// [Datastore.RunAggregationQuery][google.datastore.v1.Datastore.RunAggregationQuery]. message RunAggregationQueryResponse { // A batch of aggregation results. Always present. AggregationResultBatch batch = 1; // The parsed form of the `GqlQuery` from the request, if it was set. AggregationQuery query = 2; + + // The identifier of the transaction that was started as part of this + // RunAggregationQuery request. + // + // Set only when [ReadOptions.begin_transaction][] was set in + // [RunAggregationQueryRequest.read_options][google.datastore.v1.RunAggregationQueryRequest.read_options]. + bytes transaction = 5; } -// The request for [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. +// The request for +// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. message BeginTransactionRequest { // Required. The ID of the project against which to make the request. string project_id = 8 [(google.api.field_behavior) = REQUIRED]; @@ -252,7 +313,8 @@ message BeginTransactionRequest { TransactionOptions transaction_options = 10; } -// The response for [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. +// The response for +// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. message BeginTransactionResponse { // The transaction identifier (always present). bytes transaction = 1; @@ -274,11 +336,10 @@ message RollbackRequest { bytes transaction = 1 [(google.api.field_behavior) = REQUIRED]; } -// The response for [Datastore.Rollback][google.datastore.v1.Datastore.Rollback]. -// (an empty message). -message RollbackResponse { - -} +// The response for +// [Datastore.Rollback][google.datastore.v1.Datastore.Rollback]. (an empty +// message). +message RollbackResponse {} // The request for [Datastore.Commit][google.datastore.v1.Datastore.Commit]. message CommitRequest { @@ -314,6 +375,13 @@ message CommitRequest { // transaction identifier is returned by a call to // [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. bytes transaction = 1; + + // Options for beginning a new transaction for this request. + // The transaction is committed when the request completes. If specified, + // [TransactionOptions.mode][google.datastore.v1.TransactionOptions.mode] + // must be + // [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite]. + TransactionOptions single_use_transaction = 10; } // The mutations to perform. @@ -346,7 +414,8 @@ message CommitResponse { google.protobuf.Timestamp commit_time = 8; } -// The request for [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds]. +// The request for +// [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds]. message AllocateIdsRequest { // Required. The ID of the project against which to make the request. string project_id = 8 [(google.api.field_behavior) = REQUIRED]; @@ -357,19 +426,21 @@ message AllocateIdsRequest { // database. string database_id = 9; - // Required. A list of keys with incomplete key paths for which to allocate IDs. - // No key may be reserved/read-only. + // Required. A list of keys with incomplete key paths for which to allocate + // IDs. No key may be reserved/read-only. repeated Key keys = 1 [(google.api.field_behavior) = REQUIRED]; } -// The response for [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds]. +// The response for +// [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds]. message AllocateIdsResponse { // The keys specified in the request (in the same order), each with // its key path completed with a newly allocated ID. repeated Key keys = 1; } -// The request for [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds]. +// The request for +// [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds]. message ReserveIdsRequest { // Required. The ID of the project against which to make the request. string project_id = 8 [(google.api.field_behavior) = REQUIRED]; @@ -380,15 +451,14 @@ message ReserveIdsRequest { // database. string database_id = 9; - // Required. A list of keys with complete key paths whose numeric IDs should not be - // auto-allocated. + // Required. A list of keys with complete key paths whose numeric IDs should + // not be auto-allocated. repeated Key keys = 1 [(google.api.field_behavior) = REQUIRED]; } -// The response for [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds]. -message ReserveIdsResponse { - -} +// The response for +// [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds]. +message ReserveIdsResponse {} // A mutation to apply to an entity. message Mutation { @@ -491,6 +561,15 @@ message ReadOptions { // [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. bytes transaction = 2; + // Options for beginning a new transaction for this request. + // + // The new transaction identifier will be returned in the corresponding + // response as either + // [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction] + // or + // [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction]. + TransactionOptions new_transaction = 3; + // Reads entities as they were at the given time. This may not be older // than 270 seconds. This value is only supported for Cloud Firestore in // Datastore mode. @@ -501,8 +580,10 @@ message ReadOptions { // Options for beginning a new transaction. // // Transactions can be created explicitly with calls to -// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction] or implicitly by setting -// [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction] in read requests. +// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction] +// or implicitly by setting +// [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction] +// in read requests. message TransactionOptions { // Options specific to read / write transactions. message ReadWrite { diff --git a/protos/protos.d.ts b/protos/protos.d.ts index e55f5da4a..c069d3098 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -5460,6 +5460,9 @@ export namespace google { /** LookupResponse deferred */ deferred?: (google.datastore.v1.IKey[]|null); + /** LookupResponse transaction */ + transaction?: (Uint8Array|string|null); + /** LookupResponse readTime */ readTime?: (google.protobuf.ITimestamp|null); } @@ -5482,6 +5485,9 @@ export namespace google { /** LookupResponse deferred. */ public deferred: google.datastore.v1.IKey[]; + /** LookupResponse transaction. */ + public transaction: (Uint8Array|string); + /** LookupResponse readTime. */ public readTime?: (google.protobuf.ITimestamp|null); @@ -5701,6 +5707,9 @@ export namespace google { /** RunQueryResponse query */ query?: (google.datastore.v1.IQuery|null); + + /** RunQueryResponse transaction */ + transaction?: (Uint8Array|string|null); } /** Represents a RunQueryResponse. */ @@ -5718,6 +5727,9 @@ export namespace google { /** RunQueryResponse query. */ public query?: (google.datastore.v1.IQuery|null); + /** RunQueryResponse transaction. */ + public transaction: (Uint8Array|string); + /** * Creates a new RunQueryResponse instance using the specified properties. * @param [properties] Properties to set @@ -5934,6 +5946,9 @@ export namespace google { /** RunAggregationQueryResponse query */ query?: (google.datastore.v1.IAggregationQuery|null); + + /** RunAggregationQueryResponse transaction */ + transaction?: (Uint8Array|string|null); } /** Represents a RunAggregationQueryResponse. */ @@ -5951,6 +5966,9 @@ export namespace google { /** RunAggregationQueryResponse query. */ public query?: (google.datastore.v1.IAggregationQuery|null); + /** RunAggregationQueryResponse transaction. */ + public transaction: (Uint8Array|string); + /** * Creates a new RunAggregationQueryResponse instance using the specified properties. * @param [properties] Properties to set @@ -6450,6 +6468,9 @@ export namespace google { /** CommitRequest transaction */ transaction?: (Uint8Array|string|null); + /** CommitRequest singleUseTransaction */ + singleUseTransaction?: (google.datastore.v1.ITransactionOptions|null); + /** CommitRequest mutations */ mutations?: (google.datastore.v1.IMutation[]|null); } @@ -6475,11 +6496,14 @@ export namespace google { /** CommitRequest transaction. */ public transaction?: (Uint8Array|string|null); + /** CommitRequest singleUseTransaction. */ + public singleUseTransaction?: (google.datastore.v1.ITransactionOptions|null); + /** CommitRequest mutations. */ public mutations: google.datastore.v1.IMutation[]; /** CommitRequest transactionSelector. */ - public transactionSelector?: "transaction"; + public transactionSelector?: ("transaction"|"singleUseTransaction"); /** * Creates a new CommitRequest instance using the specified properties. @@ -7341,6 +7365,9 @@ export namespace google { /** ReadOptions transaction */ transaction?: (Uint8Array|string|null); + /** ReadOptions newTransaction */ + newTransaction?: (google.datastore.v1.ITransactionOptions|null); + /** ReadOptions readTime */ readTime?: (google.protobuf.ITimestamp|null); } @@ -7360,11 +7387,14 @@ export namespace google { /** ReadOptions transaction. */ public transaction?: (Uint8Array|string|null); + /** ReadOptions newTransaction. */ + public newTransaction?: (google.datastore.v1.ITransactionOptions|null); + /** ReadOptions readTime. */ public readTime?: (google.protobuf.ITimestamp|null); /** ReadOptions consistencyType. */ - public consistencyType?: ("readConsistency"|"transaction"|"readTime"); + public consistencyType?: ("readConsistency"|"transaction"|"newTransaction"|"readTime"); /** * Creates a new ReadOptions instance using the specified properties. @@ -8133,6 +8163,206 @@ export namespace google { UNORDERED_LIST = 6, NON_EMPTY_DEFAULT = 7 } + + /** Properties of a RoutingRule. */ + interface IRoutingRule { + + /** RoutingRule routingParameters */ + routingParameters?: (google.api.IRoutingParameter[]|null); + } + + /** Represents a RoutingRule. */ + class RoutingRule implements IRoutingRule { + + /** + * Constructs a new RoutingRule. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IRoutingRule); + + /** RoutingRule routingParameters. */ + public routingParameters: google.api.IRoutingParameter[]; + + /** + * Creates a new RoutingRule instance using the specified properties. + * @param [properties] Properties to set + * @returns RoutingRule instance + */ + public static create(properties?: google.api.IRoutingRule): google.api.RoutingRule; + + /** + * Encodes the specified RoutingRule message. Does not implicitly {@link google.api.RoutingRule.verify|verify} messages. + * @param message RoutingRule message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IRoutingRule, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RoutingRule message, length delimited. Does not implicitly {@link google.api.RoutingRule.verify|verify} messages. + * @param message RoutingRule message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IRoutingRule, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RoutingRule message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RoutingRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.RoutingRule; + + /** + * Decodes a RoutingRule message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RoutingRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.RoutingRule; + + /** + * Verifies a RoutingRule message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RoutingRule message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RoutingRule + */ + public static fromObject(object: { [k: string]: any }): google.api.RoutingRule; + + /** + * Creates a plain object from a RoutingRule message. Also converts values to other types if specified. + * @param message RoutingRule + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.RoutingRule, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RoutingRule to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RoutingRule + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RoutingParameter. */ + interface IRoutingParameter { + + /** RoutingParameter field */ + field?: (string|null); + + /** RoutingParameter pathTemplate */ + pathTemplate?: (string|null); + } + + /** Represents a RoutingParameter. */ + class RoutingParameter implements IRoutingParameter { + + /** + * Constructs a new RoutingParameter. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IRoutingParameter); + + /** RoutingParameter field. */ + public field: string; + + /** RoutingParameter pathTemplate. */ + public pathTemplate: string; + + /** + * Creates a new RoutingParameter instance using the specified properties. + * @param [properties] Properties to set + * @returns RoutingParameter instance + */ + public static create(properties?: google.api.IRoutingParameter): google.api.RoutingParameter; + + /** + * Encodes the specified RoutingParameter message. Does not implicitly {@link google.api.RoutingParameter.verify|verify} messages. + * @param message RoutingParameter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IRoutingParameter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RoutingParameter message, length delimited. Does not implicitly {@link google.api.RoutingParameter.verify|verify} messages. + * @param message RoutingParameter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IRoutingParameter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RoutingParameter message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RoutingParameter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.RoutingParameter; + + /** + * Decodes a RoutingParameter message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RoutingParameter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.RoutingParameter; + + /** + * Verifies a RoutingParameter message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RoutingParameter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RoutingParameter + */ + public static fromObject(object: { [k: string]: any }): google.api.RoutingParameter; + + /** + * Creates a plain object from a RoutingParameter message. Also converts values to other types if specified. + * @param message RoutingParameter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.RoutingParameter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RoutingParameter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RoutingParameter + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Namespace protobuf. */ @@ -10676,6 +10906,9 @@ export namespace google { /** MethodOptions .google.longrunning.operationInfo */ ".google.longrunning.operationInfo"?: (google.longrunning.IOperationInfo|null); + + /** MethodOptions .google.api.routing */ + ".google.api.routing"?: (google.api.IRoutingRule|null); } /** Represents a MethodOptions. */ diff --git a/protos/protos.js b/protos/protos.js index 6751b3160..e6fba66c6 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -13833,6 +13833,7 @@ * @property {Array.|null} [found] LookupResponse found * @property {Array.|null} [missing] LookupResponse missing * @property {Array.|null} [deferred] LookupResponse deferred + * @property {Uint8Array|null} [transaction] LookupResponse transaction * @property {google.protobuf.ITimestamp|null} [readTime] LookupResponse readTime */ @@ -13878,6 +13879,14 @@ */ LookupResponse.prototype.deferred = $util.emptyArray; + /** + * LookupResponse transaction. + * @member {Uint8Array} transaction + * @memberof google.datastore.v1.LookupResponse + * @instance + */ + LookupResponse.prototype.transaction = $util.newBuffer([]); + /** * LookupResponse readTime. * @member {google.protobuf.ITimestamp|null|undefined} readTime @@ -13919,6 +13928,8 @@ if (message.deferred != null && message.deferred.length) for (var i = 0; i < message.deferred.length; ++i) $root.google.datastore.v1.Key.encode(message.deferred[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.transaction != null && Object.hasOwnProperty.call(message, "transaction")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.transaction); if (message.readTime != null && Object.hasOwnProperty.call(message, "readTime")) $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); return writer; @@ -13973,6 +13984,10 @@ message.deferred.push($root.google.datastore.v1.Key.decode(reader, reader.uint32())); break; } + case 5: { + message.transaction = reader.bytes(); + break; + } case 7: { message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); break; @@ -14039,6 +14054,9 @@ return "deferred." + error; } } + if (message.transaction != null && message.hasOwnProperty("transaction")) + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; if (message.readTime != null && message.hasOwnProperty("readTime")) { var error = $root.google.protobuf.Timestamp.verify(message.readTime); if (error) @@ -14089,6 +14107,11 @@ message.deferred[i] = $root.google.datastore.v1.Key.fromObject(object.deferred[i]); } } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length >= 0) + message.transaction = object.transaction; if (object.readTime != null) { if (typeof object.readTime !== "object") throw TypeError(".google.datastore.v1.LookupResponse.readTime: object expected"); @@ -14115,8 +14138,16 @@ object.missing = []; object.deferred = []; } - if (options.defaults) + if (options.defaults) { + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } object.readTime = null; + } if (message.found && message.found.length) { object.found = []; for (var j = 0; j < message.found.length; ++j) @@ -14132,6 +14163,8 @@ for (var j = 0; j < message.deferred.length; ++j) object.deferred[j] = $root.google.datastore.v1.Key.toObject(message.deferred[j], options); } + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; if (message.readTime != null && message.hasOwnProperty("readTime")) object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); return object; @@ -14540,6 +14573,7 @@ * @interface IRunQueryResponse * @property {google.datastore.v1.IQueryResultBatch|null} [batch] RunQueryResponse batch * @property {google.datastore.v1.IQuery|null} [query] RunQueryResponse query + * @property {Uint8Array|null} [transaction] RunQueryResponse transaction */ /** @@ -14573,6 +14607,14 @@ */ RunQueryResponse.prototype.query = null; + /** + * RunQueryResponse transaction. + * @member {Uint8Array} transaction + * @memberof google.datastore.v1.RunQueryResponse + * @instance + */ + RunQueryResponse.prototype.transaction = $util.newBuffer([]); + /** * Creates a new RunQueryResponse instance using the specified properties. * @function create @@ -14601,6 +14643,8 @@ $root.google.datastore.v1.QueryResultBatch.encode(message.batch, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); if (message.query != null && Object.hasOwnProperty.call(message, "query")) $root.google.datastore.v1.Query.encode(message.query, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.transaction != null && Object.hasOwnProperty.call(message, "transaction")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.transaction); return writer; }; @@ -14643,6 +14687,10 @@ message.query = $root.google.datastore.v1.Query.decode(reader, reader.uint32()); break; } + case 5: { + message.transaction = reader.bytes(); + break; + } default: reader.skipType(tag & 7); break; @@ -14688,6 +14736,9 @@ if (error) return "query." + error; } + if (message.transaction != null && message.hasOwnProperty("transaction")) + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; return null; }; @@ -14713,6 +14764,11 @@ throw TypeError(".google.datastore.v1.RunQueryResponse.query: object expected"); message.query = $root.google.datastore.v1.Query.fromObject(object.query); } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length >= 0) + message.transaction = object.transaction; return message; }; @@ -14732,11 +14788,20 @@ if (options.defaults) { object.batch = null; object.query = null; + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } } if (message.batch != null && message.hasOwnProperty("batch")) object.batch = $root.google.datastore.v1.QueryResultBatch.toObject(message.batch, options); if (message.query != null && message.hasOwnProperty("query")) object.query = $root.google.datastore.v1.Query.toObject(message.query, options); + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; return object; }; @@ -15143,6 +15208,7 @@ * @interface IRunAggregationQueryResponse * @property {google.datastore.v1.IAggregationResultBatch|null} [batch] RunAggregationQueryResponse batch * @property {google.datastore.v1.IAggregationQuery|null} [query] RunAggregationQueryResponse query + * @property {Uint8Array|null} [transaction] RunAggregationQueryResponse transaction */ /** @@ -15176,6 +15242,14 @@ */ RunAggregationQueryResponse.prototype.query = null; + /** + * RunAggregationQueryResponse transaction. + * @member {Uint8Array} transaction + * @memberof google.datastore.v1.RunAggregationQueryResponse + * @instance + */ + RunAggregationQueryResponse.prototype.transaction = $util.newBuffer([]); + /** * Creates a new RunAggregationQueryResponse instance using the specified properties. * @function create @@ -15204,6 +15278,8 @@ $root.google.datastore.v1.AggregationResultBatch.encode(message.batch, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); if (message.query != null && Object.hasOwnProperty.call(message, "query")) $root.google.datastore.v1.AggregationQuery.encode(message.query, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.transaction != null && Object.hasOwnProperty.call(message, "transaction")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.transaction); return writer; }; @@ -15246,6 +15322,10 @@ message.query = $root.google.datastore.v1.AggregationQuery.decode(reader, reader.uint32()); break; } + case 5: { + message.transaction = reader.bytes(); + break; + } default: reader.skipType(tag & 7); break; @@ -15291,6 +15371,9 @@ if (error) return "query." + error; } + if (message.transaction != null && message.hasOwnProperty("transaction")) + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; return null; }; @@ -15316,6 +15399,11 @@ throw TypeError(".google.datastore.v1.RunAggregationQueryResponse.query: object expected"); message.query = $root.google.datastore.v1.AggregationQuery.fromObject(object.query); } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length >= 0) + message.transaction = object.transaction; return message; }; @@ -15335,11 +15423,20 @@ if (options.defaults) { object.batch = null; object.query = null; + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } } if (message.batch != null && message.hasOwnProperty("batch")) object.batch = $root.google.datastore.v1.AggregationResultBatch.toObject(message.batch, options); if (message.query != null && message.hasOwnProperty("query")) object.query = $root.google.datastore.v1.AggregationQuery.toObject(message.query, options); + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; return object; }; @@ -16283,6 +16380,7 @@ * @property {string|null} [databaseId] CommitRequest databaseId * @property {google.datastore.v1.CommitRequest.Mode|null} [mode] CommitRequest mode * @property {Uint8Array|null} [transaction] CommitRequest transaction + * @property {google.datastore.v1.ITransactionOptions|null} [singleUseTransaction] CommitRequest singleUseTransaction * @property {Array.|null} [mutations] CommitRequest mutations */ @@ -16334,6 +16432,14 @@ */ CommitRequest.prototype.transaction = null; + /** + * CommitRequest singleUseTransaction. + * @member {google.datastore.v1.ITransactionOptions|null|undefined} singleUseTransaction + * @memberof google.datastore.v1.CommitRequest + * @instance + */ + CommitRequest.prototype.singleUseTransaction = null; + /** * CommitRequest mutations. * @member {Array.} mutations @@ -16347,12 +16453,12 @@ /** * CommitRequest transactionSelector. - * @member {"transaction"|undefined} transactionSelector + * @member {"transaction"|"singleUseTransaction"|undefined} transactionSelector * @memberof google.datastore.v1.CommitRequest * @instance */ Object.defineProperty(CommitRequest.prototype, "transactionSelector", { - get: $util.oneOfGetter($oneOfFields = ["transaction"]), + get: $util.oneOfGetter($oneOfFields = ["transaction", "singleUseTransaction"]), set: $util.oneOfSetter($oneOfFields) }); @@ -16391,6 +16497,8 @@ writer.uint32(/* id 8, wireType 2 =*/66).string(message.projectId); if (message.databaseId != null && Object.hasOwnProperty.call(message, "databaseId")) writer.uint32(/* id 9, wireType 2 =*/74).string(message.databaseId); + if (message.singleUseTransaction != null && Object.hasOwnProperty.call(message, "singleUseTransaction")) + $root.google.datastore.v1.TransactionOptions.encode(message.singleUseTransaction, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); return writer; }; @@ -16441,6 +16549,10 @@ message.transaction = reader.bytes(); break; } + case 10: { + message.singleUseTransaction = $root.google.datastore.v1.TransactionOptions.decode(reader, reader.uint32()); + break; + } case 6: { if (!(message.mutations && message.mutations.length)) message.mutations = []; @@ -16503,6 +16615,16 @@ if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) return "transaction: buffer expected"; } + if (message.singleUseTransaction != null && message.hasOwnProperty("singleUseTransaction")) { + if (properties.transactionSelector === 1) + return "transactionSelector: multiple values"; + properties.transactionSelector = 1; + { + var error = $root.google.datastore.v1.TransactionOptions.verify(message.singleUseTransaction); + if (error) + return "singleUseTransaction." + error; + } + } if (message.mutations != null && message.hasOwnProperty("mutations")) { if (!Array.isArray(message.mutations)) return "mutations: array expected"; @@ -16556,6 +16678,11 @@ $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); else if (object.transaction.length >= 0) message.transaction = object.transaction; + if (object.singleUseTransaction != null) { + if (typeof object.singleUseTransaction !== "object") + throw TypeError(".google.datastore.v1.CommitRequest.singleUseTransaction: object expected"); + message.singleUseTransaction = $root.google.datastore.v1.TransactionOptions.fromObject(object.singleUseTransaction); + } if (object.mutations) { if (!Array.isArray(object.mutations)) throw TypeError(".google.datastore.v1.CommitRequest.mutations: array expected"); @@ -16605,6 +16732,11 @@ object.projectId = message.projectId; if (message.databaseId != null && message.hasOwnProperty("databaseId")) object.databaseId = message.databaseId; + if (message.singleUseTransaction != null && message.hasOwnProperty("singleUseTransaction")) { + object.singleUseTransaction = $root.google.datastore.v1.TransactionOptions.toObject(message.singleUseTransaction, options); + if (options.oneofs) + object.transactionSelector = "singleUseTransaction"; + } return object; }; @@ -18593,6 +18725,7 @@ * @interface IReadOptions * @property {google.datastore.v1.ReadOptions.ReadConsistency|null} [readConsistency] ReadOptions readConsistency * @property {Uint8Array|null} [transaction] ReadOptions transaction + * @property {google.datastore.v1.ITransactionOptions|null} [newTransaction] ReadOptions newTransaction * @property {google.protobuf.ITimestamp|null} [readTime] ReadOptions readTime */ @@ -18627,6 +18760,14 @@ */ ReadOptions.prototype.transaction = null; + /** + * ReadOptions newTransaction. + * @member {google.datastore.v1.ITransactionOptions|null|undefined} newTransaction + * @memberof google.datastore.v1.ReadOptions + * @instance + */ + ReadOptions.prototype.newTransaction = null; + /** * ReadOptions readTime. * @member {google.protobuf.ITimestamp|null|undefined} readTime @@ -18640,12 +18781,12 @@ /** * ReadOptions consistencyType. - * @member {"readConsistency"|"transaction"|"readTime"|undefined} consistencyType + * @member {"readConsistency"|"transaction"|"newTransaction"|"readTime"|undefined} consistencyType * @memberof google.datastore.v1.ReadOptions * @instance */ Object.defineProperty(ReadOptions.prototype, "consistencyType", { - get: $util.oneOfGetter($oneOfFields = ["readConsistency", "transaction", "readTime"]), + get: $util.oneOfGetter($oneOfFields = ["readConsistency", "transaction", "newTransaction", "readTime"]), set: $util.oneOfSetter($oneOfFields) }); @@ -18677,6 +18818,8 @@ writer.uint32(/* id 1, wireType 0 =*/8).int32(message.readConsistency); if (message.transaction != null && Object.hasOwnProperty.call(message, "transaction")) writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.transaction); + if (message.newTransaction != null && Object.hasOwnProperty.call(message, "newTransaction")) + $root.google.datastore.v1.TransactionOptions.encode(message.newTransaction, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); if (message.readTime != null && Object.hasOwnProperty.call(message, "readTime")) $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); return writer; @@ -18721,6 +18864,10 @@ message.transaction = reader.bytes(); break; } + case 3: { + message.newTransaction = $root.google.datastore.v1.TransactionOptions.decode(reader, reader.uint32()); + break; + } case 4: { message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); break; @@ -18779,6 +18926,16 @@ if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) return "transaction: buffer expected"; } + if (message.newTransaction != null && message.hasOwnProperty("newTransaction")) { + if (properties.consistencyType === 1) + return "consistencyType: multiple values"; + properties.consistencyType = 1; + { + var error = $root.google.datastore.v1.TransactionOptions.verify(message.newTransaction); + if (error) + return "newTransaction." + error; + } + } if (message.readTime != null && message.hasOwnProperty("readTime")) { if (properties.consistencyType === 1) return "consistencyType: multiple values"; @@ -18829,6 +18986,11 @@ $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); else if (object.transaction.length >= 0) message.transaction = object.transaction; + if (object.newTransaction != null) { + if (typeof object.newTransaction !== "object") + throw TypeError(".google.datastore.v1.ReadOptions.newTransaction: object expected"); + message.newTransaction = $root.google.datastore.v1.TransactionOptions.fromObject(object.newTransaction); + } if (object.readTime != null) { if (typeof object.readTime !== "object") throw TypeError(".google.datastore.v1.ReadOptions.readTime: object expected"); @@ -18860,6 +19022,11 @@ if (options.oneofs) object.consistencyType = "transaction"; } + if (message.newTransaction != null && message.hasOwnProperty("newTransaction")) { + object.newTransaction = $root.google.datastore.v1.TransactionOptions.toObject(message.newTransaction, options); + if (options.oneofs) + object.consistencyType = "newTransaction"; + } if (message.readTime != null && message.hasOwnProperty("readTime")) { object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); if (options.oneofs) @@ -20599,6 +20766,457 @@ return values; })(); + api.RoutingRule = (function() { + + /** + * Properties of a RoutingRule. + * @memberof google.api + * @interface IRoutingRule + * @property {Array.|null} [routingParameters] RoutingRule routingParameters + */ + + /** + * Constructs a new RoutingRule. + * @memberof google.api + * @classdesc Represents a RoutingRule. + * @implements IRoutingRule + * @constructor + * @param {google.api.IRoutingRule=} [properties] Properties to set + */ + function RoutingRule(properties) { + this.routingParameters = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RoutingRule routingParameters. + * @member {Array.} routingParameters + * @memberof google.api.RoutingRule + * @instance + */ + RoutingRule.prototype.routingParameters = $util.emptyArray; + + /** + * Creates a new RoutingRule instance using the specified properties. + * @function create + * @memberof google.api.RoutingRule + * @static + * @param {google.api.IRoutingRule=} [properties] Properties to set + * @returns {google.api.RoutingRule} RoutingRule instance + */ + RoutingRule.create = function create(properties) { + return new RoutingRule(properties); + }; + + /** + * Encodes the specified RoutingRule message. Does not implicitly {@link google.api.RoutingRule.verify|verify} messages. + * @function encode + * @memberof google.api.RoutingRule + * @static + * @param {google.api.IRoutingRule} message RoutingRule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RoutingRule.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.routingParameters != null && message.routingParameters.length) + for (var i = 0; i < message.routingParameters.length; ++i) + $root.google.api.RoutingParameter.encode(message.routingParameters[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RoutingRule message, length delimited. Does not implicitly {@link google.api.RoutingRule.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.RoutingRule + * @static + * @param {google.api.IRoutingRule} message RoutingRule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RoutingRule.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RoutingRule message from the specified reader or buffer. + * @function decode + * @memberof google.api.RoutingRule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.RoutingRule} RoutingRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RoutingRule.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.RoutingRule(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + if (!(message.routingParameters && message.routingParameters.length)) + message.routingParameters = []; + message.routingParameters.push($root.google.api.RoutingParameter.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RoutingRule message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.RoutingRule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.RoutingRule} RoutingRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RoutingRule.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RoutingRule message. + * @function verify + * @memberof google.api.RoutingRule + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RoutingRule.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.routingParameters != null && message.hasOwnProperty("routingParameters")) { + if (!Array.isArray(message.routingParameters)) + return "routingParameters: array expected"; + for (var i = 0; i < message.routingParameters.length; ++i) { + var error = $root.google.api.RoutingParameter.verify(message.routingParameters[i]); + if (error) + return "routingParameters." + error; + } + } + return null; + }; + + /** + * Creates a RoutingRule message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.RoutingRule + * @static + * @param {Object.} object Plain object + * @returns {google.api.RoutingRule} RoutingRule + */ + RoutingRule.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.RoutingRule) + return object; + var message = new $root.google.api.RoutingRule(); + if (object.routingParameters) { + if (!Array.isArray(object.routingParameters)) + throw TypeError(".google.api.RoutingRule.routingParameters: array expected"); + message.routingParameters = []; + for (var i = 0; i < object.routingParameters.length; ++i) { + if (typeof object.routingParameters[i] !== "object") + throw TypeError(".google.api.RoutingRule.routingParameters: object expected"); + message.routingParameters[i] = $root.google.api.RoutingParameter.fromObject(object.routingParameters[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a RoutingRule message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.RoutingRule + * @static + * @param {google.api.RoutingRule} message RoutingRule + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RoutingRule.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.routingParameters = []; + if (message.routingParameters && message.routingParameters.length) { + object.routingParameters = []; + for (var j = 0; j < message.routingParameters.length; ++j) + object.routingParameters[j] = $root.google.api.RoutingParameter.toObject(message.routingParameters[j], options); + } + return object; + }; + + /** + * Converts this RoutingRule to JSON. + * @function toJSON + * @memberof google.api.RoutingRule + * @instance + * @returns {Object.} JSON object + */ + RoutingRule.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RoutingRule + * @function getTypeUrl + * @memberof google.api.RoutingRule + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RoutingRule.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.RoutingRule"; + }; + + return RoutingRule; + })(); + + api.RoutingParameter = (function() { + + /** + * Properties of a RoutingParameter. + * @memberof google.api + * @interface IRoutingParameter + * @property {string|null} [field] RoutingParameter field + * @property {string|null} [pathTemplate] RoutingParameter pathTemplate + */ + + /** + * Constructs a new RoutingParameter. + * @memberof google.api + * @classdesc Represents a RoutingParameter. + * @implements IRoutingParameter + * @constructor + * @param {google.api.IRoutingParameter=} [properties] Properties to set + */ + function RoutingParameter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RoutingParameter field. + * @member {string} field + * @memberof google.api.RoutingParameter + * @instance + */ + RoutingParameter.prototype.field = ""; + + /** + * RoutingParameter pathTemplate. + * @member {string} pathTemplate + * @memberof google.api.RoutingParameter + * @instance + */ + RoutingParameter.prototype.pathTemplate = ""; + + /** + * Creates a new RoutingParameter instance using the specified properties. + * @function create + * @memberof google.api.RoutingParameter + * @static + * @param {google.api.IRoutingParameter=} [properties] Properties to set + * @returns {google.api.RoutingParameter} RoutingParameter instance + */ + RoutingParameter.create = function create(properties) { + return new RoutingParameter(properties); + }; + + /** + * Encodes the specified RoutingParameter message. Does not implicitly {@link google.api.RoutingParameter.verify|verify} messages. + * @function encode + * @memberof google.api.RoutingParameter + * @static + * @param {google.api.IRoutingParameter} message RoutingParameter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RoutingParameter.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.field != null && Object.hasOwnProperty.call(message, "field")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.field); + if (message.pathTemplate != null && Object.hasOwnProperty.call(message, "pathTemplate")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.pathTemplate); + return writer; + }; + + /** + * Encodes the specified RoutingParameter message, length delimited. Does not implicitly {@link google.api.RoutingParameter.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.RoutingParameter + * @static + * @param {google.api.IRoutingParameter} message RoutingParameter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RoutingParameter.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RoutingParameter message from the specified reader or buffer. + * @function decode + * @memberof google.api.RoutingParameter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.RoutingParameter} RoutingParameter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RoutingParameter.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.RoutingParameter(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.field = reader.string(); + break; + } + case 2: { + message.pathTemplate = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RoutingParameter message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.RoutingParameter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.RoutingParameter} RoutingParameter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RoutingParameter.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RoutingParameter message. + * @function verify + * @memberof google.api.RoutingParameter + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RoutingParameter.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.field != null && message.hasOwnProperty("field")) + if (!$util.isString(message.field)) + return "field: string expected"; + if (message.pathTemplate != null && message.hasOwnProperty("pathTemplate")) + if (!$util.isString(message.pathTemplate)) + return "pathTemplate: string expected"; + return null; + }; + + /** + * Creates a RoutingParameter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.RoutingParameter + * @static + * @param {Object.} object Plain object + * @returns {google.api.RoutingParameter} RoutingParameter + */ + RoutingParameter.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.RoutingParameter) + return object; + var message = new $root.google.api.RoutingParameter(); + if (object.field != null) + message.field = String(object.field); + if (object.pathTemplate != null) + message.pathTemplate = String(object.pathTemplate); + return message; + }; + + /** + * Creates a plain object from a RoutingParameter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.RoutingParameter + * @static + * @param {google.api.RoutingParameter} message RoutingParameter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RoutingParameter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.field = ""; + object.pathTemplate = ""; + } + if (message.field != null && message.hasOwnProperty("field")) + object.field = message.field; + if (message.pathTemplate != null && message.hasOwnProperty("pathTemplate")) + object.pathTemplate = message.pathTemplate; + return object; + }; + + /** + * Converts this RoutingParameter to JSON. + * @function toJSON + * @memberof google.api.RoutingParameter + * @instance + * @returns {Object.} JSON object + */ + RoutingParameter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RoutingParameter + * @function getTypeUrl + * @memberof google.api.RoutingParameter + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RoutingParameter.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.RoutingParameter"; + }; + + return RoutingParameter; + })(); + return api; })(); @@ -27715,6 +28333,7 @@ * @property {google.api.IHttpRule|null} [".google.api.http"] MethodOptions .google.api.http * @property {Array.|null} [".google.api.methodSignature"] MethodOptions .google.api.methodSignature * @property {google.longrunning.IOperationInfo|null} [".google.longrunning.operationInfo"] MethodOptions .google.longrunning.operationInfo + * @property {google.api.IRoutingRule|null} [".google.api.routing"] MethodOptions .google.api.routing */ /** @@ -27782,6 +28401,14 @@ */ MethodOptions.prototype[".google.longrunning.operationInfo"] = null; + /** + * MethodOptions .google.api.routing. + * @member {google.api.IRoutingRule|null|undefined} .google.api.routing + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.api.routing"] = null; + /** * Creates a new MethodOptions instance using the specified properties. * @function create @@ -27820,6 +28447,8 @@ writer.uint32(/* id 1051, wireType 2 =*/8410).string(message[".google.api.methodSignature"][i]); if (message[".google.api.http"] != null && Object.hasOwnProperty.call(message, ".google.api.http")) $root.google.api.HttpRule.encode(message[".google.api.http"], writer.uint32(/* id 72295728, wireType 2 =*/578365826).fork()).ldelim(); + if (message[".google.api.routing"] != null && Object.hasOwnProperty.call(message, ".google.api.routing")) + $root.google.api.RoutingRule.encode(message[".google.api.routing"], writer.uint32(/* id 72295729, wireType 2 =*/578365834).fork()).ldelim(); return writer; }; @@ -27882,6 +28511,10 @@ message[".google.longrunning.operationInfo"] = $root.google.longrunning.OperationInfo.decode(reader, reader.uint32()); break; } + case 72295729: { + message[".google.api.routing"] = $root.google.api.RoutingRule.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -27955,6 +28588,11 @@ if (error) return ".google.longrunning.operationInfo." + error; } + if (message[".google.api.routing"] != null && message.hasOwnProperty(".google.api.routing")) { + var error = $root.google.api.RoutingRule.verify(message[".google.api.routing"]); + if (error) + return ".google.api.routing." + error; + } return null; }; @@ -28019,6 +28657,11 @@ throw TypeError(".google.protobuf.MethodOptions..google.longrunning.operationInfo: object expected"); message[".google.longrunning.operationInfo"] = $root.google.longrunning.OperationInfo.fromObject(object[".google.longrunning.operationInfo"]); } + if (object[".google.api.routing"] != null) { + if (typeof object[".google.api.routing"] !== "object") + throw TypeError(".google.protobuf.MethodOptions..google.api.routing: object expected"); + message[".google.api.routing"] = $root.google.api.RoutingRule.fromObject(object[".google.api.routing"]); + } return message; }; @@ -28044,6 +28687,7 @@ object.idempotencyLevel = options.enums === String ? "IDEMPOTENCY_UNKNOWN" : 0; object[".google.longrunning.operationInfo"] = null; object[".google.api.http"] = null; + object[".google.api.routing"] = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -28063,6 +28707,8 @@ } if (message[".google.api.http"] != null && message.hasOwnProperty(".google.api.http")) object[".google.api.http"] = $root.google.api.HttpRule.toObject(message[".google.api.http"], options); + if (message[".google.api.routing"] != null && message.hasOwnProperty(".google.api.routing")) + object[".google.api.routing"] = $root.google.api.RoutingRule.toObject(message[".google.api.routing"], options); return object; }; diff --git a/protos/protos.json b/protos/protos.json index f8f142455..a6c734d63 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -1149,6 +1149,7 @@ "options": { "(google.api.http).post": "/v1/projects/{project_id}:lookup", "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "database_id", "(google.api.method_signature)": "project_id,read_options,keys" }, "parsedOptions": [ @@ -1158,6 +1159,18 @@ "body": "*" } }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "project_id" + }, + { + "field": "database_id" + } + ] + } + }, { "(google.api.method_signature)": "project_id,read_options,keys" } @@ -1168,7 +1181,8 @@ "responseType": "RunQueryResponse", "options": { "(google.api.http).post": "/v1/projects/{project_id}:runQuery", - "(google.api.http).body": "*" + "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "database_id" }, "parsedOptions": [ { @@ -1176,6 +1190,18 @@ "post": "/v1/projects/{project_id}:runQuery", "body": "*" } + }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "project_id" + }, + { + "field": "database_id" + } + ] + } } ] }, @@ -1184,7 +1210,8 @@ "responseType": "RunAggregationQueryResponse", "options": { "(google.api.http).post": "/v1/projects/{project_id}:runAggregationQuery", - "(google.api.http).body": "*" + "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "database_id" }, "parsedOptions": [ { @@ -1192,6 +1219,18 @@ "post": "/v1/projects/{project_id}:runAggregationQuery", "body": "*" } + }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "project_id" + }, + { + "field": "database_id" + } + ] + } } ] }, @@ -1201,6 +1240,7 @@ "options": { "(google.api.http).post": "/v1/projects/{project_id}:beginTransaction", "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "database_id", "(google.api.method_signature)": "project_id" }, "parsedOptions": [ @@ -1210,6 +1250,18 @@ "body": "*" } }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "project_id" + }, + { + "field": "database_id" + } + ] + } + }, { "(google.api.method_signature)": "project_id" } @@ -1221,6 +1273,7 @@ "options": { "(google.api.http).post": "/v1/projects/{project_id}:commit", "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "database_id", "(google.api.method_signature)": "project_id,mode,mutations" }, "parsedOptions": [ @@ -1230,6 +1283,18 @@ "body": "*" } }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "project_id" + }, + { + "field": "database_id" + } + ] + } + }, { "(google.api.method_signature)": "project_id,mode,transaction,mutations" }, @@ -1244,6 +1309,7 @@ "options": { "(google.api.http).post": "/v1/projects/{project_id}:rollback", "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "database_id", "(google.api.method_signature)": "project_id,transaction" }, "parsedOptions": [ @@ -1253,6 +1319,18 @@ "body": "*" } }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "project_id" + }, + { + "field": "database_id" + } + ] + } + }, { "(google.api.method_signature)": "project_id,transaction" } @@ -1264,6 +1342,7 @@ "options": { "(google.api.http).post": "/v1/projects/{project_id}:allocateIds", "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "database_id", "(google.api.method_signature)": "project_id,keys" }, "parsedOptions": [ @@ -1273,6 +1352,18 @@ "body": "*" } }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "project_id" + }, + { + "field": "database_id" + } + ] + } + }, { "(google.api.method_signature)": "project_id,keys" } @@ -1284,6 +1375,7 @@ "options": { "(google.api.http).post": "/v1/projects/{project_id}:reserveIds", "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "database_id", "(google.api.method_signature)": "project_id,keys" }, "parsedOptions": [ @@ -1293,6 +1385,18 @@ "body": "*" } }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "project_id" + }, + { + "field": "database_id" + } + ] + } + }, { "(google.api.method_signature)": "project_id,keys" } @@ -1344,6 +1448,10 @@ "type": "Key", "id": 3 }, + "transaction": { + "type": "bytes", + "id": 5 + }, "readTime": { "type": "google.protobuf.Timestamp", "id": 7 @@ -1398,6 +1506,10 @@ "query": { "type": "Query", "id": 2 + }, + "transaction": { + "type": "bytes", + "id": 5 } } }, @@ -1449,6 +1561,10 @@ "query": { "type": "AggregationQuery", "id": 2 + }, + "transaction": { + "type": "bytes", + "id": 5 } } }, @@ -1508,7 +1624,8 @@ "oneofs": { "transactionSelector": { "oneof": [ - "transaction" + "transaction", + "singleUseTransaction" ] } }, @@ -1532,6 +1649,10 @@ "type": "bytes", "id": 1 }, + "singleUseTransaction": { + "type": "TransactionOptions", + "id": 10 + }, "mutations": { "rule": "repeated", "type": "Mutation", @@ -1693,6 +1814,7 @@ "oneof": [ "readConsistency", "transaction", + "newTransaction", "readTime" ] } @@ -1706,6 +1828,10 @@ "type": "bytes", "id": 2 }, + "newTransaction": { + "type": "TransactionOptions", + "id": 3 + }, "readTime": { "type": "google.protobuf.Timestamp", "id": 4 @@ -1767,7 +1893,7 @@ "options": { "go_package": "google.golang.org/genproto/googleapis/api/annotations;annotations", "java_multiple_files": true, - "java_outer_classname": "FieldBehaviorProto", + "java_outer_classname": "RoutingProto", "java_package": "com.google.api", "objc_class_prefix": "GAPI", "cc_enable_arenas": true @@ -1893,6 +2019,32 @@ "UNORDERED_LIST": 6, "NON_EMPTY_DEFAULT": 7 } + }, + "routing": { + "type": "google.api.RoutingRule", + "id": 72295729, + "extend": "google.protobuf.MethodOptions" + }, + "RoutingRule": { + "fields": { + "routingParameters": { + "rule": "repeated", + "type": "RoutingParameter", + "id": 2 + } + } + }, + "RoutingParameter": { + "fields": { + "field": { + "type": "string", + "id": 1 + }, + "pathTemplate": { + "type": "string", + "id": 2 + } + } } } }, diff --git a/src/v1/datastore_admin_client.ts b/src/v1/datastore_admin_client.ts index 02a594c11..dbe388bbd 100644 --- a/src/v1/datastore_admin_client.ts +++ b/src/v1/datastore_admin_client.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -182,6 +182,9 @@ export class DatastoreAdminClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; diff --git a/src/v1/datastore_client.ts b/src/v1/datastore_client.ts index b83576f02..12161af7f 100644 --- a/src/v1/datastore_client.ts +++ b/src/v1/datastore_client.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -125,6 +125,9 @@ export class DatastoreClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; @@ -440,10 +443,29 @@ export class DatastoreClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; + const routingParameter = {}; + { + const fieldValue = request.projectId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['project_id'] ?? fieldValue; + Object.assign(routingParameter, {project_id: parameterValue}); + } + } + } + { + const fieldValue = request.databaseId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['database_id'] ?? fieldValue; + Object.assign(routingParameter, {database_id: parameterValue}); + } + } + } options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - project_id: request.projectId ?? '', - }); + this._gaxModule.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.lookup(request, options, callback); } @@ -539,10 +561,29 @@ export class DatastoreClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; + const routingParameter = {}; + { + const fieldValue = request.projectId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['project_id'] ?? fieldValue; + Object.assign(routingParameter, {project_id: parameterValue}); + } + } + } + { + const fieldValue = request.databaseId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['database_id'] ?? fieldValue; + Object.assign(routingParameter, {database_id: parameterValue}); + } + } + } options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - project_id: request.projectId ?? '', - }); + this._gaxModule.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.runQuery(request, options, callback); } @@ -640,10 +681,29 @@ export class DatastoreClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; + const routingParameter = {}; + { + const fieldValue = request.projectId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['project_id'] ?? fieldValue; + Object.assign(routingParameter, {project_id: parameterValue}); + } + } + } + { + const fieldValue = request.databaseId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['database_id'] ?? fieldValue; + Object.assign(routingParameter, {database_id: parameterValue}); + } + } + } options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - project_id: request.projectId ?? '', - }); + this._gaxModule.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.runAggregationQuery(request, options, callback); } @@ -732,10 +792,29 @@ export class DatastoreClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; + const routingParameter = {}; + { + const fieldValue = request.projectId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['project_id'] ?? fieldValue; + Object.assign(routingParameter, {project_id: parameterValue}); + } + } + } + { + const fieldValue = request.databaseId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['database_id'] ?? fieldValue; + Object.assign(routingParameter, {database_id: parameterValue}); + } + } + } options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - project_id: request.projectId ?? '', - }); + this._gaxModule.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.beginTransaction(request, options, callback); } @@ -758,6 +837,12 @@ export class DatastoreClient { * The identifier of the transaction associated with the commit. A * transaction identifier is returned by a call to * {@link google.datastore.v1.Datastore.BeginTransaction|Datastore.BeginTransaction}. + * @param {google.datastore.v1.TransactionOptions} request.singleUseTransaction + * Options for beginning a new transaction for this request. + * The transaction is committed when the request completes. If specified, + * {@link google.datastore.v1.TransactionOptions.mode|TransactionOptions.mode} + * must be + * {@link google.datastore.v1.TransactionOptions.ReadWrite|TransactionOptions.ReadWrite}. * @param {number[]} request.mutations * The mutations to perform. * @@ -841,10 +926,29 @@ export class DatastoreClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; + const routingParameter = {}; + { + const fieldValue = request.projectId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['project_id'] ?? fieldValue; + Object.assign(routingParameter, {project_id: parameterValue}); + } + } + } + { + const fieldValue = request.databaseId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['database_id'] ?? fieldValue; + Object.assign(routingParameter, {database_id: parameterValue}); + } + } + } options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - project_id: request.projectId ?? '', - }); + this._gaxModule.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.commit(request, options, callback); } @@ -932,10 +1036,29 @@ export class DatastoreClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; + const routingParameter = {}; + { + const fieldValue = request.projectId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['project_id'] ?? fieldValue; + Object.assign(routingParameter, {project_id: parameterValue}); + } + } + } + { + const fieldValue = request.databaseId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['database_id'] ?? fieldValue; + Object.assign(routingParameter, {database_id: parameterValue}); + } + } + } options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - project_id: request.projectId ?? '', - }); + this._gaxModule.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.rollback(request, options, callback); } @@ -953,8 +1076,8 @@ export class DatastoreClient { * '(default)' is not allowed; please use empty string '' to refer the default * database. * @param {number[]} request.keys - * Required. A list of keys with incomplete key paths for which to allocate IDs. - * No key may be reserved/read-only. + * Required. A list of keys with incomplete key paths for which to allocate + * IDs. No key may be reserved/read-only. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -1024,10 +1147,29 @@ export class DatastoreClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; + const routingParameter = {}; + { + const fieldValue = request.projectId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['project_id'] ?? fieldValue; + Object.assign(routingParameter, {project_id: parameterValue}); + } + } + } + { + const fieldValue = request.databaseId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['database_id'] ?? fieldValue; + Object.assign(routingParameter, {database_id: parameterValue}); + } + } + } options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - project_id: request.projectId ?? '', - }); + this._gaxModule.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.allocateIds(request, options, callback); } @@ -1045,8 +1187,8 @@ export class DatastoreClient { * '(default)' is not allowed; please use empty string '' to refer the default * database. * @param {number[]} request.keys - * Required. A list of keys with complete key paths whose numeric IDs should not be - * auto-allocated. + * Required. A list of keys with complete key paths whose numeric IDs should + * not be auto-allocated. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -1116,10 +1258,29 @@ export class DatastoreClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; + const routingParameter = {}; + { + const fieldValue = request.projectId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['project_id'] ?? fieldValue; + Object.assign(routingParameter, {project_id: parameterValue}); + } + } + } + { + const fieldValue = request.databaseId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['database_id'] ?? fieldValue; + Object.assign(routingParameter, {database_id: parameterValue}); + } + } + } options.otherArgs.headers['x-goog-request-params'] = - this._gaxModule.routingHeader.fromParams({ - project_id: request.projectId ?? '', - }); + this._gaxModule.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.reserveIds(request, options, callback); } diff --git a/system-test/fixtures/sample/src/index.js b/system-test/fixtures/sample/src/index.js index 44c29691c..6a4ecce7b 100644 --- a/system-test/fixtures/sample/src/index.js +++ b/system-test/fixtures/sample/src/index.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/system-test/fixtures/sample/src/index.ts b/system-test/fixtures/sample/src/index.ts index 97fdbf6f7..6688080dc 100644 --- a/system-test/fixtures/sample/src/index.ts +++ b/system-test/fixtures/sample/src/index.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/system-test/install.ts b/system-test/install.ts index 6dd1eaada..f61fe2364 100644 --- a/system-test/install.ts +++ b/system-test/install.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/test/gapic_datastore_admin_v1.ts b/test/gapic_datastore_admin_v1.ts index 4fe35cf2c..f1c0480ff 100644 --- a/test/gapic_datastore_admin_v1.ts +++ b/test/gapic_datastore_admin_v1.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/test/gapic_datastore_v1.ts b/test/gapic_datastore_v1.ts index 3698f5ec9..a77daf4b0 100644 --- a/test/gapic_datastore_v1.ts +++ b/test/gapic_datastore_v1.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -195,12 +195,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.LookupRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.LookupRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( new protos.google.datastore.v1.LookupResponse() ); @@ -226,12 +223,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.LookupRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.LookupRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( new protos.google.datastore.v1.LookupResponse() ); @@ -273,12 +267,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.LookupRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.LookupRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedError = new Error('expected'); client.innerApiCalls.lookup = stubSimpleCall(undefined, expectedError); await assert.rejects(client.lookup(request), expectedError); @@ -301,11 +292,8 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.LookupRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.LookupRequest', - ['projectId'] - ); - request.projectId = defaultValue1; + // path template is empty + request.databaseId = 'value'; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.lookup(request), expectedError); @@ -322,12 +310,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.RunQueryRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.RunQueryRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( new protos.google.datastore.v1.RunQueryResponse() ); @@ -353,12 +338,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.RunQueryRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.RunQueryRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( new protos.google.datastore.v1.RunQueryResponse() ); @@ -400,12 +382,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.RunQueryRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.RunQueryRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedError = new Error('expected'); client.innerApiCalls.runQuery = stubSimpleCall(undefined, expectedError); await assert.rejects(client.runQuery(request), expectedError); @@ -428,11 +407,8 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.RunQueryRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.RunQueryRequest', - ['projectId'] - ); - request.projectId = defaultValue1; + // path template is empty + request.databaseId = 'value'; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.runQuery(request), expectedError); @@ -449,12 +425,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.RunAggregationQueryRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.RunAggregationQueryRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( new protos.google.datastore.v1.RunAggregationQueryResponse() ); @@ -481,12 +454,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.RunAggregationQueryRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.RunAggregationQueryRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( new protos.google.datastore.v1.RunAggregationQueryResponse() ); @@ -528,12 +498,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.RunAggregationQueryRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.RunAggregationQueryRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedError = new Error('expected'); client.innerApiCalls.runAggregationQuery = stubSimpleCall( undefined, @@ -559,11 +526,8 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.RunAggregationQueryRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.RunAggregationQueryRequest', - ['projectId'] - ); - request.projectId = defaultValue1; + // path template is empty + request.databaseId = 'value'; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.runAggregationQuery(request), expectedError); @@ -580,12 +544,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.BeginTransactionRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.BeginTransactionRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( new protos.google.datastore.v1.BeginTransactionResponse() ); @@ -611,12 +572,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.BeginTransactionRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.BeginTransactionRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( new protos.google.datastore.v1.BeginTransactionResponse() ); @@ -658,12 +616,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.BeginTransactionRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.BeginTransactionRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedError = new Error('expected'); client.innerApiCalls.beginTransaction = stubSimpleCall( undefined, @@ -689,11 +644,8 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.BeginTransactionRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.BeginTransactionRequest', - ['projectId'] - ); - request.projectId = defaultValue1; + // path template is empty + request.databaseId = 'value'; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.beginTransaction(request), expectedError); @@ -710,12 +662,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.CommitRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.CommitRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( new protos.google.datastore.v1.CommitResponse() ); @@ -741,12 +690,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.CommitRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.CommitRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( new protos.google.datastore.v1.CommitResponse() ); @@ -788,12 +734,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.CommitRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.CommitRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedError = new Error('expected'); client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); await assert.rejects(client.commit(request), expectedError); @@ -816,11 +759,8 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.CommitRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.CommitRequest', - ['projectId'] - ); - request.projectId = defaultValue1; + // path template is empty + request.databaseId = 'value'; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.commit(request), expectedError); @@ -837,12 +777,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.RollbackRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.RollbackRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( new protos.google.datastore.v1.RollbackResponse() ); @@ -868,12 +805,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.RollbackRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.RollbackRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( new protos.google.datastore.v1.RollbackResponse() ); @@ -915,12 +849,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.RollbackRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.RollbackRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedError = new Error('expected'); client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); await assert.rejects(client.rollback(request), expectedError); @@ -943,11 +874,8 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.RollbackRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.RollbackRequest', - ['projectId'] - ); - request.projectId = defaultValue1; + // path template is empty + request.databaseId = 'value'; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.rollback(request), expectedError); @@ -964,12 +892,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.AllocateIdsRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.AllocateIdsRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( new protos.google.datastore.v1.AllocateIdsResponse() ); @@ -995,12 +920,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.AllocateIdsRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.AllocateIdsRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( new protos.google.datastore.v1.AllocateIdsResponse() ); @@ -1042,12 +964,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.AllocateIdsRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.AllocateIdsRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedError = new Error('expected'); client.innerApiCalls.allocateIds = stubSimpleCall( undefined, @@ -1073,11 +992,8 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.AllocateIdsRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.AllocateIdsRequest', - ['projectId'] - ); - request.projectId = defaultValue1; + // path template is empty + request.databaseId = 'value'; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.allocateIds(request), expectedError); @@ -1094,12 +1010,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.ReserveIdsRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.ReserveIdsRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( new protos.google.datastore.v1.ReserveIdsResponse() ); @@ -1125,12 +1038,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.ReserveIdsRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.ReserveIdsRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedResponse = generateSampleMessage( new protos.google.datastore.v1.ReserveIdsResponse() ); @@ -1172,12 +1082,9 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.ReserveIdsRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.ReserveIdsRequest', - ['projectId'] - ); - request.projectId = defaultValue1; - const expectedHeaderRequestParams = `project_id=${defaultValue1}`; + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; const expectedError = new Error('expected'); client.innerApiCalls.reserveIds = stubSimpleCall( undefined, @@ -1203,11 +1110,8 @@ describe('v1.DatastoreClient', () => { const request = generateSampleMessage( new protos.google.datastore.v1.ReserveIdsRequest() ); - const defaultValue1 = getTypeDefaultValue( - '.google.datastore.v1.ReserveIdsRequest', - ['projectId'] - ); - request.projectId = defaultValue1; + // path template is empty + request.databaseId = 'value'; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.reserveIds(request), expectedError);