From 29d38a17663adcd02252a5b6c778d053208de12f Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 15:17:35 -0400 Subject: [PATCH] feat: add BigQuery configuration for subscriptions (#1563) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add BigQuery configuration for subscriptions PiperOrigin-RevId: 449031535 Source-Link: https://github.com/googleapis/googleapis/commit/feec34dfac930eb0ab8c3e72ff5794c3f4c5924d Source-Link: https://github.com/googleapis/googleapis-gen/commit/89664e9708c19d532c63f7a16fd79cb631d87aa1 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODk2NjRlOTcwOGMxOWQ1MzJjNjNmN2ExNmZkNzljYjYzMWQ4N2FhMSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- protos/google/pubsub/v1/pubsub.proto | 78 ++++- protos/protos.d.ts | 148 ++++++++++ protos/protos.js | 407 +++++++++++++++++++++++++++ protos/protos.json | 58 ++++ src/v1/subscriber_client.ts | 13 +- 5 files changed, 699 insertions(+), 5 deletions(-) diff --git a/protos/google/pubsub/v1/pubsub.proto b/protos/google/pubsub/v1/pubsub.proto index 172801ba3..5ab209bbd 100644 --- a/protos/google/pubsub/v1/pubsub.proto +++ b/protos/google/pubsub/v1/pubsub.proto @@ -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. @@ -642,6 +642,20 @@ message Subscription { pattern: "projects/{project}/subscriptions/{subscription}" }; + // Possible states for a subscription. + enum State { + // Default value. This value is unused. + STATE_UNSPECIFIED = 0; + + // The subscription can actively receive messages + ACTIVE = 1; + + // The subscription cannot receive messages because of an error with the + // resource to which it pushes messages. See the more detailed error state + // in the corresponding configuration. + RESOURCE_ERROR = 2; + } + // Required. The name of the subscription. It must have the format // `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must // start with a letter, and contain only letters (`[A-Za-z]`), numbers @@ -659,10 +673,17 @@ message Subscription { ]; // If push delivery is used with this subscription, this field is - // used to configure it. An empty `pushConfig` signifies that the subscriber - // will pull and ack messages using API methods. + // used to configure it. Either `pushConfig` or `bigQueryConfig` can be set, + // but not both. If both are empty, then the subscriber will pull and ack + // messages using API methods. PushConfig push_config = 4; + // If delivery to BigQuery is used with this subscription, this field is + // used to configure it. Either `pushConfig` or `bigQueryConfig` can be set, + // but not both. If both are empty, then the subscriber will pull and ack + // messages using API methods. + BigQueryConfig bigquery_config = 18; + // The approximate amount of time (on a best-effort basis) Pub/Sub waits for // the subscriber to acknowledge receipt before resending the message. In the // interval after the message is delivered and before it is acknowledged, it @@ -773,6 +794,10 @@ message Subscription { // in responses from the server; it is ignored if it is set in any requests. google.protobuf.Duration topic_message_retention_duration = 17 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. An output-only field indicating whether or not the subscription can receive + // messages. + State state = 19 [(google.api.field_behavior) = OUTPUT_ONLY]; } // A policy that specifies how Cloud Pub/Sub retries message delivery. @@ -902,6 +927,53 @@ message PushConfig { } } +// Configuration for a BigQuery subscription. +message BigQueryConfig { + // Possible states for a BigQuery subscription. + enum State { + // Default value. This value is unused. + STATE_UNSPECIFIED = 0; + + // The subscription can actively send messages to BigQuery + ACTIVE = 1; + + // Cannot write to the BigQuery table because of permission denied errors. + PERMISSION_DENIED = 2; + + // Cannot write to the BigQuery table because it does not exist. + NOT_FOUND = 3; + + // Cannot write to the BigQuery table due to a schema mismatch. + SCHEMA_MISMATCH = 4; + } + + // The name of the table to which to write data, of the form + // {projectId}:{datasetId}.{tableId} + string table = 1; + + // When true, use the topic's schema as the columns to write to in BigQuery, + // if it exists. + bool use_topic_schema = 2; + + // When true, write the subscription name, message_id, publish_time, + // attributes, and ordering_key to additional columns in the table. The + // subscription name, message_id, and publish_time fields are put in their own + // columns while all other message properties (other than data) are written to + // a JSON object in the attributes column. + bool write_metadata = 3; + + // When true and use_topic_schema is true, any fields that are a part of the + // topic schema that are not part of the BigQuery table schema are dropped + // when writing to BigQuery. Otherwise, the schemas must be kept in sync and + // any messages with extra fields are not written and remain in the + // subscription's backlog. + bool drop_unknown_fields = 4; + + // Output only. An output-only field that indicates whether or not the subscription can + // receive messages. + State state = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + // A message and its corresponding acknowledgment ID. message ReceivedMessage { // This ID can be used to acknowledge the received message. diff --git a/protos/protos.d.ts b/protos/protos.d.ts index 92e36484f..b5960417a 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -2264,6 +2264,9 @@ export namespace google { /** Subscription pushConfig */ pushConfig?: (google.pubsub.v1.IPushConfig|null); + /** Subscription bigqueryConfig */ + bigqueryConfig?: (google.pubsub.v1.IBigQueryConfig|null); + /** Subscription ackDeadlineSeconds */ ackDeadlineSeconds?: (number|null); @@ -2299,6 +2302,9 @@ export namespace google { /** Subscription topicMessageRetentionDuration */ topicMessageRetentionDuration?: (google.protobuf.IDuration|null); + + /** Subscription state */ + state?: (google.pubsub.v1.Subscription.State|keyof typeof google.pubsub.v1.Subscription.State|null); } /** Represents a Subscription. */ @@ -2319,6 +2325,9 @@ export namespace google { /** Subscription pushConfig. */ public pushConfig?: (google.pubsub.v1.IPushConfig|null); + /** Subscription bigqueryConfig. */ + public bigqueryConfig?: (google.pubsub.v1.IBigQueryConfig|null); + /** Subscription ackDeadlineSeconds. */ public ackDeadlineSeconds: number; @@ -2355,6 +2364,9 @@ export namespace google { /** Subscription topicMessageRetentionDuration. */ public topicMessageRetentionDuration?: (google.protobuf.IDuration|null); + /** Subscription state. */ + public state: (google.pubsub.v1.Subscription.State|keyof typeof google.pubsub.v1.Subscription.State); + /** * Creates a new Subscription instance using the specified properties. * @param [properties] Properties to set @@ -2426,6 +2438,16 @@ export namespace google { public toJSON(): { [k: string]: any }; } + namespace Subscription { + + /** State enum. */ + enum State { + STATE_UNSPECIFIED = 0, + ACTIVE = 1, + RESOURCE_ERROR = 2 + } + } + /** Properties of a RetryPolicy. */ interface IRetryPolicy { @@ -2912,6 +2934,132 @@ export namespace google { } } + /** Properties of a BigQueryConfig. */ + interface IBigQueryConfig { + + /** BigQueryConfig table */ + table?: (string|null); + + /** BigQueryConfig useTopicSchema */ + useTopicSchema?: (boolean|null); + + /** BigQueryConfig writeMetadata */ + writeMetadata?: (boolean|null); + + /** BigQueryConfig dropUnknownFields */ + dropUnknownFields?: (boolean|null); + + /** BigQueryConfig state */ + state?: (google.pubsub.v1.BigQueryConfig.State|keyof typeof google.pubsub.v1.BigQueryConfig.State|null); + } + + /** Represents a BigQueryConfig. */ + class BigQueryConfig implements IBigQueryConfig { + + /** + * Constructs a new BigQueryConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.IBigQueryConfig); + + /** BigQueryConfig table. */ + public table: string; + + /** BigQueryConfig useTopicSchema. */ + public useTopicSchema: boolean; + + /** BigQueryConfig writeMetadata. */ + public writeMetadata: boolean; + + /** BigQueryConfig dropUnknownFields. */ + public dropUnknownFields: boolean; + + /** BigQueryConfig state. */ + public state: (google.pubsub.v1.BigQueryConfig.State|keyof typeof google.pubsub.v1.BigQueryConfig.State); + + /** + * Creates a new BigQueryConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns BigQueryConfig instance + */ + public static create(properties?: google.pubsub.v1.IBigQueryConfig): google.pubsub.v1.BigQueryConfig; + + /** + * Encodes the specified BigQueryConfig message. Does not implicitly {@link google.pubsub.v1.BigQueryConfig.verify|verify} messages. + * @param message BigQueryConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.IBigQueryConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BigQueryConfig message, length delimited. Does not implicitly {@link google.pubsub.v1.BigQueryConfig.verify|verify} messages. + * @param message BigQueryConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.IBigQueryConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BigQueryConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BigQueryConfig + * @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.pubsub.v1.BigQueryConfig; + + /** + * Decodes a BigQueryConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BigQueryConfig + * @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.pubsub.v1.BigQueryConfig; + + /** + * Verifies a BigQueryConfig 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 BigQueryConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BigQueryConfig + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.BigQueryConfig; + + /** + * Creates a plain object from a BigQueryConfig message. Also converts values to other types if specified. + * @param message BigQueryConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.BigQueryConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BigQueryConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace BigQueryConfig { + + /** State enum. */ + enum State { + STATE_UNSPECIFIED = 0, + ACTIVE = 1, + PERMISSION_DENIED = 2, + NOT_FOUND = 3, + SCHEMA_MISMATCH = 4 + } + } + /** Properties of a ReceivedMessage. */ interface IReceivedMessage { diff --git a/protos/protos.js b/protos/protos.js index e93dbbbd6..e6e3b2070 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -4843,6 +4843,7 @@ * @property {string|null} [name] Subscription name * @property {string|null} [topic] Subscription topic * @property {google.pubsub.v1.IPushConfig|null} [pushConfig] Subscription pushConfig + * @property {google.pubsub.v1.IBigQueryConfig|null} [bigqueryConfig] Subscription bigqueryConfig * @property {number|null} [ackDeadlineSeconds] Subscription ackDeadlineSeconds * @property {boolean|null} [retainAckedMessages] Subscription retainAckedMessages * @property {google.protobuf.IDuration|null} [messageRetentionDuration] Subscription messageRetentionDuration @@ -4855,6 +4856,7 @@ * @property {boolean|null} [detached] Subscription detached * @property {boolean|null} [enableExactlyOnceDelivery] Subscription enableExactlyOnceDelivery * @property {google.protobuf.IDuration|null} [topicMessageRetentionDuration] Subscription topicMessageRetentionDuration + * @property {google.pubsub.v1.Subscription.State|null} [state] Subscription state */ /** @@ -4897,6 +4899,14 @@ */ Subscription.prototype.pushConfig = null; + /** + * Subscription bigqueryConfig. + * @member {google.pubsub.v1.IBigQueryConfig|null|undefined} bigqueryConfig + * @memberof google.pubsub.v1.Subscription + * @instance + */ + Subscription.prototype.bigqueryConfig = null; + /** * Subscription ackDeadlineSeconds. * @member {number} ackDeadlineSeconds @@ -4993,6 +5003,14 @@ */ Subscription.prototype.topicMessageRetentionDuration = null; + /** + * Subscription state. + * @member {google.pubsub.v1.Subscription.State} state + * @memberof google.pubsub.v1.Subscription + * @instance + */ + Subscription.prototype.state = 0; + /** * Creates a new Subscription instance using the specified properties. * @function create @@ -5048,6 +5066,10 @@ writer.uint32(/* id 16, wireType 0 =*/128).bool(message.enableExactlyOnceDelivery); if (message.topicMessageRetentionDuration != null && Object.hasOwnProperty.call(message, "topicMessageRetentionDuration")) $root.google.protobuf.Duration.encode(message.topicMessageRetentionDuration, writer.uint32(/* id 17, wireType 2 =*/138).fork()).ldelim(); + if (message.bigqueryConfig != null && Object.hasOwnProperty.call(message, "bigqueryConfig")) + $root.google.pubsub.v1.BigQueryConfig.encode(message.bigqueryConfig, writer.uint32(/* id 18, wireType 2 =*/146).fork()).ldelim(); + if (message.state != null && Object.hasOwnProperty.call(message, "state")) + writer.uint32(/* id 19, wireType 0 =*/152).int32(message.state); return writer; }; @@ -5091,6 +5113,9 @@ case 4: message.pushConfig = $root.google.pubsub.v1.PushConfig.decode(reader, reader.uint32()); break; + case 18: + message.bigqueryConfig = $root.google.pubsub.v1.BigQueryConfig.decode(reader, reader.uint32()); + break; case 5: message.ackDeadlineSeconds = reader.int32(); break; @@ -5146,6 +5171,9 @@ case 17: message.topicMessageRetentionDuration = $root.google.protobuf.Duration.decode(reader, reader.uint32()); break; + case 19: + message.state = reader.int32(); + break; default: reader.skipType(tag & 7); break; @@ -5192,6 +5220,11 @@ if (error) return "pushConfig." + error; } + if (message.bigqueryConfig != null && message.hasOwnProperty("bigqueryConfig")) { + var error = $root.google.pubsub.v1.BigQueryConfig.verify(message.bigqueryConfig); + if (error) + return "bigqueryConfig." + error; + } if (message.ackDeadlineSeconds != null && message.hasOwnProperty("ackDeadlineSeconds")) if (!$util.isInteger(message.ackDeadlineSeconds)) return "ackDeadlineSeconds: integer expected"; @@ -5243,6 +5276,15 @@ if (error) return "topicMessageRetentionDuration." + error; } + if (message.state != null && message.hasOwnProperty("state")) + switch (message.state) { + default: + return "state: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -5267,6 +5309,11 @@ throw TypeError(".google.pubsub.v1.Subscription.pushConfig: object expected"); message.pushConfig = $root.google.pubsub.v1.PushConfig.fromObject(object.pushConfig); } + if (object.bigqueryConfig != null) { + if (typeof object.bigqueryConfig !== "object") + throw TypeError(".google.pubsub.v1.Subscription.bigqueryConfig: object expected"); + message.bigqueryConfig = $root.google.pubsub.v1.BigQueryConfig.fromObject(object.bigqueryConfig); + } if (object.ackDeadlineSeconds != null) message.ackDeadlineSeconds = object.ackDeadlineSeconds | 0; if (object.retainAckedMessages != null) @@ -5311,6 +5358,20 @@ throw TypeError(".google.pubsub.v1.Subscription.topicMessageRetentionDuration: object expected"); message.topicMessageRetentionDuration = $root.google.protobuf.Duration.fromObject(object.topicMessageRetentionDuration); } + switch (object.state) { + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "ACTIVE": + case 1: + message.state = 1; + break; + case "RESOURCE_ERROR": + case 2: + message.state = 2; + break; + } return message; }; @@ -5344,6 +5405,8 @@ object.detached = false; object.enableExactlyOnceDelivery = false; object.topicMessageRetentionDuration = null; + object.bigqueryConfig = null; + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -5379,6 +5442,10 @@ object.enableExactlyOnceDelivery = message.enableExactlyOnceDelivery; if (message.topicMessageRetentionDuration != null && message.hasOwnProperty("topicMessageRetentionDuration")) object.topicMessageRetentionDuration = $root.google.protobuf.Duration.toObject(message.topicMessageRetentionDuration, options); + if (message.bigqueryConfig != null && message.hasOwnProperty("bigqueryConfig")) + object.bigqueryConfig = $root.google.pubsub.v1.BigQueryConfig.toObject(message.bigqueryConfig, options); + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.pubsub.v1.Subscription.State[message.state] : message.state; return object; }; @@ -5393,6 +5460,22 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * State enum. + * @name google.pubsub.v1.Subscription.State + * @enum {number} + * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value + * @property {number} ACTIVE=1 ACTIVE value + * @property {number} RESOURCE_ERROR=2 RESOURCE_ERROR value + */ + Subscription.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "ACTIVE"] = 1; + values[valuesById[2] = "RESOURCE_ERROR"] = 2; + return values; + })(); + return Subscription; })(); @@ -6520,6 +6603,330 @@ return PushConfig; })(); + v1.BigQueryConfig = (function() { + + /** + * Properties of a BigQueryConfig. + * @memberof google.pubsub.v1 + * @interface IBigQueryConfig + * @property {string|null} [table] BigQueryConfig table + * @property {boolean|null} [useTopicSchema] BigQueryConfig useTopicSchema + * @property {boolean|null} [writeMetadata] BigQueryConfig writeMetadata + * @property {boolean|null} [dropUnknownFields] BigQueryConfig dropUnknownFields + * @property {google.pubsub.v1.BigQueryConfig.State|null} [state] BigQueryConfig state + */ + + /** + * Constructs a new BigQueryConfig. + * @memberof google.pubsub.v1 + * @classdesc Represents a BigQueryConfig. + * @implements IBigQueryConfig + * @constructor + * @param {google.pubsub.v1.IBigQueryConfig=} [properties] Properties to set + */ + function BigQueryConfig(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]]; + } + + /** + * BigQueryConfig table. + * @member {string} table + * @memberof google.pubsub.v1.BigQueryConfig + * @instance + */ + BigQueryConfig.prototype.table = ""; + + /** + * BigQueryConfig useTopicSchema. + * @member {boolean} useTopicSchema + * @memberof google.pubsub.v1.BigQueryConfig + * @instance + */ + BigQueryConfig.prototype.useTopicSchema = false; + + /** + * BigQueryConfig writeMetadata. + * @member {boolean} writeMetadata + * @memberof google.pubsub.v1.BigQueryConfig + * @instance + */ + BigQueryConfig.prototype.writeMetadata = false; + + /** + * BigQueryConfig dropUnknownFields. + * @member {boolean} dropUnknownFields + * @memberof google.pubsub.v1.BigQueryConfig + * @instance + */ + BigQueryConfig.prototype.dropUnknownFields = false; + + /** + * BigQueryConfig state. + * @member {google.pubsub.v1.BigQueryConfig.State} state + * @memberof google.pubsub.v1.BigQueryConfig + * @instance + */ + BigQueryConfig.prototype.state = 0; + + /** + * Creates a new BigQueryConfig instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.BigQueryConfig + * @static + * @param {google.pubsub.v1.IBigQueryConfig=} [properties] Properties to set + * @returns {google.pubsub.v1.BigQueryConfig} BigQueryConfig instance + */ + BigQueryConfig.create = function create(properties) { + return new BigQueryConfig(properties); + }; + + /** + * Encodes the specified BigQueryConfig message. Does not implicitly {@link google.pubsub.v1.BigQueryConfig.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.BigQueryConfig + * @static + * @param {google.pubsub.v1.IBigQueryConfig} message BigQueryConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BigQueryConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.table != null && Object.hasOwnProperty.call(message, "table")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.table); + if (message.useTopicSchema != null && Object.hasOwnProperty.call(message, "useTopicSchema")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.useTopicSchema); + if (message.writeMetadata != null && Object.hasOwnProperty.call(message, "writeMetadata")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.writeMetadata); + if (message.dropUnknownFields != null && Object.hasOwnProperty.call(message, "dropUnknownFields")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.dropUnknownFields); + if (message.state != null && Object.hasOwnProperty.call(message, "state")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.state); + return writer; + }; + + /** + * Encodes the specified BigQueryConfig message, length delimited. Does not implicitly {@link google.pubsub.v1.BigQueryConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.BigQueryConfig + * @static + * @param {google.pubsub.v1.IBigQueryConfig} message BigQueryConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BigQueryConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BigQueryConfig message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.BigQueryConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.BigQueryConfig} BigQueryConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BigQueryConfig.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.pubsub.v1.BigQueryConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.table = reader.string(); + break; + case 2: + message.useTopicSchema = reader.bool(); + break; + case 3: + message.writeMetadata = reader.bool(); + break; + case 4: + message.dropUnknownFields = reader.bool(); + break; + case 5: + message.state = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BigQueryConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.BigQueryConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.BigQueryConfig} BigQueryConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BigQueryConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BigQueryConfig message. + * @function verify + * @memberof google.pubsub.v1.BigQueryConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BigQueryConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.table != null && message.hasOwnProperty("table")) + if (!$util.isString(message.table)) + return "table: string expected"; + if (message.useTopicSchema != null && message.hasOwnProperty("useTopicSchema")) + if (typeof message.useTopicSchema !== "boolean") + return "useTopicSchema: boolean expected"; + if (message.writeMetadata != null && message.hasOwnProperty("writeMetadata")) + if (typeof message.writeMetadata !== "boolean") + return "writeMetadata: boolean expected"; + if (message.dropUnknownFields != null && message.hasOwnProperty("dropUnknownFields")) + if (typeof message.dropUnknownFields !== "boolean") + return "dropUnknownFields: boolean expected"; + if (message.state != null && message.hasOwnProperty("state")) + switch (message.state) { + default: + return "state: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + return null; + }; + + /** + * Creates a BigQueryConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.BigQueryConfig + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.BigQueryConfig} BigQueryConfig + */ + BigQueryConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.BigQueryConfig) + return object; + var message = new $root.google.pubsub.v1.BigQueryConfig(); + if (object.table != null) + message.table = String(object.table); + if (object.useTopicSchema != null) + message.useTopicSchema = Boolean(object.useTopicSchema); + if (object.writeMetadata != null) + message.writeMetadata = Boolean(object.writeMetadata); + if (object.dropUnknownFields != null) + message.dropUnknownFields = Boolean(object.dropUnknownFields); + switch (object.state) { + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "ACTIVE": + case 1: + message.state = 1; + break; + case "PERMISSION_DENIED": + case 2: + message.state = 2; + break; + case "NOT_FOUND": + case 3: + message.state = 3; + break; + case "SCHEMA_MISMATCH": + case 4: + message.state = 4; + break; + } + return message; + }; + + /** + * Creates a plain object from a BigQueryConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.BigQueryConfig + * @static + * @param {google.pubsub.v1.BigQueryConfig} message BigQueryConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BigQueryConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.table = ""; + object.useTopicSchema = false; + object.writeMetadata = false; + object.dropUnknownFields = false; + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + } + if (message.table != null && message.hasOwnProperty("table")) + object.table = message.table; + if (message.useTopicSchema != null && message.hasOwnProperty("useTopicSchema")) + object.useTopicSchema = message.useTopicSchema; + if (message.writeMetadata != null && message.hasOwnProperty("writeMetadata")) + object.writeMetadata = message.writeMetadata; + if (message.dropUnknownFields != null && message.hasOwnProperty("dropUnknownFields")) + object.dropUnknownFields = message.dropUnknownFields; + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.pubsub.v1.BigQueryConfig.State[message.state] : message.state; + return object; + }; + + /** + * Converts this BigQueryConfig to JSON. + * @function toJSON + * @memberof google.pubsub.v1.BigQueryConfig + * @instance + * @returns {Object.} JSON object + */ + BigQueryConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * State enum. + * @name google.pubsub.v1.BigQueryConfig.State + * @enum {number} + * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value + * @property {number} ACTIVE=1 ACTIVE value + * @property {number} PERMISSION_DENIED=2 PERMISSION_DENIED value + * @property {number} NOT_FOUND=3 NOT_FOUND value + * @property {number} SCHEMA_MISMATCH=4 SCHEMA_MISMATCH value + */ + BigQueryConfig.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "ACTIVE"] = 1; + values[valuesById[2] = "PERMISSION_DENIED"] = 2; + values[valuesById[3] = "NOT_FOUND"] = 3; + values[valuesById[4] = "SCHEMA_MISMATCH"] = 4; + return values; + })(); + + return BigQueryConfig; + })(); + v1.ReceivedMessage = (function() { /** diff --git a/protos/protos.json b/protos/protos.json index dc897e5af..1668561e9 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -780,6 +780,10 @@ "type": "PushConfig", "id": 4 }, + "bigqueryConfig": { + "type": "BigQueryConfig", + "id": 18 + }, "ackDeadlineSeconds": { "type": "int32", "id": 5 @@ -831,6 +835,22 @@ "options": { "(google.api.field_behavior)": "OUTPUT_ONLY" } + }, + "state": { + "type": "State", + "id": 19, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + }, + "nested": { + "State": { + "values": { + "STATE_UNSPECIFIED": 0, + "ACTIVE": 1, + "RESOURCE_ERROR": 2 + } } } }, @@ -904,6 +924,44 @@ } } }, + "BigQueryConfig": { + "fields": { + "table": { + "type": "string", + "id": 1 + }, + "useTopicSchema": { + "type": "bool", + "id": 2 + }, + "writeMetadata": { + "type": "bool", + "id": 3 + }, + "dropUnknownFields": { + "type": "bool", + "id": 4 + }, + "state": { + "type": "State", + "id": 5, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + }, + "nested": { + "State": { + "values": { + "STATE_UNSPECIFIED": 0, + "ACTIVE": 1, + "PERMISSION_DENIED": 2, + "NOT_FOUND": 3, + "SCHEMA_MISMATCH": 4 + } + } + } + }, "ReceivedMessage": { "fields": { "ackId": { diff --git a/src/v1/subscriber_client.ts b/src/v1/subscriber_client.ts index a6fa19bdc..9474093c1 100644 --- a/src/v1/subscriber_client.ts +++ b/src/v1/subscriber_client.ts @@ -405,8 +405,14 @@ export class SubscriberClient { * field will be `_deleted-topic_` if the topic has been deleted. * @param {google.pubsub.v1.PushConfig} request.pushConfig * If push delivery is used with this subscription, this field is - * used to configure it. An empty `pushConfig` signifies that the subscriber - * will pull and ack messages using API methods. + * used to configure it. Either `pushConfig` or `bigQueryConfig` can be set, + * but not both. If both are empty, then the subscriber will pull and ack + * messages using API methods. + * @param {google.pubsub.v1.BigQueryConfig} request.bigqueryConfig + * If delivery to BigQuery is used with this subscription, this field is + * used to configure it. Either `pushConfig` or `bigQueryConfig` can be set, + * but not both. If both are empty, then the subscriber will pull and ack + * messages using API methods. * @param {number} request.ackDeadlineSeconds * The approximate amount of time (on a best-effort basis) Pub/Sub waits for * the subscriber to acknowledge receipt before resending the message. In the @@ -505,6 +511,9 @@ export class SubscriberClient { * `topic_message_retention_duration` are always available to subscribers. See * the `message_retention_duration` field in `Topic`. This field is set only * in responses from the server; it is ignored if it is set in any requests. + * @param {google.pubsub.v1.Subscription.State} request.state + * Output only. An output-only field indicating whether or not the subscription can receive + * messages. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array.