diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 2c37ca7a7..a5fbf1572 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest - digest: sha256:89c5b2f3decec8ad64febbebea671076c119d1ab43700da380846a315600de8a + digest: sha256:a014d05bf3b3ba52143ba26a7208177e186e1d574fdc1f82a340b68f8bea4768 diff --git a/.jsdoc.js b/.jsdoc.js index dba57ef85..7cb0f52a2 100644 --- a/.jsdoc.js +++ b/.jsdoc.js @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -34,15 +34,13 @@ module.exports = { source: { excludePattern: '(^|\\/|\\\\)[._]', include: [ - 'build/src' - ], - exclude: [ - 'build/src/v2' + 'build/src', + 'protos' ], includePattern: '\\.js$' }, templates: { - copyright: 'Copyright 2021 Google LLC', + copyright: 'Copyright 2022 Google LLC', includeDate: false, sourceFiles: false, systemName: '@google-cloud/bigtable', diff --git a/linkinator.config.json b/linkinator.config.json index 0121dfa68..befd23c86 100644 --- a/linkinator.config.json +++ b/linkinator.config.json @@ -3,8 +3,14 @@ "skip": [ "https://codecov.io/gh/googleapis/", "www.googleapis.com", - "img.shields.io" + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" ], "silent": true, - "concurrency": 5 + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 } diff --git a/owlbot.py b/owlbot.py index b51f0cc33..c13fbd8b8 100644 --- a/owlbot.py +++ b/owlbot.py @@ -50,6 +50,7 @@ for file in system_test_files: s.replace(file, 'BigtableClient', 'Bigtable') s.replace(file, 'client.close', '// client.close') # this does not work with the manual layer + s.replace(file, 'function doStuffWith', '// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction doStuffWith') # The staging directory should never be merged into the main branch. shutil.rmtree(staging) diff --git a/package.json b/package.json index b29fc1f2c..9abf03378 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "fix": "gts fix", "prelint": "cd samples; npm link ../; npm install", "lint": "gts check", - "prepare": "npm run compile", + "prepare": "npm run compile-protos && npm run compile", "samples-test": "cd samples/ && npm link ../ && npm install && npm test && cd ../", "snippet-test": "mocha samples/api-reference-doc-snippets/tests/*.js --timeout 600000", "presystem-test": "npm run compile", @@ -53,7 +53,7 @@ "dot-prop": "^6.0.0", "escape-string-regexp": "^4.0.0", "extend": "^3.0.2", - "google-gax": "^2.27.1", + "google-gax": "^2.29.5", "is": "^3.0.1", "is-utf8": "^0.2.1", "lodash.snakecase": "^4.1.1", diff --git a/protos/google/bigtable/v2/bigtable.proto b/protos/google/bigtable/v2/bigtable.proto index 94a842842..17b145665 100644 --- a/protos/google/bigtable/v2/bigtable.proto +++ b/protos/google/bigtable/v2/bigtable.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2019 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import "google/api/annotations.proto"; import "google/api/client.proto"; import "google/api/field_behavior.proto"; import "google/api/resource.proto"; +import "google/api/routing.proto"; import "google/bigtable/v2/data.proto"; import "google/protobuf/wrappers.proto"; import "google/rpc/status.proto"; @@ -57,6 +58,15 @@ service Bigtable { post: "/v2/{table_name=projects/*/instances/*/tables/*}:readRows" body: "*" }; + option (google.api.routing) = { + routing_parameters { + field: "table_name" + path_template: "{table_name=projects/*/instances/*/tables/*}" + } + routing_parameters { + field: "app_profile_id" + } + }; option (google.api.method_signature) = "table_name"; option (google.api.method_signature) = "table_name,app_profile_id"; } @@ -69,6 +79,15 @@ service Bigtable { option (google.api.http) = { get: "/v2/{table_name=projects/*/instances/*/tables/*}:sampleRowKeys" }; + option (google.api.routing) = { + routing_parameters { + field: "table_name" + path_template: "{table_name=projects/*/instances/*/tables/*}" + } + routing_parameters { + field: "app_profile_id" + } + }; option (google.api.method_signature) = "table_name"; option (google.api.method_signature) = "table_name,app_profile_id"; } @@ -80,6 +99,15 @@ service Bigtable { post: "/v2/{table_name=projects/*/instances/*/tables/*}:mutateRow" body: "*" }; + option (google.api.routing) = { + routing_parameters { + field: "table_name" + path_template: "{table_name=projects/*/instances/*/tables/*}" + } + routing_parameters { + field: "app_profile_id" + } + }; option (google.api.method_signature) = "table_name,row_key,mutations"; option (google.api.method_signature) = "table_name,row_key,mutations,app_profile_id"; } @@ -92,6 +120,15 @@ service Bigtable { post: "/v2/{table_name=projects/*/instances/*/tables/*}:mutateRows" body: "*" }; + option (google.api.routing) = { + routing_parameters { + field: "table_name" + path_template: "{table_name=projects/*/instances/*/tables/*}" + } + routing_parameters { + field: "app_profile_id" + } + }; option (google.api.method_signature) = "table_name,entries"; option (google.api.method_signature) = "table_name,entries,app_profile_id"; } @@ -102,6 +139,15 @@ service Bigtable { post: "/v2/{table_name=projects/*/instances/*/tables/*}:checkAndMutateRow" body: "*" }; + option (google.api.routing) = { + routing_parameters { + field: "table_name" + path_template: "{table_name=projects/*/instances/*/tables/*}" + } + routing_parameters { + field: "app_profile_id" + } + }; option (google.api.method_signature) = "table_name,row_key,predicate_filter,true_mutations,false_mutations"; option (google.api.method_signature) = "table_name,row_key,predicate_filter,true_mutations,false_mutations,app_profile_id"; } @@ -116,6 +162,15 @@ service Bigtable { post: "/v2/{table_name=projects/*/instances/*/tables/*}:readModifyWriteRow" body: "*" }; + option (google.api.routing) = { + routing_parameters { + field: "table_name" + path_template: "{table_name=projects/*/instances/*/tables/*}" + } + routing_parameters { + field: "app_profile_id" + } + }; option (google.api.method_signature) = "table_name,row_key,rules"; option (google.api.method_signature) = "table_name,row_key,rules,app_profile_id"; } @@ -137,14 +192,15 @@ message ReadRowsRequest { // "default" application profile will be used. string app_profile_id = 5; - // The row keys and/or ranges to read. If not specified, reads from all rows. + // The row keys and/or ranges to read sequentially. If not specified, reads + // from all rows. RowSet rows = 2; // The filter to apply to the contents of the specified row(s). If unset, // reads the entirety of each row. RowFilter filter = 3; - // The read will terminate after committing to N rows' worth of results. The + // The read will stop after committing to N rows' worth of results. The // default (zero) is to return all results. int64 rows_limit = 4; } diff --git a/protos/google/bigtable/v2/data.proto b/protos/google/bigtable/v2/data.proto index 2cc916454..7193ee753 100644 --- a/protos/google/bigtable/v2/data.proto +++ b/protos/google/bigtable/v2/data.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2019 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// syntax = "proto3"; @@ -210,7 +209,7 @@ message ValueRange { // RowFilter.Chain and RowFilter.Interleave documentation. // // The total serialized size of a RowFilter message must not -// exceed 4096 bytes, and RowFilters may not be nested within each other +// exceed 20480 bytes, and RowFilters may not be nested within each other // (in Chains or Interleaves) to a depth of more than 20. message RowFilter { // A RowFilter which sends rows through several RowFilters in sequence. diff --git a/protos/protos.d.ts b/protos/protos.d.ts index 97794d96e..7ba732019 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -13085,6 +13085,192 @@ export namespace google { */ public toJSON(): { [k: string]: any }; } + + /** 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 }; + } + + /** 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 }; + } } /** Namespace protobuf. */ @@ -15483,6 +15669,9 @@ export namespace google { /** MethodOptions .google.api.methodSignature */ ".google.api.methodSignature"?: (string[]|null); + /** MethodOptions .google.api.routing */ + ".google.api.routing"?: (google.api.IRoutingRule|null); + /** MethodOptions .google.longrunning.operationInfo */ ".google.longrunning.operationInfo"?: (google.longrunning.IOperationInfo|null); } diff --git a/protos/protos.js b/protos/protos.js index 62eda399c..f29dd53c6 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -31214,6 +31214,424 @@ return ResourceReference; })(); + 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); + }; + + 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); + }; + + return RoutingParameter; + })(); + return api; })(); @@ -37942,6 +38360,7 @@ * @property {Array.|null} [uninterpretedOption] MethodOptions uninterpretedOption * @property {google.api.IHttpRule|null} [".google.api.http"] MethodOptions .google.api.http * @property {Array.|null} [".google.api.methodSignature"] MethodOptions .google.api.methodSignature + * @property {google.api.IRoutingRule|null} [".google.api.routing"] MethodOptions .google.api.routing * @property {google.longrunning.IOperationInfo|null} [".google.longrunning.operationInfo"] MethodOptions .google.longrunning.operationInfo */ @@ -38002,6 +38421,14 @@ */ MethodOptions.prototype[".google.api.methodSignature"] = $util.emptyArray; + /** + * MethodOptions .google.api.routing. + * @member {google.api.IRoutingRule|null|undefined} .google.api.routing + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.api.routing"] = null; + /** * MethodOptions .google.longrunning.operationInfo. * @member {google.longrunning.IOperationInfo|null|undefined} .google.longrunning.operationInfo @@ -38048,6 +38475,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; }; @@ -38101,6 +38530,9 @@ message[".google.api.methodSignature"] = []; message[".google.api.methodSignature"].push(reader.string()); break; + case 72295729: + message[".google.api.routing"] = $root.google.api.RoutingRule.decode(reader, reader.uint32()); + break; case 1049: message[".google.longrunning.operationInfo"] = $root.google.longrunning.OperationInfo.decode(reader, reader.uint32()); break; @@ -38172,6 +38604,11 @@ if (!$util.isString(message[".google.api.methodSignature"][i])) return ".google.api.methodSignature: string[] expected"; } + 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; + } if (message[".google.longrunning.operationInfo"] != null && message.hasOwnProperty(".google.longrunning.operationInfo")) { var error = $root.google.longrunning.OperationInfo.verify(message[".google.longrunning.operationInfo"]); if (error) @@ -38230,6 +38667,11 @@ for (var i = 0; i < object[".google.api.methodSignature"].length; ++i) message[".google.api.methodSignature"][i] = String(object[".google.api.methodSignature"][i]); } + 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"]); + } if (object[".google.longrunning.operationInfo"] != null) { if (typeof object[".google.longrunning.operationInfo"] !== "object") throw TypeError(".google.protobuf.MethodOptions..google.longrunning.operationInfo: object expected"); @@ -38260,6 +38702,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; @@ -38279,6 +38722,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 cccbe144a..69288d77a 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -2568,6 +2568,8 @@ "options": { "(google.api.http).post": "/v2/{table_name=projects/*/instances/*/tables/*}:readRows", "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "app_profile_id", + "(google.api.routing).routing_parameters.path_template": "{table_name=projects/*/instances/*/tables/*}", "(google.api.method_signature)": "table_name,app_profile_id" }, "parsedOptions": [ @@ -2577,6 +2579,19 @@ "body": "*" } }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "table_name", + "path_template": "{table_name=projects/*/instances/*/tables/*}" + }, + { + "field": "app_profile_id" + } + ] + } + }, { "(google.api.method_signature)": "table_name" }, @@ -2591,6 +2606,8 @@ "responseStream": true, "options": { "(google.api.http).get": "/v2/{table_name=projects/*/instances/*/tables/*}:sampleRowKeys", + "(google.api.routing).routing_parameters.field": "app_profile_id", + "(google.api.routing).routing_parameters.path_template": "{table_name=projects/*/instances/*/tables/*}", "(google.api.method_signature)": "table_name,app_profile_id" }, "parsedOptions": [ @@ -2599,6 +2616,19 @@ "get": "/v2/{table_name=projects/*/instances/*/tables/*}:sampleRowKeys" } }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "table_name", + "path_template": "{table_name=projects/*/instances/*/tables/*}" + }, + { + "field": "app_profile_id" + } + ] + } + }, { "(google.api.method_signature)": "table_name" }, @@ -2613,6 +2643,8 @@ "options": { "(google.api.http).post": "/v2/{table_name=projects/*/instances/*/tables/*}:mutateRow", "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "app_profile_id", + "(google.api.routing).routing_parameters.path_template": "{table_name=projects/*/instances/*/tables/*}", "(google.api.method_signature)": "table_name,row_key,mutations,app_profile_id" }, "parsedOptions": [ @@ -2622,6 +2654,19 @@ "body": "*" } }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "table_name", + "path_template": "{table_name=projects/*/instances/*/tables/*}" + }, + { + "field": "app_profile_id" + } + ] + } + }, { "(google.api.method_signature)": "table_name,row_key,mutations" }, @@ -2637,6 +2682,8 @@ "options": { "(google.api.http).post": "/v2/{table_name=projects/*/instances/*/tables/*}:mutateRows", "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "app_profile_id", + "(google.api.routing).routing_parameters.path_template": "{table_name=projects/*/instances/*/tables/*}", "(google.api.method_signature)": "table_name,entries,app_profile_id" }, "parsedOptions": [ @@ -2646,6 +2693,19 @@ "body": "*" } }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "table_name", + "path_template": "{table_name=projects/*/instances/*/tables/*}" + }, + { + "field": "app_profile_id" + } + ] + } + }, { "(google.api.method_signature)": "table_name,entries" }, @@ -2660,6 +2720,8 @@ "options": { "(google.api.http).post": "/v2/{table_name=projects/*/instances/*/tables/*}:checkAndMutateRow", "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "app_profile_id", + "(google.api.routing).routing_parameters.path_template": "{table_name=projects/*/instances/*/tables/*}", "(google.api.method_signature)": "table_name,row_key,predicate_filter,true_mutations,false_mutations,app_profile_id" }, "parsedOptions": [ @@ -2669,6 +2731,19 @@ "body": "*" } }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "table_name", + "path_template": "{table_name=projects/*/instances/*/tables/*}" + }, + { + "field": "app_profile_id" + } + ] + } + }, { "(google.api.method_signature)": "table_name,row_key,predicate_filter,true_mutations,false_mutations" }, @@ -2683,6 +2758,8 @@ "options": { "(google.api.http).post": "/v2/{table_name=projects/*/instances/*/tables/*}:readModifyWriteRow", "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "app_profile_id", + "(google.api.routing).routing_parameters.path_template": "{table_name=projects/*/instances/*/tables/*}", "(google.api.method_signature)": "table_name,row_key,rules,app_profile_id" }, "parsedOptions": [ @@ -2692,6 +2769,19 @@ "body": "*" } }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "table_name", + "path_template": "{table_name=projects/*/instances/*/tables/*}" + }, + { + "field": "app_profile_id" + } + ] + } + }, { "(google.api.method_signature)": "table_name,row_key,rules" }, @@ -3449,7 +3539,7 @@ "options": { "go_package": "google.golang.org/genproto/googleapis/api/annotations;annotations", "java_multiple_files": true, - "java_outer_classname": "ResourceProto", + "java_outer_classname": "RoutingProto", "java_package": "com.google.api", "objc_class_prefix": "GAPI", "cc_enable_arenas": true @@ -3652,6 +3742,32 @@ "id": 2 } } + }, + "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/samples/generated/v2/bigtable.check_and_mutate_row.js b/samples/generated/v2/bigtable.check_and_mutate_row.js index 2b17cbb17..0175b8960 100644 --- a/samples/generated/v2/bigtable.check_and_mutate_row.js +++ b/samples/generated/v2/bigtable.check_and_mutate_row.js @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. + 'use strict'; function main(tableName, rowKey) { diff --git a/samples/generated/v2/bigtable.mutate_row.js b/samples/generated/v2/bigtable.mutate_row.js index ad3838420..16e28ad77 100644 --- a/samples/generated/v2/bigtable.mutate_row.js +++ b/samples/generated/v2/bigtable.mutate_row.js @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. + 'use strict'; function main(tableName, rowKey, mutations) { diff --git a/samples/generated/v2/bigtable.mutate_rows.js b/samples/generated/v2/bigtable.mutate_rows.js index 60e170822..0e5ec322b 100644 --- a/samples/generated/v2/bigtable.mutate_rows.js +++ b/samples/generated/v2/bigtable.mutate_rows.js @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. + 'use strict'; function main(tableName, entries) { @@ -52,15 +53,9 @@ function main(tableName, entries) { // Run request const stream = await bigtableClient.mutateRows(request); - stream.on('data', response => { - console.log(response); - }); - stream.on('error', err => { - throw err; - }); - stream.on('end', () => { - /* API call completed */ - }); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); } callMutateRows(); diff --git a/samples/generated/v2/bigtable.read_modify_write_row.js b/samples/generated/v2/bigtable.read_modify_write_row.js index 8633cef80..2a3f7e049 100644 --- a/samples/generated/v2/bigtable.read_modify_write_row.js +++ b/samples/generated/v2/bigtable.read_modify_write_row.js @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. + 'use strict'; function main(tableName, rowKey, rules) { diff --git a/samples/generated/v2/bigtable.read_rows.js b/samples/generated/v2/bigtable.read_rows.js index fa7429f0f..8d8156eb0 100644 --- a/samples/generated/v2/bigtable.read_rows.js +++ b/samples/generated/v2/bigtable.read_rows.js @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. + 'use strict'; function main(tableName) { @@ -31,7 +32,8 @@ function main(tableName) { */ // const appProfileId = 'abc123' /** - * The row keys and/or ranges to read. If not specified, reads from all rows. + * The row keys and/or ranges to read sequentially. If not specified, reads + * from all rows. */ // const rows = {} /** @@ -40,7 +42,7 @@ function main(tableName) { */ // const filter = {} /** - * The read will terminate after committing to N rows' worth of results. The + * The read will stop after committing to N rows' worth of results. The * default (zero) is to return all results. */ // const rowsLimit = 1234 @@ -59,15 +61,9 @@ function main(tableName) { // Run request const stream = await bigtableClient.readRows(request); - stream.on('data', response => { - console.log(response); - }); - stream.on('error', err => { - throw err; - }); - stream.on('end', () => { - /* API call completed */ - }); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); } callReadRows(); diff --git a/samples/generated/v2/bigtable.sample_row_keys.js b/samples/generated/v2/bigtable.sample_row_keys.js index ad006b89e..902385fbd 100644 --- a/samples/generated/v2/bigtable.sample_row_keys.js +++ b/samples/generated/v2/bigtable.sample_row_keys.js @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. + 'use strict'; function main(tableName) { @@ -45,15 +46,9 @@ function main(tableName) { // Run request const stream = await bigtableClient.sampleRowKeys(request); - stream.on('data', response => { - console.log(response); - }); - stream.on('error', err => { - throw err; - }); - stream.on('end', () => { - /* API call completed */ - }); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); } callSampleRowKeys(); diff --git a/src/cluster.ts b/src/cluster.ts index 3f6f3addd..11479e699 100644 --- a/src/cluster.ts +++ b/src/cluster.ts @@ -522,6 +522,7 @@ Please use the format 'my-cluster' or '${instance.name}/clusters/my-cluster'.`); const backupInstance = this.id === '-' ? this.instance + // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain .cluster(backup.name?.match(/clusters\/([^/]+)/)![1]!) .backup(backup.name!.split('/').pop()!) : this.backup(backup.name!.split('/').pop()!); @@ -594,6 +595,7 @@ Please use the format 'my-cluster' or '${instance.name}/clusters/my-cluster'.`); const backupInstance = this.id === '-' ? this.instance + // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain .cluster(backup.name?.match(/clusters\/([^/]+)/)![1]!) .backup(backup.name!.split('/').pop()!) : this.backup(backup.name!.split('/').pop()!); diff --git a/src/index.ts b/src/index.ts index 20473afc5..997824b82 100644 --- a/src/index.ts +++ b/src/index.ts @@ -751,7 +751,7 @@ export class Bigtable { return new Instance(this, name); } - // eslint-disable-next-line @typescript-eslint/no-explicit-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars request(config?: any): AbortableDuplex; // eslint-disable-next-line @typescript-eslint/no-explicit-any request(config?: any, callback?: RequestCallback): void; @@ -957,7 +957,7 @@ promisifyAll(Bigtable, { */ // Allow creating a `Bigtable` instance without using the `new` keyword. -// eslint-disable-next-line @typescript-eslint/no-explicit-any +// eslint-disable-next-line @typescript-eslint/no-explicit-any, no-class-assign (Bigtable as any) = new Proxy(Bigtable, { apply(target, thisArg, argumentsList) { // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/src/v2/bigtable_client.ts b/src/v2/bigtable_client.ts index ce1496ec2..560410767 100644 --- a/src/v2/bigtable_client.ts +++ b/src/v2/bigtable_client.ts @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -407,10 +407,31 @@ export class BigtableClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - table_name: request.tableName || '', + const routingParameter = {}; + if ( + typeof request.tableName !== 'undefined' && + RegExp('(?projects)/[^/]+/instances/[^/]+/tables/[^/]+').test( + request.tableName! + ) + ) { + Object.assign(routingParameter, { + table_name: request.tableName!.match( + RegExp('(?projects/[^/]+/instances/[^/]+/tables/[^/]+)') + )![0], + }); + } + + if ( + typeof request.appProfileId !== 'undefined' && + RegExp('[^/]+').test(request.appProfileId!) + ) { + Object.assign(routingParameter, { + app_profile_id: request.appProfileId!.match(RegExp('[^/]+'))![0], }); + } + + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.mutateRow(request, options, callback); } @@ -517,10 +538,31 @@ export class BigtableClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - table_name: request.tableName || '', + const routingParameter = {}; + if ( + typeof request.tableName !== 'undefined' && + RegExp('(?projects)/[^/]+/instances/[^/]+/tables/[^/]+').test( + request.tableName! + ) + ) { + Object.assign(routingParameter, { + table_name: request.tableName!.match( + RegExp('(?projects/[^/]+/instances/[^/]+/tables/[^/]+)') + )![0], + }); + } + + if ( + typeof request.appProfileId !== 'undefined' && + RegExp('[^/]+').test(request.appProfileId!) + ) { + Object.assign(routingParameter, { + app_profile_id: request.appProfileId!.match(RegExp('[^/]+'))![0], }); + } + + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.checkAndMutateRow(request, options, callback); } @@ -618,10 +660,31 @@ export class BigtableClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - table_name: request.tableName || '', + const routingParameter = {}; + if ( + typeof request.tableName !== 'undefined' && + RegExp('(?projects)/[^/]+/instances/[^/]+/tables/[^/]+').test( + request.tableName! + ) + ) { + Object.assign(routingParameter, { + table_name: request.tableName!.match( + RegExp('(?projects/[^/]+/instances/[^/]+/tables/[^/]+)') + )![0], + }); + } + + if ( + typeof request.appProfileId !== 'undefined' && + RegExp('[^/]+').test(request.appProfileId!) + ) { + Object.assign(routingParameter, { + app_profile_id: request.appProfileId!.match(RegExp('[^/]+'))![0], }); + } + + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.readModifyWriteRow(request, options, callback); } @@ -643,12 +706,13 @@ export class BigtableClient { * This value specifies routing for replication. If not specified, the * "default" application profile will be used. * @param {google.bigtable.v2.RowSet} request.rows - * The row keys and/or ranges to read. If not specified, reads from all rows. + * The row keys and/or ranges to read sequentially. If not specified, reads + * from all rows. * @param {google.bigtable.v2.RowFilter} request.filter * The filter to apply to the contents of the specified row(s). If unset, * reads the entirety of each row. * @param {number} request.rowsLimit - * The read will terminate after committing to N rows' worth of results. The + * The read will stop after committing to N rows' worth of results. The * default (zero) is to return all results. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. @@ -668,10 +732,31 @@ export class BigtableClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - table_name: request.tableName || '', + const routingParameter = {}; + if ( + typeof request.tableName !== 'undefined' && + RegExp('(?projects)/[^/]+/instances/[^/]+/tables/[^/]+').test( + request.tableName! + ) + ) { + Object.assign(routingParameter, { + table_name: request.tableName!.match( + RegExp('(?projects/[^/]+/instances/[^/]+/tables/[^/]+)') + )![0], + }); + } + + if ( + typeof request.appProfileId !== 'undefined' && + RegExp('[^/]+').test(request.appProfileId!) + ) { + Object.assign(routingParameter, { + app_profile_id: request.appProfileId!.match(RegExp('[^/]+'))![0], }); + } + + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.readRows(request, options); } @@ -709,10 +794,31 @@ export class BigtableClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - table_name: request.tableName || '', + const routingParameter = {}; + if ( + typeof request.tableName !== 'undefined' && + RegExp('(?projects)/[^/]+/instances/[^/]+/tables/[^/]+').test( + request.tableName! + ) + ) { + Object.assign(routingParameter, { + table_name: request.tableName!.match( + RegExp('(?projects/[^/]+/instances/[^/]+/tables/[^/]+)') + )![0], + }); + } + + if ( + typeof request.appProfileId !== 'undefined' && + RegExp('[^/]+').test(request.appProfileId!) + ) { + Object.assign(routingParameter, { + app_profile_id: request.appProfileId!.match(RegExp('[^/]+'))![0], }); + } + + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.sampleRowKeys(request, options); } @@ -753,10 +859,31 @@ export class BigtableClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - table_name: request.tableName || '', + const routingParameter = {}; + if ( + typeof request.tableName !== 'undefined' && + RegExp('(?projects)/[^/]+/instances/[^/]+/tables/[^/]+').test( + request.tableName! + ) + ) { + Object.assign(routingParameter, { + table_name: request.tableName!.match( + RegExp('(?projects/[^/]+/instances/[^/]+/tables/[^/]+)') + )![0], + }); + } + + if ( + typeof request.appProfileId !== 'undefined' && + RegExp('[^/]+').test(request.appProfileId!) + ) { + Object.assign(routingParameter, { + app_profile_id: request.appProfileId!.match(RegExp('[^/]+'))![0], }); + } + + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams(routingParameter); this.initialize(); return this.innerApiCalls.mutateRows(request, options); } diff --git a/src/v2/gapic_metadata.json b/src/v2/gapic_metadata.json index f53c67d90..6e578d2c9 100644 --- a/src/v2/gapic_metadata.json +++ b/src/v2/gapic_metadata.json @@ -2,467 +2,62 @@ "schema": "1.0", "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", "language": "typescript", - "protoPackage": "google.bigtable.admin.v2", + "protoPackage": "google.bigtable.v2", "libraryPackage": "@google-cloud/bigtable", "services": { - "BigtableInstanceAdmin": { + "Bigtable": { "clients": { "grpc": { - "libraryClient": "BigtableInstanceAdminClient", + "libraryClient": "BigtableClient", "rpcs": { - "GetInstance": { + "MutateRow": { "methods": [ - "getInstance" + "mutateRow" ] }, - "ListInstances": { + "CheckAndMutateRow": { "methods": [ - "listInstances" + "checkAndMutateRow" ] }, - "UpdateInstance": { + "ReadModifyWriteRow": { "methods": [ - "updateInstance" + "readModifyWriteRow" ] }, - "DeleteInstance": { + "ReadRows": { "methods": [ - "deleteInstance" + "readRows" ] }, - "GetCluster": { + "SampleRowKeys": { "methods": [ - "getCluster" + "sampleRowKeys" ] }, - "ListClusters": { + "MutateRows": { "methods": [ - "listClusters" - ] - }, - "DeleteCluster": { - "methods": [ - "deleteCluster" - ] - }, - "CreateAppProfile": { - "methods": [ - "createAppProfile" - ] - }, - "GetAppProfile": { - "methods": [ - "getAppProfile" - ] - }, - "DeleteAppProfile": { - "methods": [ - "deleteAppProfile" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateInstance": { - "methods": [ - "createInstance" - ] - }, - "PartialUpdateInstance": { - "methods": [ - "partialUpdateInstance" - ] - }, - "CreateCluster": { - "methods": [ - "createCluster" - ] - }, - "UpdateCluster": { - "methods": [ - "updateCluster" - ] - }, - "PartialUpdateCluster": { - "methods": [ - "partialUpdateCluster" - ] - }, - "UpdateAppProfile": { - "methods": [ - "updateAppProfile" - ] - }, - "ListAppProfiles": { - "methods": [ - "listAppProfiles", - "listAppProfilesStream", - "listAppProfilesAsync" + "mutateRows" ] } } }, "grpc-fallback": { - "libraryClient": "BigtableInstanceAdminClient", - "rpcs": { - "GetInstance": { - "methods": [ - "getInstance" - ] - }, - "ListInstances": { - "methods": [ - "listInstances" - ] - }, - "UpdateInstance": { - "methods": [ - "updateInstance" - ] - }, - "DeleteInstance": { - "methods": [ - "deleteInstance" - ] - }, - "GetCluster": { - "methods": [ - "getCluster" - ] - }, - "ListClusters": { - "methods": [ - "listClusters" - ] - }, - "DeleteCluster": { - "methods": [ - "deleteCluster" - ] - }, - "CreateAppProfile": { - "methods": [ - "createAppProfile" - ] - }, - "GetAppProfile": { - "methods": [ - "getAppProfile" - ] - }, - "DeleteAppProfile": { - "methods": [ - "deleteAppProfile" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateInstance": { - "methods": [ - "createInstance" - ] - }, - "PartialUpdateInstance": { - "methods": [ - "partialUpdateInstance" - ] - }, - "CreateCluster": { - "methods": [ - "createCluster" - ] - }, - "UpdateCluster": { - "methods": [ - "updateCluster" - ] - }, - "PartialUpdateCluster": { - "methods": [ - "partialUpdateCluster" - ] - }, - "UpdateAppProfile": { - "methods": [ - "updateAppProfile" - ] - }, - "ListAppProfiles": { - "methods": [ - "listAppProfiles", - "listAppProfilesStream", - "listAppProfilesAsync" - ] - } - } - } - } - }, - "BigtableTableAdmin": { - "clients": { - "grpc": { - "libraryClient": "BigtableTableAdminClient", + "libraryClient": "BigtableClient", "rpcs": { - "CreateTable": { - "methods": [ - "createTable" - ] - }, - "GetTable": { - "methods": [ - "getTable" - ] - }, - "DeleteTable": { - "methods": [ - "deleteTable" - ] - }, - "ModifyColumnFamilies": { - "methods": [ - "modifyColumnFamilies" - ] - }, - "DropRowRange": { - "methods": [ - "dropRowRange" - ] - }, - "GenerateConsistencyToken": { - "methods": [ - "generateConsistencyToken" - ] - }, - "CheckConsistency": { - "methods": [ - "checkConsistency" - ] - }, - "GetSnapshot": { - "methods": [ - "getSnapshot" - ] - }, - "DeleteSnapshot": { - "methods": [ - "deleteSnapshot" - ] - }, - "GetBackup": { - "methods": [ - "getBackup" - ] - }, - "UpdateBackup": { - "methods": [ - "updateBackup" - ] - }, - "DeleteBackup": { - "methods": [ - "deleteBackup" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateTableFromSnapshot": { - "methods": [ - "createTableFromSnapshot" - ] - }, - "SnapshotTable": { - "methods": [ - "snapshotTable" - ] - }, - "CreateBackup": { - "methods": [ - "createBackup" - ] - }, - "RestoreTable": { - "methods": [ - "restoreTable" - ] - }, - "ListTables": { - "methods": [ - "listTables", - "listTablesStream", - "listTablesAsync" - ] - }, - "ListSnapshots": { - "methods": [ - "listSnapshots", - "listSnapshotsStream", - "listSnapshotsAsync" - ] - }, - "ListBackups": { - "methods": [ - "listBackups", - "listBackupsStream", - "listBackupsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "BigtableTableAdminClient", - "rpcs": { - "CreateTable": { - "methods": [ - "createTable" - ] - }, - "GetTable": { - "methods": [ - "getTable" - ] - }, - "DeleteTable": { - "methods": [ - "deleteTable" - ] - }, - "ModifyColumnFamilies": { - "methods": [ - "modifyColumnFamilies" - ] - }, - "DropRowRange": { - "methods": [ - "dropRowRange" - ] - }, - "GenerateConsistencyToken": { - "methods": [ - "generateConsistencyToken" - ] - }, - "CheckConsistency": { - "methods": [ - "checkConsistency" - ] - }, - "GetSnapshot": { - "methods": [ - "getSnapshot" - ] - }, - "DeleteSnapshot": { - "methods": [ - "deleteSnapshot" - ] - }, - "GetBackup": { - "methods": [ - "getBackup" - ] - }, - "UpdateBackup": { - "methods": [ - "updateBackup" - ] - }, - "DeleteBackup": { - "methods": [ - "deleteBackup" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateTableFromSnapshot": { - "methods": [ - "createTableFromSnapshot" - ] - }, - "SnapshotTable": { - "methods": [ - "snapshotTable" - ] - }, - "CreateBackup": { - "methods": [ - "createBackup" - ] - }, - "RestoreTable": { - "methods": [ - "restoreTable" - ] - }, - "ListTables": { + "MutateRow": { "methods": [ - "listTables", - "listTablesStream", - "listTablesAsync" + "mutateRow" ] }, - "ListSnapshots": { + "CheckAndMutateRow": { "methods": [ - "listSnapshots", - "listSnapshotsStream", - "listSnapshotsAsync" + "checkAndMutateRow" ] }, - "ListBackups": { + "ReadModifyWriteRow": { "methods": [ - "listBackups", - "listBackupsStream", - "listBackupsAsync" + "readModifyWriteRow" ] } } diff --git a/system-test/bigtable.ts b/system-test/bigtable.ts index 8282a1538..5b28f9726 100644 --- a/system-test/bigtable.ts +++ b/system-test/bigtable.ts @@ -220,6 +220,7 @@ describe('Bigtable', () => { }); cryptoKeyVersionName = resp.data.primary.name; + // eslint-disable-next-line @typescript-eslint/no-unused-vars const [_, operation] = await CMEK_INSTANCE.create({ clusters: [ { @@ -254,6 +255,7 @@ describe('Bigtable', () => { it('should create a cluster', async () => { const cluster = CMEK_INSTANCE.cluster(generateId('cluster')); + // eslint-disable-next-line @typescript-eslint/no-unused-vars const [_, operation] = await cluster.create({ location: 'us-central1-b', nodes: 3, @@ -269,6 +271,7 @@ describe('Bigtable', () => { const cluster = CMEK_INSTANCE.cluster(generateId('cluster')); try { + // eslint-disable-next-line @typescript-eslint/no-unused-vars const [_, operation] = await cluster.create({ location: 'us-central1-b', nodes: 3, diff --git a/system-test/fixtures/sample/src/index.js b/system-test/fixtures/sample/src/index.js index f232229d7..88b56b8b8 100644 --- a/system-test/fixtures/sample/src/index.js +++ b/system-test/fixtures/sample/src/index.js @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC +// Copyright 2022 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 90e054464..7b598ec1c 100644 --- a/system-test/fixtures/sample/src/index.ts +++ b/system-test/fixtures/sample/src/index.ts @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import {Bigtable} from '@google-cloud/bigtable'; // check that the client class type name can be used +// eslint-disable-next-line @typescript-eslint/no-unused-vars function doStuffWithBigtable(client: Bigtable) { // client.close(); } diff --git a/system-test/install.ts b/system-test/install.ts index d2d61c039..6dd1eaada 100644 --- a/system-test/install.ts +++ b/system-test/install.ts @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC +// Copyright 2022 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_bigtable_v2.ts b/test/gapic_bigtable_v2.ts index ef8dea34e..ffa8554b8 100644 --- a/test/gapic_bigtable_v2.ts +++ b/test/gapic_bigtable_v2.ts @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -163,8 +163,7 @@ describe('v2.BigtableClient', () => { const request = generateSampleMessage( new protos.google.bigtable.v2.MutateRowRequest() ); - request.tableName = ''; - const expectedHeaderRequestParams = 'table_name='; + const expectedHeaderRequestParams = ''; const expectedOptions = { otherArgs: { headers: { @@ -194,8 +193,7 @@ describe('v2.BigtableClient', () => { const request = generateSampleMessage( new protos.google.bigtable.v2.MutateRowRequest() ); - request.tableName = ''; - const expectedHeaderRequestParams = 'table_name='; + const expectedHeaderRequestParams = ''; const expectedOptions = { otherArgs: { headers: { @@ -241,8 +239,7 @@ describe('v2.BigtableClient', () => { const request = generateSampleMessage( new protos.google.bigtable.v2.MutateRowRequest() ); - request.tableName = ''; - const expectedHeaderRequestParams = 'table_name='; + const expectedHeaderRequestParams = ''; const expectedOptions = { otherArgs: { headers: { @@ -271,8 +268,7 @@ describe('v2.BigtableClient', () => { const request = generateSampleMessage( new protos.google.bigtable.v2.CheckAndMutateRowRequest() ); - request.tableName = ''; - const expectedHeaderRequestParams = 'table_name='; + const expectedHeaderRequestParams = ''; const expectedOptions = { otherArgs: { headers: { @@ -302,8 +298,7 @@ describe('v2.BigtableClient', () => { const request = generateSampleMessage( new protos.google.bigtable.v2.CheckAndMutateRowRequest() ); - request.tableName = ''; - const expectedHeaderRequestParams = 'table_name='; + const expectedHeaderRequestParams = ''; const expectedOptions = { otherArgs: { headers: { @@ -349,8 +344,7 @@ describe('v2.BigtableClient', () => { const request = generateSampleMessage( new protos.google.bigtable.v2.CheckAndMutateRowRequest() ); - request.tableName = ''; - const expectedHeaderRequestParams = 'table_name='; + const expectedHeaderRequestParams = ''; const expectedOptions = { otherArgs: { headers: { @@ -382,8 +376,7 @@ describe('v2.BigtableClient', () => { const request = generateSampleMessage( new protos.google.bigtable.v2.ReadModifyWriteRowRequest() ); - request.tableName = ''; - const expectedHeaderRequestParams = 'table_name='; + const expectedHeaderRequestParams = ''; const expectedOptions = { otherArgs: { headers: { @@ -414,8 +407,7 @@ describe('v2.BigtableClient', () => { const request = generateSampleMessage( new protos.google.bigtable.v2.ReadModifyWriteRowRequest() ); - request.tableName = ''; - const expectedHeaderRequestParams = 'table_name='; + const expectedHeaderRequestParams = ''; const expectedOptions = { otherArgs: { headers: { @@ -461,8 +453,7 @@ describe('v2.BigtableClient', () => { const request = generateSampleMessage( new protos.google.bigtable.v2.ReadModifyWriteRowRequest() ); - request.tableName = ''; - const expectedHeaderRequestParams = 'table_name='; + const expectedHeaderRequestParams = ''; const expectedOptions = { otherArgs: { headers: { @@ -494,8 +485,7 @@ describe('v2.BigtableClient', () => { const request = generateSampleMessage( new protos.google.bigtable.v2.ReadRowsRequest() ); - request.tableName = ''; - const expectedHeaderRequestParams = 'table_name='; + const expectedHeaderRequestParams = ''; const expectedOptions = { otherArgs: { headers: { @@ -537,8 +527,7 @@ describe('v2.BigtableClient', () => { const request = generateSampleMessage( new protos.google.bigtable.v2.ReadRowsRequest() ); - request.tableName = ''; - const expectedHeaderRequestParams = 'table_name='; + const expectedHeaderRequestParams = ''; const expectedOptions = { otherArgs: { headers: { @@ -582,8 +571,7 @@ describe('v2.BigtableClient', () => { const request = generateSampleMessage( new protos.google.bigtable.v2.SampleRowKeysRequest() ); - request.tableName = ''; - const expectedHeaderRequestParams = 'table_name='; + const expectedHeaderRequestParams = ''; const expectedOptions = { otherArgs: { headers: { @@ -626,8 +614,7 @@ describe('v2.BigtableClient', () => { const request = generateSampleMessage( new protos.google.bigtable.v2.SampleRowKeysRequest() ); - request.tableName = ''; - const expectedHeaderRequestParams = 'table_name='; + const expectedHeaderRequestParams = ''; const expectedOptions = { otherArgs: { headers: { @@ -671,8 +658,7 @@ describe('v2.BigtableClient', () => { const request = generateSampleMessage( new protos.google.bigtable.v2.MutateRowsRequest() ); - request.tableName = ''; - const expectedHeaderRequestParams = 'table_name='; + const expectedHeaderRequestParams = ''; const expectedOptions = { otherArgs: { headers: { @@ -715,8 +701,7 @@ describe('v2.BigtableClient', () => { const request = generateSampleMessage( new protos.google.bigtable.v2.MutateRowsRequest() ); - request.tableName = ''; - const expectedHeaderRequestParams = 'table_name='; + const expectedHeaderRequestParams = ''; const expectedOptions = { otherArgs: { headers: { diff --git a/test/instance.ts b/test/instance.ts index 910734779..988dee2ad 100644 --- a/test/instance.ts +++ b/test/instance.ts @@ -32,7 +32,7 @@ import { import {Bigtable, RequestOptions} from '../src'; import {PassThrough} from 'stream'; import * as pumpify from 'pumpify'; -import {RestoreTableCallback, RestoreTableConfig} from '../src/backup'; +import {RestoreTableConfig} from '../src/backup'; const sandbox = sinon.createSandbox();