diff --git a/protos/google/bigtable/admin/v2/types.proto b/protos/google/bigtable/admin/v2/types.proto index 222a6a2e5..053296189 100644 --- a/protos/google/bigtable/admin/v2/types.proto +++ b/protos/google/bigtable/admin/v2/types.proto @@ -41,18 +41,18 @@ option ruby_package = "Google::Cloud::Bigtable::Admin::V2"; // * Natural sort: Does the encoded value sort consistently with the original // typed value? Note that Bigtable will always sort data based on the raw // encoded value, *not* the decoded type. -// - Example: STRING values sort in the same order as their UTF-8 encodings. +// - Example: BYTES values sort in the same order as their raw encodings. // - Counterexample: Encoding INT64 to a fixed-width STRING does *not* // preserve sort order when dealing with negative numbers. // INT64(1) > INT64(-1), but STRING("-00001") > STRING("00001). -// - The overall encoding chain sorts naturally if *every* link does. +// - The overall encoding chain has this property if *every* link does. // * Self-delimiting: If we concatenate two encoded values, can we always tell // where the first one ends and the second one begins? // - Example: If we encode INT64s to fixed-width STRINGs, the first value // will always contain exactly N digits, possibly preceded by a sign. // - Counterexample: If we concatenate two UTF-8 encoded STRINGs, we have // no way to tell where the first one ends. -// - The overall encoding chain is self-delimiting if *any* link is. +// - The overall encoding chain has this property if *any* link does. // * Compatibility: Which other systems have matching encoding schemes? For // example, does this encoding have a GoogleSQL equivalent? HBase? Java? message Type { @@ -78,6 +78,31 @@ message Type { Encoding encoding = 1; } + // String + // Values of type `String` are stored in `Value.string_value`. + message String { + // Rules used to convert to/from lower level types. + message Encoding { + // UTF-8 encoding + // * Natural sort? No (ASCII characters only) + // * Self-delimiting? No + // * Compatibility? + // - BigQuery Federation `TEXT` encoding + // - HBase `Bytes.toBytes` + // - Java `String#getBytes(StandardCharsets.UTF_8)` + message Utf8Raw {} + + // Which encoding to use. + oneof encoding { + // Use `Utf8Raw` encoding. + Utf8Raw utf8_raw = 1; + } + } + + // The encoding to use when converting to/from lower level types. + Encoding encoding = 1; + } + // Int64 // Values of type `Int64` are stored in `Value.int_value`. message Int64 { @@ -140,6 +165,9 @@ message Type { // Bytes Bytes bytes_type = 1; + // String + String string_type = 2; + // Int64 Int64 int64_type = 5; diff --git a/protos/protos.d.ts b/protos/protos.d.ts index c897e6ee2..9be2489a6 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -12532,6 +12532,9 @@ export namespace google { /** Type bytesType */ bytesType?: (google.bigtable.admin.v2.Type.IBytes|null); + /** Type stringType */ + stringType?: (google.bigtable.admin.v2.Type.IString|null); + /** Type int64Type */ int64Type?: (google.bigtable.admin.v2.Type.IInt64|null); @@ -12551,6 +12554,9 @@ export namespace google { /** Type bytesType. */ public bytesType?: (google.bigtable.admin.v2.Type.IBytes|null); + /** Type stringType. */ + public stringType?: (google.bigtable.admin.v2.Type.IString|null); + /** Type int64Type. */ public int64Type?: (google.bigtable.admin.v2.Type.IInt64|null); @@ -12558,7 +12564,7 @@ export namespace google { public aggregateType?: (google.bigtable.admin.v2.Type.IAggregate|null); /** Type kind. */ - public kind?: ("bytesType"|"int64Type"|"aggregateType"); + public kind?: ("bytesType"|"stringType"|"int64Type"|"aggregateType"); /** * Creates a new Type instance using the specified properties. @@ -12934,6 +12940,300 @@ export namespace google { } } + /** Properties of a String. */ + interface IString { + + /** String encoding */ + encoding?: (google.bigtable.admin.v2.Type.String.IEncoding|null); + } + + /** Represents a String. */ + class String implements IString { + + /** + * Constructs a new String. + * @param [properties] Properties to set + */ + constructor(properties?: google.bigtable.admin.v2.Type.IString); + + /** String encoding. */ + public encoding?: (google.bigtable.admin.v2.Type.String.IEncoding|null); + + /** + * Creates a new String instance using the specified properties. + * @param [properties] Properties to set + * @returns String instance + */ + public static create(properties?: google.bigtable.admin.v2.Type.IString): google.bigtable.admin.v2.Type.String; + + /** + * Encodes the specified String message. Does not implicitly {@link google.bigtable.admin.v2.Type.String.verify|verify} messages. + * @param message String message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.bigtable.admin.v2.Type.IString, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified String message, length delimited. Does not implicitly {@link google.bigtable.admin.v2.Type.String.verify|verify} messages. + * @param message String message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.bigtable.admin.v2.Type.IString, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a String message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns String + * @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.bigtable.admin.v2.Type.String; + + /** + * Decodes a String message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns String + * @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.bigtable.admin.v2.Type.String; + + /** + * Verifies a String 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 String message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns String + */ + public static fromObject(object: { [k: string]: any }): google.bigtable.admin.v2.Type.String; + + /** + * Creates a plain object from a String message. Also converts values to other types if specified. + * @param message String + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.bigtable.admin.v2.Type.String, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this String to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for String + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace String { + + /** Properties of an Encoding. */ + interface IEncoding { + + /** Encoding utf8Raw */ + utf8Raw?: (google.bigtable.admin.v2.Type.String.Encoding.IUtf8Raw|null); + } + + /** Represents an Encoding. */ + class Encoding implements IEncoding { + + /** + * Constructs a new Encoding. + * @param [properties] Properties to set + */ + constructor(properties?: google.bigtable.admin.v2.Type.String.IEncoding); + + /** Encoding utf8Raw. */ + public utf8Raw?: (google.bigtable.admin.v2.Type.String.Encoding.IUtf8Raw|null); + + /** Encoding encoding. */ + public encoding?: "utf8Raw"; + + /** + * Creates a new Encoding instance using the specified properties. + * @param [properties] Properties to set + * @returns Encoding instance + */ + public static create(properties?: google.bigtable.admin.v2.Type.String.IEncoding): google.bigtable.admin.v2.Type.String.Encoding; + + /** + * Encodes the specified Encoding message. Does not implicitly {@link google.bigtable.admin.v2.Type.String.Encoding.verify|verify} messages. + * @param message Encoding message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.bigtable.admin.v2.Type.String.IEncoding, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Encoding message, length delimited. Does not implicitly {@link google.bigtable.admin.v2.Type.String.Encoding.verify|verify} messages. + * @param message Encoding message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.bigtable.admin.v2.Type.String.IEncoding, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Encoding message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Encoding + * @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.bigtable.admin.v2.Type.String.Encoding; + + /** + * Decodes an Encoding message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Encoding + * @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.bigtable.admin.v2.Type.String.Encoding; + + /** + * Verifies an Encoding 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 an Encoding message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Encoding + */ + public static fromObject(object: { [k: string]: any }): google.bigtable.admin.v2.Type.String.Encoding; + + /** + * Creates a plain object from an Encoding message. Also converts values to other types if specified. + * @param message Encoding + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.bigtable.admin.v2.Type.String.Encoding, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Encoding to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Encoding + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Encoding { + + /** Properties of an Utf8Raw. */ + interface IUtf8Raw { + } + + /** Represents an Utf8Raw. */ + class Utf8Raw implements IUtf8Raw { + + /** + * Constructs a new Utf8Raw. + * @param [properties] Properties to set + */ + constructor(properties?: google.bigtable.admin.v2.Type.String.Encoding.IUtf8Raw); + + /** + * Creates a new Utf8Raw instance using the specified properties. + * @param [properties] Properties to set + * @returns Utf8Raw instance + */ + public static create(properties?: google.bigtable.admin.v2.Type.String.Encoding.IUtf8Raw): google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw; + + /** + * Encodes the specified Utf8Raw message. Does not implicitly {@link google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw.verify|verify} messages. + * @param message Utf8Raw message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.bigtable.admin.v2.Type.String.Encoding.IUtf8Raw, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Utf8Raw message, length delimited. Does not implicitly {@link google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw.verify|verify} messages. + * @param message Utf8Raw message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.bigtable.admin.v2.Type.String.Encoding.IUtf8Raw, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Utf8Raw message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Utf8Raw + * @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.bigtable.admin.v2.Type.String.Encoding.Utf8Raw; + + /** + * Decodes an Utf8Raw message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Utf8Raw + * @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.bigtable.admin.v2.Type.String.Encoding.Utf8Raw; + + /** + * Verifies an Utf8Raw 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 an Utf8Raw message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Utf8Raw + */ + public static fromObject(object: { [k: string]: any }): google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw; + + /** + * Creates a plain object from an Utf8Raw message. Also converts values to other types if specified. + * @param message Utf8Raw + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Utf8Raw to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Utf8Raw + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + } + /** Properties of an Int64. */ interface IInt64 { diff --git a/protos/protos.js b/protos/protos.js index 952bb1a08..2cd5a56a6 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -29525,6 +29525,7 @@ * @memberof google.bigtable.admin.v2 * @interface IType * @property {google.bigtable.admin.v2.Type.IBytes|null} [bytesType] Type bytesType + * @property {google.bigtable.admin.v2.Type.IString|null} [stringType] Type stringType * @property {google.bigtable.admin.v2.Type.IInt64|null} [int64Type] Type int64Type * @property {google.bigtable.admin.v2.Type.IAggregate|null} [aggregateType] Type aggregateType */ @@ -29552,6 +29553,14 @@ */ Type.prototype.bytesType = null; + /** + * Type stringType. + * @member {google.bigtable.admin.v2.Type.IString|null|undefined} stringType + * @memberof google.bigtable.admin.v2.Type + * @instance + */ + Type.prototype.stringType = null; + /** * Type int64Type. * @member {google.bigtable.admin.v2.Type.IInt64|null|undefined} int64Type @@ -29573,12 +29582,12 @@ /** * Type kind. - * @member {"bytesType"|"int64Type"|"aggregateType"|undefined} kind + * @member {"bytesType"|"stringType"|"int64Type"|"aggregateType"|undefined} kind * @memberof google.bigtable.admin.v2.Type * @instance */ Object.defineProperty(Type.prototype, "kind", { - get: $util.oneOfGetter($oneOfFields = ["bytesType", "int64Type", "aggregateType"]), + get: $util.oneOfGetter($oneOfFields = ["bytesType", "stringType", "int64Type", "aggregateType"]), set: $util.oneOfSetter($oneOfFields) }); @@ -29608,6 +29617,8 @@ writer = $Writer.create(); if (message.bytesType != null && Object.hasOwnProperty.call(message, "bytesType")) $root.google.bigtable.admin.v2.Type.Bytes.encode(message.bytesType, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.stringType != null && Object.hasOwnProperty.call(message, "stringType")) + $root.google.bigtable.admin.v2.Type.String.encode(message.stringType, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.int64Type != null && Object.hasOwnProperty.call(message, "int64Type")) $root.google.bigtable.admin.v2.Type.Int64.encode(message.int64Type, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); if (message.aggregateType != null && Object.hasOwnProperty.call(message, "aggregateType")) @@ -29650,6 +29661,10 @@ message.bytesType = $root.google.bigtable.admin.v2.Type.Bytes.decode(reader, reader.uint32()); break; } + case 2: { + message.stringType = $root.google.bigtable.admin.v2.Type.String.decode(reader, reader.uint32()); + break; + } case 5: { message.int64Type = $root.google.bigtable.admin.v2.Type.Int64.decode(reader, reader.uint32()); break; @@ -29702,6 +29717,16 @@ return "bytesType." + error; } } + if (message.stringType != null && message.hasOwnProperty("stringType")) { + if (properties.kind === 1) + return "kind: multiple values"; + properties.kind = 1; + { + var error = $root.google.bigtable.admin.v2.Type.String.verify(message.stringType); + if (error) + return "stringType." + error; + } + } if (message.int64Type != null && message.hasOwnProperty("int64Type")) { if (properties.kind === 1) return "kind: multiple values"; @@ -29742,6 +29767,11 @@ throw TypeError(".google.bigtable.admin.v2.Type.bytesType: object expected"); message.bytesType = $root.google.bigtable.admin.v2.Type.Bytes.fromObject(object.bytesType); } + if (object.stringType != null) { + if (typeof object.stringType !== "object") + throw TypeError(".google.bigtable.admin.v2.Type.stringType: object expected"); + message.stringType = $root.google.bigtable.admin.v2.Type.String.fromObject(object.stringType); + } if (object.int64Type != null) { if (typeof object.int64Type !== "object") throw TypeError(".google.bigtable.admin.v2.Type.int64Type: object expected"); @@ -29773,6 +29803,11 @@ if (options.oneofs) object.kind = "bytesType"; } + if (message.stringType != null && message.hasOwnProperty("stringType")) { + object.stringType = $root.google.bigtable.admin.v2.Type.String.toObject(message.stringType, options); + if (options.oneofs) + object.kind = "stringType"; + } if (message.int64Type != null && message.hasOwnProperty("int64Type")) { object.int64Type = $root.google.bigtable.admin.v2.Type.Int64.toObject(message.int64Type, options); if (options.oneofs) @@ -30422,6 +30457,616 @@ return Bytes; })(); + Type.String = (function() { + + /** + * Properties of a String. + * @memberof google.bigtable.admin.v2.Type + * @interface IString + * @property {google.bigtable.admin.v2.Type.String.IEncoding|null} [encoding] String encoding + */ + + /** + * Constructs a new String. + * @memberof google.bigtable.admin.v2.Type + * @classdesc Represents a String. + * @implements IString + * @constructor + * @param {google.bigtable.admin.v2.Type.IString=} [properties] Properties to set + */ + function String(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]]; + } + + /** + * String encoding. + * @member {google.bigtable.admin.v2.Type.String.IEncoding|null|undefined} encoding + * @memberof google.bigtable.admin.v2.Type.String + * @instance + */ + String.prototype.encoding = null; + + /** + * Creates a new String instance using the specified properties. + * @function create + * @memberof google.bigtable.admin.v2.Type.String + * @static + * @param {google.bigtable.admin.v2.Type.IString=} [properties] Properties to set + * @returns {google.bigtable.admin.v2.Type.String} String instance + */ + String.create = function create(properties) { + return new String(properties); + }; + + /** + * Encodes the specified String message. Does not implicitly {@link google.bigtable.admin.v2.Type.String.verify|verify} messages. + * @function encode + * @memberof google.bigtable.admin.v2.Type.String + * @static + * @param {google.bigtable.admin.v2.Type.IString} message String message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + String.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.encoding != null && Object.hasOwnProperty.call(message, "encoding")) + $root.google.bigtable.admin.v2.Type.String.Encoding.encode(message.encoding, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified String message, length delimited. Does not implicitly {@link google.bigtable.admin.v2.Type.String.verify|verify} messages. + * @function encodeDelimited + * @memberof google.bigtable.admin.v2.Type.String + * @static + * @param {google.bigtable.admin.v2.Type.IString} message String message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + String.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a String message from the specified reader or buffer. + * @function decode + * @memberof google.bigtable.admin.v2.Type.String + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.bigtable.admin.v2.Type.String} String + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + String.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.bigtable.admin.v2.Type.String(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.encoding = $root.google.bigtable.admin.v2.Type.String.Encoding.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a String message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.bigtable.admin.v2.Type.String + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.bigtable.admin.v2.Type.String} String + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + String.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a String message. + * @function verify + * @memberof google.bigtable.admin.v2.Type.String + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + String.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.encoding != null && message.hasOwnProperty("encoding")) { + var error = $root.google.bigtable.admin.v2.Type.String.Encoding.verify(message.encoding); + if (error) + return "encoding." + error; + } + return null; + }; + + /** + * Creates a String message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.bigtable.admin.v2.Type.String + * @static + * @param {Object.} object Plain object + * @returns {google.bigtable.admin.v2.Type.String} String + */ + String.fromObject = function fromObject(object) { + if (object instanceof $root.google.bigtable.admin.v2.Type.String) + return object; + var message = new $root.google.bigtable.admin.v2.Type.String(); + if (object.encoding != null) { + if (typeof object.encoding !== "object") + throw TypeError(".google.bigtable.admin.v2.Type.String.encoding: object expected"); + message.encoding = $root.google.bigtable.admin.v2.Type.String.Encoding.fromObject(object.encoding); + } + return message; + }; + + /** + * Creates a plain object from a String message. Also converts values to other types if specified. + * @function toObject + * @memberof google.bigtable.admin.v2.Type.String + * @static + * @param {google.bigtable.admin.v2.Type.String} message String + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + String.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.encoding = null; + if (message.encoding != null && message.hasOwnProperty("encoding")) + object.encoding = $root.google.bigtable.admin.v2.Type.String.Encoding.toObject(message.encoding, options); + return object; + }; + + /** + * Converts this String to JSON. + * @function toJSON + * @memberof google.bigtable.admin.v2.Type.String + * @instance + * @returns {Object.} JSON object + */ + String.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for String + * @function getTypeUrl + * @memberof google.bigtable.admin.v2.Type.String + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + String.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.bigtable.admin.v2.Type.String"; + }; + + String.Encoding = (function() { + + /** + * Properties of an Encoding. + * @memberof google.bigtable.admin.v2.Type.String + * @interface IEncoding + * @property {google.bigtable.admin.v2.Type.String.Encoding.IUtf8Raw|null} [utf8Raw] Encoding utf8Raw + */ + + /** + * Constructs a new Encoding. + * @memberof google.bigtable.admin.v2.Type.String + * @classdesc Represents an Encoding. + * @implements IEncoding + * @constructor + * @param {google.bigtable.admin.v2.Type.String.IEncoding=} [properties] Properties to set + */ + function Encoding(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]]; + } + + /** + * Encoding utf8Raw. + * @member {google.bigtable.admin.v2.Type.String.Encoding.IUtf8Raw|null|undefined} utf8Raw + * @memberof google.bigtable.admin.v2.Type.String.Encoding + * @instance + */ + Encoding.prototype.utf8Raw = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Encoding encoding. + * @member {"utf8Raw"|undefined} encoding + * @memberof google.bigtable.admin.v2.Type.String.Encoding + * @instance + */ + Object.defineProperty(Encoding.prototype, "encoding", { + get: $util.oneOfGetter($oneOfFields = ["utf8Raw"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Encoding instance using the specified properties. + * @function create + * @memberof google.bigtable.admin.v2.Type.String.Encoding + * @static + * @param {google.bigtable.admin.v2.Type.String.IEncoding=} [properties] Properties to set + * @returns {google.bigtable.admin.v2.Type.String.Encoding} Encoding instance + */ + Encoding.create = function create(properties) { + return new Encoding(properties); + }; + + /** + * Encodes the specified Encoding message. Does not implicitly {@link google.bigtable.admin.v2.Type.String.Encoding.verify|verify} messages. + * @function encode + * @memberof google.bigtable.admin.v2.Type.String.Encoding + * @static + * @param {google.bigtable.admin.v2.Type.String.IEncoding} message Encoding message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Encoding.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.utf8Raw != null && Object.hasOwnProperty.call(message, "utf8Raw")) + $root.google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw.encode(message.utf8Raw, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Encoding message, length delimited. Does not implicitly {@link google.bigtable.admin.v2.Type.String.Encoding.verify|verify} messages. + * @function encodeDelimited + * @memberof google.bigtable.admin.v2.Type.String.Encoding + * @static + * @param {google.bigtable.admin.v2.Type.String.IEncoding} message Encoding message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Encoding.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Encoding message from the specified reader or buffer. + * @function decode + * @memberof google.bigtable.admin.v2.Type.String.Encoding + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.bigtable.admin.v2.Type.String.Encoding} Encoding + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Encoding.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.bigtable.admin.v2.Type.String.Encoding(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.utf8Raw = $root.google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Encoding message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.bigtable.admin.v2.Type.String.Encoding + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.bigtable.admin.v2.Type.String.Encoding} Encoding + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Encoding.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Encoding message. + * @function verify + * @memberof google.bigtable.admin.v2.Type.String.Encoding + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Encoding.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.utf8Raw != null && message.hasOwnProperty("utf8Raw")) { + properties.encoding = 1; + { + var error = $root.google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw.verify(message.utf8Raw); + if (error) + return "utf8Raw." + error; + } + } + return null; + }; + + /** + * Creates an Encoding message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.bigtable.admin.v2.Type.String.Encoding + * @static + * @param {Object.} object Plain object + * @returns {google.bigtable.admin.v2.Type.String.Encoding} Encoding + */ + Encoding.fromObject = function fromObject(object) { + if (object instanceof $root.google.bigtable.admin.v2.Type.String.Encoding) + return object; + var message = new $root.google.bigtable.admin.v2.Type.String.Encoding(); + if (object.utf8Raw != null) { + if (typeof object.utf8Raw !== "object") + throw TypeError(".google.bigtable.admin.v2.Type.String.Encoding.utf8Raw: object expected"); + message.utf8Raw = $root.google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw.fromObject(object.utf8Raw); + } + return message; + }; + + /** + * Creates a plain object from an Encoding message. Also converts values to other types if specified. + * @function toObject + * @memberof google.bigtable.admin.v2.Type.String.Encoding + * @static + * @param {google.bigtable.admin.v2.Type.String.Encoding} message Encoding + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Encoding.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.utf8Raw != null && message.hasOwnProperty("utf8Raw")) { + object.utf8Raw = $root.google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw.toObject(message.utf8Raw, options); + if (options.oneofs) + object.encoding = "utf8Raw"; + } + return object; + }; + + /** + * Converts this Encoding to JSON. + * @function toJSON + * @memberof google.bigtable.admin.v2.Type.String.Encoding + * @instance + * @returns {Object.} JSON object + */ + Encoding.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Encoding + * @function getTypeUrl + * @memberof google.bigtable.admin.v2.Type.String.Encoding + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Encoding.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.bigtable.admin.v2.Type.String.Encoding"; + }; + + Encoding.Utf8Raw = (function() { + + /** + * Properties of an Utf8Raw. + * @memberof google.bigtable.admin.v2.Type.String.Encoding + * @interface IUtf8Raw + */ + + /** + * Constructs a new Utf8Raw. + * @memberof google.bigtable.admin.v2.Type.String.Encoding + * @classdesc Represents an Utf8Raw. + * @implements IUtf8Raw + * @constructor + * @param {google.bigtable.admin.v2.Type.String.Encoding.IUtf8Raw=} [properties] Properties to set + */ + function Utf8Raw(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]]; + } + + /** + * Creates a new Utf8Raw instance using the specified properties. + * @function create + * @memberof google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw + * @static + * @param {google.bigtable.admin.v2.Type.String.Encoding.IUtf8Raw=} [properties] Properties to set + * @returns {google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw} Utf8Raw instance + */ + Utf8Raw.create = function create(properties) { + return new Utf8Raw(properties); + }; + + /** + * Encodes the specified Utf8Raw message. Does not implicitly {@link google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw.verify|verify} messages. + * @function encode + * @memberof google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw + * @static + * @param {google.bigtable.admin.v2.Type.String.Encoding.IUtf8Raw} message Utf8Raw message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Utf8Raw.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified Utf8Raw message, length delimited. Does not implicitly {@link google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw.verify|verify} messages. + * @function encodeDelimited + * @memberof google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw + * @static + * @param {google.bigtable.admin.v2.Type.String.Encoding.IUtf8Raw} message Utf8Raw message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Utf8Raw.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Utf8Raw message from the specified reader or buffer. + * @function decode + * @memberof google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw} Utf8Raw + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Utf8Raw.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.bigtable.admin.v2.Type.String.Encoding.Utf8Raw(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Utf8Raw message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw} Utf8Raw + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Utf8Raw.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Utf8Raw message. + * @function verify + * @memberof google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Utf8Raw.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates an Utf8Raw message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw + * @static + * @param {Object.} object Plain object + * @returns {google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw} Utf8Raw + */ + Utf8Raw.fromObject = function fromObject(object) { + if (object instanceof $root.google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw) + return object; + return new $root.google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw(); + }; + + /** + * Creates a plain object from an Utf8Raw message. Also converts values to other types if specified. + * @function toObject + * @memberof google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw + * @static + * @param {google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw} message Utf8Raw + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Utf8Raw.toObject = function toObject() { + return {}; + }; + + /** + * Converts this Utf8Raw to JSON. + * @function toJSON + * @memberof google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw + * @instance + * @returns {Object.} JSON object + */ + Utf8Raw.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Utf8Raw + * @function getTypeUrl + * @memberof google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Utf8Raw.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw"; + }; + + return Utf8Raw; + })(); + + return Encoding; + })(); + + return String; + })(); + Type.Int64 = (function() { /** diff --git a/protos/protos.json b/protos/protos.json index d0b03646f..13a104bf7 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -3435,6 +3435,7 @@ "kind": { "oneof": [ "bytesType", + "stringType", "int64Type", "aggregateType" ] @@ -3445,6 +3446,10 @@ "type": "Bytes", "id": 1 }, + "stringType": { + "type": "String", + "id": 2 + }, "int64Type": { "type": "Int64", "id": 5 @@ -3485,6 +3490,36 @@ } } }, + "String": { + "fields": { + "encoding": { + "type": "Encoding", + "id": 1 + } + }, + "nested": { + "Encoding": { + "oneofs": { + "encoding": { + "oneof": [ + "utf8Raw" + ] + } + }, + "fields": { + "utf8Raw": { + "type": "Utf8Raw", + "id": 1 + } + }, + "nested": { + "Utf8Raw": { + "fields": {} + } + } + } + } + }, "Int64": { "fields": { "encoding": { diff --git a/src/v2/bigtable_client.ts b/src/v2/bigtable_client.ts index b0e95910a..e437b9427 100644 --- a/src/v2/bigtable_client.ts +++ b/src/v2/bigtable_client.ts @@ -214,28 +214,28 @@ export class BigtableClient { readRows: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, - /* gaxStreamingRetries: */ false + !!opts.gaxServerStreamingRetries ), sampleRowKeys: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, - /* gaxStreamingRetries: */ false + !!opts.gaxServerStreamingRetries ), mutateRows: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, - /* gaxStreamingRetries: */ false + !!opts.gaxServerStreamingRetries ), generateInitialChangeStreamPartitions: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, - /* gaxStreamingRetries: */ false + !!opts.gaxServerStreamingRetries ), readChangeStream: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, - /* gaxStreamingRetries: */ false + !!opts.gaxServerStreamingRetries ), }; diff --git a/test/gapic_bigtable_v2.ts b/test/gapic_bigtable_v2.ts index a93014850..4595e4b3d 100644 --- a/test/gapic_bigtable_v2.ts +++ b/test/gapic_bigtable_v2.ts @@ -797,6 +797,47 @@ describe('v2.BigtableClient', () => { assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); + it('invokes readRows without error and gaxServerStreamingRetries enabled', async () => { + const client = new bigtableModule.v2.BigtableClient({ + gaxServerStreamingRetries: true, + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.v2.ReadRowsRequest() + ); + // path template: {authorized_view_name=projects/*/instances/*/tables/*/authorizedViews/*} + request.authorizedViewName = + 'projects/value/instances/value/tables/value/authorizedViews/value'; + const expectedHeaderRequestParams = + 'authorized_view_name=projects%2Fvalue%2Finstances%2Fvalue%2Ftables%2Fvalue%2FauthorizedViews%2Fvalue'; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.v2.ReadRowsResponse() + ); + client.innerApiCalls.readRows = stubServerStreamingCall(expectedResponse); + const stream = client.readRows(request); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.bigtable.v2.ReadRowsResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.readRows as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readRows as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + it('invokes readRows with error', async () => { const client = new bigtableModule.v2.BigtableClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, @@ -869,6 +910,12 @@ describe('v2.BigtableClient', () => { }); await assert.rejects(promise, expectedError); }); + it('should create a client with gaxServerStreamingRetries enabled', () => { + const client = new bigtableModule.v2.BigtableClient({ + gaxServerStreamingRetries: true, + }); + assert(client); + }); }); describe('sampleRowKeys', () => { @@ -915,6 +962,48 @@ describe('v2.BigtableClient', () => { assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); + it('invokes sampleRowKeys without error and gaxServerStreamingRetries enabled', async () => { + const client = new bigtableModule.v2.BigtableClient({ + gaxServerStreamingRetries: true, + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.v2.SampleRowKeysRequest() + ); + // path template: {authorized_view_name=projects/*/instances/*/tables/*/authorizedViews/*} + request.authorizedViewName = + 'projects/value/instances/value/tables/value/authorizedViews/value'; + const expectedHeaderRequestParams = + 'authorized_view_name=projects%2Fvalue%2Finstances%2Fvalue%2Ftables%2Fvalue%2FauthorizedViews%2Fvalue'; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.v2.SampleRowKeysResponse() + ); + client.innerApiCalls.sampleRowKeys = + stubServerStreamingCall(expectedResponse); + const stream = client.sampleRowKeys(request); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.bigtable.v2.SampleRowKeysResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.sampleRowKeys as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.sampleRowKeys as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + it('invokes sampleRowKeys with error', async () => { const client = new bigtableModule.v2.BigtableClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, @@ -987,6 +1076,12 @@ describe('v2.BigtableClient', () => { }); await assert.rejects(promise, expectedError); }); + it('should create a client with gaxServerStreamingRetries enabled', () => { + const client = new bigtableModule.v2.BigtableClient({ + gaxServerStreamingRetries: true, + }); + assert(client); + }); }); describe('mutateRows', () => { @@ -1033,6 +1128,48 @@ describe('v2.BigtableClient', () => { assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); + it('invokes mutateRows without error and gaxServerStreamingRetries enabled', async () => { + const client = new bigtableModule.v2.BigtableClient({ + gaxServerStreamingRetries: true, + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.v2.MutateRowsRequest() + ); + // path template: {authorized_view_name=projects/*/instances/*/tables/*/authorizedViews/*} + request.authorizedViewName = + 'projects/value/instances/value/tables/value/authorizedViews/value'; + const expectedHeaderRequestParams = + 'authorized_view_name=projects%2Fvalue%2Finstances%2Fvalue%2Ftables%2Fvalue%2FauthorizedViews%2Fvalue'; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.v2.MutateRowsResponse() + ); + client.innerApiCalls.mutateRows = + stubServerStreamingCall(expectedResponse); + const stream = client.mutateRows(request); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.bigtable.v2.MutateRowsResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.mutateRows as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.mutateRows as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + it('invokes mutateRows with error', async () => { const client = new bigtableModule.v2.BigtableClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, @@ -1105,6 +1242,12 @@ describe('v2.BigtableClient', () => { }); await assert.rejects(promise, expectedError); }); + it('should create a client with gaxServerStreamingRetries enabled', () => { + const client = new bigtableModule.v2.BigtableClient({ + gaxServerStreamingRetries: true, + }); + assert(client); + }); }); describe('generateInitialChangeStreamPartitions', () => { @@ -1154,6 +1297,51 @@ describe('v2.BigtableClient', () => { assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); + it('invokes generateInitialChangeStreamPartitions without error and gaxServerStreamingRetries enabled', async () => { + const client = new bigtableModule.v2.BigtableClient({ + gaxServerStreamingRetries: true, + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.v2.GenerateInitialChangeStreamPartitionsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.bigtable.v2.GenerateInitialChangeStreamPartitionsRequest', + ['tableName'] + ); + request.tableName = defaultValue1; + const expectedHeaderRequestParams = `table_name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.v2.GenerateInitialChangeStreamPartitionsResponse() + ); + client.innerApiCalls.generateInitialChangeStreamPartitions = + stubServerStreamingCall(expectedResponse); + const stream = client.generateInitialChangeStreamPartitions(request); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.bigtable.v2.GenerateInitialChangeStreamPartitionsResponse + ) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateInitialChangeStreamPartitions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateInitialChangeStreamPartitions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + it('invokes generateInitialChangeStreamPartitions with error', async () => { const client = new bigtableModule.v2.BigtableClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, @@ -1231,6 +1419,12 @@ describe('v2.BigtableClient', () => { }); await assert.rejects(promise, expectedError); }); + it('should create a client with gaxServerStreamingRetries enabled', () => { + const client = new bigtableModule.v2.BigtableClient({ + gaxServerStreamingRetries: true, + }); + assert(client); + }); }); describe('readChangeStream', () => { @@ -1278,6 +1472,49 @@ describe('v2.BigtableClient', () => { assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); + it('invokes readChangeStream without error and gaxServerStreamingRetries enabled', async () => { + const client = new bigtableModule.v2.BigtableClient({ + gaxServerStreamingRetries: true, + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.v2.ReadChangeStreamRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.bigtable.v2.ReadChangeStreamRequest', + ['tableName'] + ); + request.tableName = defaultValue1; + const expectedHeaderRequestParams = `table_name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.v2.ReadChangeStreamResponse() + ); + client.innerApiCalls.readChangeStream = + stubServerStreamingCall(expectedResponse); + const stream = client.readChangeStream(request); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.bigtable.v2.ReadChangeStreamResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.readChangeStream as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readChangeStream as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + it('invokes readChangeStream with error', async () => { const client = new bigtableModule.v2.BigtableClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, @@ -1353,6 +1590,12 @@ describe('v2.BigtableClient', () => { }); await assert.rejects(promise, expectedError); }); + it('should create a client with gaxServerStreamingRetries enabled', () => { + const client = new bigtableModule.v2.BigtableClient({ + gaxServerStreamingRetries: true, + }); + assert(client); + }); }); describe('Path templates', () => {