diff --git a/README.md b/README.md index 48a42e237..7af9f6a7d 100644 --- a/README.md +++ b/README.md @@ -70,14 +70,14 @@ const {PubSub} = require('@google-cloud/pubsub'); async function quickstart( projectId = 'your-project-id', // Your Google Cloud Platform project ID - topicName = 'my-topic', // Name for the new topic to create + topicNameOrId = 'my-topic', // Name for the new topic to create subscriptionName = 'my-sub' // Name for the new subscription to create ) { // Instantiates a client const pubsub = new PubSub({projectId}); // Creates a new topic - const [topic] = await pubsub.createTopic(topicName); + const [topic] = await pubsub.createTopic(topicNameOrId); console.log(`Topic ${topic.name} created.`); // Creates a subscription on that new topic diff --git a/protos/google/pubsub/v1/pubsub.proto b/protos/google/pubsub/v1/pubsub.proto index b1d65626c..a44ba7c9c 100644 --- a/protos/google/pubsub/v1/pubsub.proto +++ b/protos/google/pubsub/v1/pubsub.proto @@ -752,6 +752,19 @@ message Subscription { // the endpoint will not be made. bool detached = 15; + // If true, Pub/Sub provides the following guarantees for the delivery of + // a message with a given value of `message_id` on this subscription: + // + // * The message sent to a subscriber is guaranteed not to be resent + // before the message's acknowledgement deadline expires. + // * An acknowledged message will not be resent to a subscriber. + // + // Note that subscribers may still receive multiple copies of a message + // when `enable_exactly_once_delivery` is true if the message was published + // multiple times by a publisher client. These copies are considered distinct + // by Pub/Sub and have distinct `message_id` values. + bool enable_exactly_once_delivery = 16; + // Output only. Indicates the minimum duration for which a message is retained // after it is published to the subscription's topic. If this field is set, // messages published to the subscription's topic in the last @@ -1163,8 +1176,35 @@ message StreamingPullRequest { // Response for the `StreamingPull` method. This response is used to stream // messages from the server to the client. message StreamingPullResponse { + // Acknowledgement IDs sent in one or more previous requests to acknowledge a + // previously received message. + message AcknowledgeConfirmation { + // Successfully processed acknowledgement IDs. + repeated string ack_ids = 1 [ctype = CORD]; + + // List of acknowledgement IDs that were malformed or whose acknowledgement + // deadline has expired. + repeated string invalid_ack_ids = 2 [ctype = CORD]; + + // List of acknowledgement IDs that were out of order. + repeated string unordered_ack_ids = 3 [ctype = CORD]; + } + + // Acknowledgement IDs sent in one or more previous requests to modify the + // deadline for a specific message. + message ModifyAckDeadlineConfirmation { + // Successfully processed acknowledgement IDs. + repeated string ack_ids = 1 [ctype = CORD]; + + // List of acknowledgement IDs that were malformed or whose acknowledgement + // deadline has expired. + repeated string invalid_ack_ids = 2 [ctype = CORD]; + } + // Subscription properties sent as part of the response. message SubscriptionProperties { + // True iff exactly once delivery is enabled for this subscription. + bool exactly_once_delivery_enabled = 1; // True iff message ordering is enabled for this subscription. bool message_ordering_enabled = 2; } @@ -1172,6 +1212,14 @@ message StreamingPullResponse { // Received Pub/Sub messages. This will not be empty. repeated ReceivedMessage received_messages = 1; + // This field will only be set if `enable_exactly_once_delivery` is set to + // `true`. + AcknowledgeConfirmation acknowlege_confirmation = 2; + + // This field will only be set if `enable_exactly_once_delivery` is set to + // `true`. + ModifyAckDeadlineConfirmation modify_ack_deadline_confirmation = 3; + // Properties associated with this subscription. SubscriptionProperties subscription_properties = 4; } diff --git a/protos/protos.d.ts b/protos/protos.d.ts index eb8c32bcf..c82d9bbed 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -2294,6 +2294,9 @@ export namespace google { /** Subscription detached */ detached?: (boolean|null); + /** Subscription enableExactlyOnceDelivery */ + enableExactlyOnceDelivery?: (boolean|null); + /** Subscription topicMessageRetentionDuration */ topicMessageRetentionDuration?: (google.protobuf.IDuration|null); } @@ -2346,6 +2349,9 @@ export namespace google { /** Subscription detached. */ public detached: boolean; + /** Subscription enableExactlyOnceDelivery. */ + public enableExactlyOnceDelivery: boolean; + /** Subscription topicMessageRetentionDuration. */ public topicMessageRetentionDuration?: (google.protobuf.IDuration|null); @@ -4106,6 +4112,12 @@ export namespace google { /** StreamingPullResponse receivedMessages */ receivedMessages?: (google.pubsub.v1.IReceivedMessage[]|null); + /** StreamingPullResponse acknowlegeConfirmation */ + acknowlegeConfirmation?: (google.pubsub.v1.StreamingPullResponse.IAcknowledgeConfirmation|null); + + /** StreamingPullResponse modifyAckDeadlineConfirmation */ + modifyAckDeadlineConfirmation?: (google.pubsub.v1.StreamingPullResponse.IModifyAckDeadlineConfirmation|null); + /** StreamingPullResponse subscriptionProperties */ subscriptionProperties?: (google.pubsub.v1.StreamingPullResponse.ISubscriptionProperties|null); } @@ -4122,6 +4134,12 @@ export namespace google { /** StreamingPullResponse receivedMessages. */ public receivedMessages: google.pubsub.v1.IReceivedMessage[]; + /** StreamingPullResponse acknowlegeConfirmation. */ + public acknowlegeConfirmation?: (google.pubsub.v1.StreamingPullResponse.IAcknowledgeConfirmation|null); + + /** StreamingPullResponse modifyAckDeadlineConfirmation. */ + public modifyAckDeadlineConfirmation?: (google.pubsub.v1.StreamingPullResponse.IModifyAckDeadlineConfirmation|null); + /** StreamingPullResponse subscriptionProperties. */ public subscriptionProperties?: (google.pubsub.v1.StreamingPullResponse.ISubscriptionProperties|null); @@ -4198,9 +4216,210 @@ export namespace google { namespace StreamingPullResponse { + /** Properties of an AcknowledgeConfirmation. */ + interface IAcknowledgeConfirmation { + + /** AcknowledgeConfirmation ackIds */ + ackIds?: (string[]|null); + + /** AcknowledgeConfirmation invalidAckIds */ + invalidAckIds?: (string[]|null); + + /** AcknowledgeConfirmation unorderedAckIds */ + unorderedAckIds?: (string[]|null); + } + + /** Represents an AcknowledgeConfirmation. */ + class AcknowledgeConfirmation implements IAcknowledgeConfirmation { + + /** + * Constructs a new AcknowledgeConfirmation. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.StreamingPullResponse.IAcknowledgeConfirmation); + + /** AcknowledgeConfirmation ackIds. */ + public ackIds: string[]; + + /** AcknowledgeConfirmation invalidAckIds. */ + public invalidAckIds: string[]; + + /** AcknowledgeConfirmation unorderedAckIds. */ + public unorderedAckIds: string[]; + + /** + * Creates a new AcknowledgeConfirmation instance using the specified properties. + * @param [properties] Properties to set + * @returns AcknowledgeConfirmation instance + */ + public static create(properties?: google.pubsub.v1.StreamingPullResponse.IAcknowledgeConfirmation): google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation; + + /** + * Encodes the specified AcknowledgeConfirmation message. Does not implicitly {@link google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation.verify|verify} messages. + * @param message AcknowledgeConfirmation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.StreamingPullResponse.IAcknowledgeConfirmation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AcknowledgeConfirmation message, length delimited. Does not implicitly {@link google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation.verify|verify} messages. + * @param message AcknowledgeConfirmation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.StreamingPullResponse.IAcknowledgeConfirmation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AcknowledgeConfirmation message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AcknowledgeConfirmation + * @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.StreamingPullResponse.AcknowledgeConfirmation; + + /** + * Decodes an AcknowledgeConfirmation message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AcknowledgeConfirmation + * @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.StreamingPullResponse.AcknowledgeConfirmation; + + /** + * Verifies an AcknowledgeConfirmation 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 AcknowledgeConfirmation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AcknowledgeConfirmation + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation; + + /** + * Creates a plain object from an AcknowledgeConfirmation message. Also converts values to other types if specified. + * @param message AcknowledgeConfirmation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AcknowledgeConfirmation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ModifyAckDeadlineConfirmation. */ + interface IModifyAckDeadlineConfirmation { + + /** ModifyAckDeadlineConfirmation ackIds */ + ackIds?: (string[]|null); + + /** ModifyAckDeadlineConfirmation invalidAckIds */ + invalidAckIds?: (string[]|null); + } + + /** Represents a ModifyAckDeadlineConfirmation. */ + class ModifyAckDeadlineConfirmation implements IModifyAckDeadlineConfirmation { + + /** + * Constructs a new ModifyAckDeadlineConfirmation. + * @param [properties] Properties to set + */ + constructor(properties?: google.pubsub.v1.StreamingPullResponse.IModifyAckDeadlineConfirmation); + + /** ModifyAckDeadlineConfirmation ackIds. */ + public ackIds: string[]; + + /** ModifyAckDeadlineConfirmation invalidAckIds. */ + public invalidAckIds: string[]; + + /** + * Creates a new ModifyAckDeadlineConfirmation instance using the specified properties. + * @param [properties] Properties to set + * @returns ModifyAckDeadlineConfirmation instance + */ + public static create(properties?: google.pubsub.v1.StreamingPullResponse.IModifyAckDeadlineConfirmation): google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation; + + /** + * Encodes the specified ModifyAckDeadlineConfirmation message. Does not implicitly {@link google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation.verify|verify} messages. + * @param message ModifyAckDeadlineConfirmation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.pubsub.v1.StreamingPullResponse.IModifyAckDeadlineConfirmation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ModifyAckDeadlineConfirmation message, length delimited. Does not implicitly {@link google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation.verify|verify} messages. + * @param message ModifyAckDeadlineConfirmation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.pubsub.v1.StreamingPullResponse.IModifyAckDeadlineConfirmation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ModifyAckDeadlineConfirmation message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ModifyAckDeadlineConfirmation + * @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.StreamingPullResponse.ModifyAckDeadlineConfirmation; + + /** + * Decodes a ModifyAckDeadlineConfirmation message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ModifyAckDeadlineConfirmation + * @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.StreamingPullResponse.ModifyAckDeadlineConfirmation; + + /** + * Verifies a ModifyAckDeadlineConfirmation 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 ModifyAckDeadlineConfirmation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ModifyAckDeadlineConfirmation + */ + public static fromObject(object: { [k: string]: any }): google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation; + + /** + * Creates a plain object from a ModifyAckDeadlineConfirmation message. Also converts values to other types if specified. + * @param message ModifyAckDeadlineConfirmation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ModifyAckDeadlineConfirmation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + /** Properties of a SubscriptionProperties. */ interface ISubscriptionProperties { + /** SubscriptionProperties exactlyOnceDeliveryEnabled */ + exactlyOnceDeliveryEnabled?: (boolean|null); + /** SubscriptionProperties messageOrderingEnabled */ messageOrderingEnabled?: (boolean|null); } @@ -4214,6 +4433,9 @@ export namespace google { */ constructor(properties?: google.pubsub.v1.StreamingPullResponse.ISubscriptionProperties); + /** SubscriptionProperties exactlyOnceDeliveryEnabled. */ + public exactlyOnceDeliveryEnabled: boolean; + /** SubscriptionProperties messageOrderingEnabled. */ public messageOrderingEnabled: boolean; diff --git a/protos/protos.js b/protos/protos.js index 7b4c8098a..63199572f 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -4853,6 +4853,7 @@ * @property {google.pubsub.v1.IDeadLetterPolicy|null} [deadLetterPolicy] Subscription deadLetterPolicy * @property {google.pubsub.v1.IRetryPolicy|null} [retryPolicy] Subscription retryPolicy * @property {boolean|null} [detached] Subscription detached + * @property {boolean|null} [enableExactlyOnceDelivery] Subscription enableExactlyOnceDelivery * @property {google.protobuf.IDuration|null} [topicMessageRetentionDuration] Subscription topicMessageRetentionDuration */ @@ -4976,6 +4977,14 @@ */ Subscription.prototype.detached = false; + /** + * Subscription enableExactlyOnceDelivery. + * @member {boolean} enableExactlyOnceDelivery + * @memberof google.pubsub.v1.Subscription + * @instance + */ + Subscription.prototype.enableExactlyOnceDelivery = false; + /** * Subscription topicMessageRetentionDuration. * @member {google.protobuf.IDuration|null|undefined} topicMessageRetentionDuration @@ -5035,6 +5044,8 @@ $root.google.pubsub.v1.RetryPolicy.encode(message.retryPolicy, writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); if (message.detached != null && Object.hasOwnProperty.call(message, "detached")) writer.uint32(/* id 15, wireType 0 =*/120).bool(message.detached); + if (message.enableExactlyOnceDelivery != null && Object.hasOwnProperty.call(message, "enableExactlyOnceDelivery")) + 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(); return writer; @@ -5129,6 +5140,9 @@ case 15: message.detached = reader.bool(); break; + case 16: + message.enableExactlyOnceDelivery = reader.bool(); + break; case 17: message.topicMessageRetentionDuration = $root.google.protobuf.Duration.decode(reader, reader.uint32()); break; @@ -5221,6 +5235,9 @@ if (message.detached != null && message.hasOwnProperty("detached")) if (typeof message.detached !== "boolean") return "detached: boolean expected"; + if (message.enableExactlyOnceDelivery != null && message.hasOwnProperty("enableExactlyOnceDelivery")) + if (typeof message.enableExactlyOnceDelivery !== "boolean") + return "enableExactlyOnceDelivery: boolean expected"; if (message.topicMessageRetentionDuration != null && message.hasOwnProperty("topicMessageRetentionDuration")) { var error = $root.google.protobuf.Duration.verify(message.topicMessageRetentionDuration); if (error) @@ -5287,6 +5304,8 @@ } if (object.detached != null) message.detached = Boolean(object.detached); + if (object.enableExactlyOnceDelivery != null) + message.enableExactlyOnceDelivery = Boolean(object.enableExactlyOnceDelivery); if (object.topicMessageRetentionDuration != null) { if (typeof object.topicMessageRetentionDuration !== "object") throw TypeError(".google.pubsub.v1.Subscription.topicMessageRetentionDuration: object expected"); @@ -5323,6 +5342,7 @@ object.deadLetterPolicy = null; object.retryPolicy = null; object.detached = false; + object.enableExactlyOnceDelivery = false; object.topicMessageRetentionDuration = null; } if (message.name != null && message.hasOwnProperty("name")) @@ -5355,6 +5375,8 @@ object.retryPolicy = $root.google.pubsub.v1.RetryPolicy.toObject(message.retryPolicy, options); if (message.detached != null && message.hasOwnProperty("detached")) object.detached = message.detached; + if (message.enableExactlyOnceDelivery != null && message.hasOwnProperty("enableExactlyOnceDelivery")) + object.enableExactlyOnceDelivery = message.enableExactlyOnceDelivery; if (message.topicMessageRetentionDuration != null && message.hasOwnProperty("topicMessageRetentionDuration")) object.topicMessageRetentionDuration = $root.google.protobuf.Duration.toObject(message.topicMessageRetentionDuration, options); return object; @@ -9357,6 +9379,8 @@ * @memberof google.pubsub.v1 * @interface IStreamingPullResponse * @property {Array.|null} [receivedMessages] StreamingPullResponse receivedMessages + * @property {google.pubsub.v1.StreamingPullResponse.IAcknowledgeConfirmation|null} [acknowlegeConfirmation] StreamingPullResponse acknowlegeConfirmation + * @property {google.pubsub.v1.StreamingPullResponse.IModifyAckDeadlineConfirmation|null} [modifyAckDeadlineConfirmation] StreamingPullResponse modifyAckDeadlineConfirmation * @property {google.pubsub.v1.StreamingPullResponse.ISubscriptionProperties|null} [subscriptionProperties] StreamingPullResponse subscriptionProperties */ @@ -9384,6 +9408,22 @@ */ StreamingPullResponse.prototype.receivedMessages = $util.emptyArray; + /** + * StreamingPullResponse acknowlegeConfirmation. + * @member {google.pubsub.v1.StreamingPullResponse.IAcknowledgeConfirmation|null|undefined} acknowlegeConfirmation + * @memberof google.pubsub.v1.StreamingPullResponse + * @instance + */ + StreamingPullResponse.prototype.acknowlegeConfirmation = null; + + /** + * StreamingPullResponse modifyAckDeadlineConfirmation. + * @member {google.pubsub.v1.StreamingPullResponse.IModifyAckDeadlineConfirmation|null|undefined} modifyAckDeadlineConfirmation + * @memberof google.pubsub.v1.StreamingPullResponse + * @instance + */ + StreamingPullResponse.prototype.modifyAckDeadlineConfirmation = null; + /** * StreamingPullResponse subscriptionProperties. * @member {google.pubsub.v1.StreamingPullResponse.ISubscriptionProperties|null|undefined} subscriptionProperties @@ -9419,6 +9459,10 @@ if (message.receivedMessages != null && message.receivedMessages.length) for (var i = 0; i < message.receivedMessages.length; ++i) $root.google.pubsub.v1.ReceivedMessage.encode(message.receivedMessages[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.acknowlegeConfirmation != null && Object.hasOwnProperty.call(message, "acknowlegeConfirmation")) + $root.google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation.encode(message.acknowlegeConfirmation, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.modifyAckDeadlineConfirmation != null && Object.hasOwnProperty.call(message, "modifyAckDeadlineConfirmation")) + $root.google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation.encode(message.modifyAckDeadlineConfirmation, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); if (message.subscriptionProperties != null && Object.hasOwnProperty.call(message, "subscriptionProperties")) $root.google.pubsub.v1.StreamingPullResponse.SubscriptionProperties.encode(message.subscriptionProperties, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); return writer; @@ -9460,6 +9504,12 @@ message.receivedMessages = []; message.receivedMessages.push($root.google.pubsub.v1.ReceivedMessage.decode(reader, reader.uint32())); break; + case 2: + message.acknowlegeConfirmation = $root.google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation.decode(reader, reader.uint32()); + break; + case 3: + message.modifyAckDeadlineConfirmation = $root.google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation.decode(reader, reader.uint32()); + break; case 4: message.subscriptionProperties = $root.google.pubsub.v1.StreamingPullResponse.SubscriptionProperties.decode(reader, reader.uint32()); break; @@ -9507,6 +9557,16 @@ return "receivedMessages." + error; } } + if (message.acknowlegeConfirmation != null && message.hasOwnProperty("acknowlegeConfirmation")) { + var error = $root.google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation.verify(message.acknowlegeConfirmation); + if (error) + return "acknowlegeConfirmation." + error; + } + if (message.modifyAckDeadlineConfirmation != null && message.hasOwnProperty("modifyAckDeadlineConfirmation")) { + var error = $root.google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation.verify(message.modifyAckDeadlineConfirmation); + if (error) + return "modifyAckDeadlineConfirmation." + error; + } if (message.subscriptionProperties != null && message.hasOwnProperty("subscriptionProperties")) { var error = $root.google.pubsub.v1.StreamingPullResponse.SubscriptionProperties.verify(message.subscriptionProperties); if (error) @@ -9537,6 +9597,16 @@ message.receivedMessages[i] = $root.google.pubsub.v1.ReceivedMessage.fromObject(object.receivedMessages[i]); } } + if (object.acknowlegeConfirmation != null) { + if (typeof object.acknowlegeConfirmation !== "object") + throw TypeError(".google.pubsub.v1.StreamingPullResponse.acknowlegeConfirmation: object expected"); + message.acknowlegeConfirmation = $root.google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation.fromObject(object.acknowlegeConfirmation); + } + if (object.modifyAckDeadlineConfirmation != null) { + if (typeof object.modifyAckDeadlineConfirmation !== "object") + throw TypeError(".google.pubsub.v1.StreamingPullResponse.modifyAckDeadlineConfirmation: object expected"); + message.modifyAckDeadlineConfirmation = $root.google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation.fromObject(object.modifyAckDeadlineConfirmation); + } if (object.subscriptionProperties != null) { if (typeof object.subscriptionProperties !== "object") throw TypeError(".google.pubsub.v1.StreamingPullResponse.subscriptionProperties: object expected"); @@ -9560,13 +9630,20 @@ var object = {}; if (options.arrays || options.defaults) object.receivedMessages = []; - if (options.defaults) + if (options.defaults) { + object.acknowlegeConfirmation = null; + object.modifyAckDeadlineConfirmation = null; object.subscriptionProperties = null; + } if (message.receivedMessages && message.receivedMessages.length) { object.receivedMessages = []; for (var j = 0; j < message.receivedMessages.length; ++j) object.receivedMessages[j] = $root.google.pubsub.v1.ReceivedMessage.toObject(message.receivedMessages[j], options); } + if (message.acknowlegeConfirmation != null && message.hasOwnProperty("acknowlegeConfirmation")) + object.acknowlegeConfirmation = $root.google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation.toObject(message.acknowlegeConfirmation, options); + if (message.modifyAckDeadlineConfirmation != null && message.hasOwnProperty("modifyAckDeadlineConfirmation")) + object.modifyAckDeadlineConfirmation = $root.google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation.toObject(message.modifyAckDeadlineConfirmation, options); if (message.subscriptionProperties != null && message.hasOwnProperty("subscriptionProperties")) object.subscriptionProperties = $root.google.pubsub.v1.StreamingPullResponse.SubscriptionProperties.toObject(message.subscriptionProperties, options); return object; @@ -9583,12 +9660,535 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + StreamingPullResponse.AcknowledgeConfirmation = (function() { + + /** + * Properties of an AcknowledgeConfirmation. + * @memberof google.pubsub.v1.StreamingPullResponse + * @interface IAcknowledgeConfirmation + * @property {Array.|null} [ackIds] AcknowledgeConfirmation ackIds + * @property {Array.|null} [invalidAckIds] AcknowledgeConfirmation invalidAckIds + * @property {Array.|null} [unorderedAckIds] AcknowledgeConfirmation unorderedAckIds + */ + + /** + * Constructs a new AcknowledgeConfirmation. + * @memberof google.pubsub.v1.StreamingPullResponse + * @classdesc Represents an AcknowledgeConfirmation. + * @implements IAcknowledgeConfirmation + * @constructor + * @param {google.pubsub.v1.StreamingPullResponse.IAcknowledgeConfirmation=} [properties] Properties to set + */ + function AcknowledgeConfirmation(properties) { + this.ackIds = []; + this.invalidAckIds = []; + this.unorderedAckIds = []; + 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]]; + } + + /** + * AcknowledgeConfirmation ackIds. + * @member {Array.} ackIds + * @memberof google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation + * @instance + */ + AcknowledgeConfirmation.prototype.ackIds = $util.emptyArray; + + /** + * AcknowledgeConfirmation invalidAckIds. + * @member {Array.} invalidAckIds + * @memberof google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation + * @instance + */ + AcknowledgeConfirmation.prototype.invalidAckIds = $util.emptyArray; + + /** + * AcknowledgeConfirmation unorderedAckIds. + * @member {Array.} unorderedAckIds + * @memberof google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation + * @instance + */ + AcknowledgeConfirmation.prototype.unorderedAckIds = $util.emptyArray; + + /** + * Creates a new AcknowledgeConfirmation instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation + * @static + * @param {google.pubsub.v1.StreamingPullResponse.IAcknowledgeConfirmation=} [properties] Properties to set + * @returns {google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation} AcknowledgeConfirmation instance + */ + AcknowledgeConfirmation.create = function create(properties) { + return new AcknowledgeConfirmation(properties); + }; + + /** + * Encodes the specified AcknowledgeConfirmation message. Does not implicitly {@link google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation + * @static + * @param {google.pubsub.v1.StreamingPullResponse.IAcknowledgeConfirmation} message AcknowledgeConfirmation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AcknowledgeConfirmation.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ackIds != null && message.ackIds.length) + for (var i = 0; i < message.ackIds.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.ackIds[i]); + if (message.invalidAckIds != null && message.invalidAckIds.length) + for (var i = 0; i < message.invalidAckIds.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.invalidAckIds[i]); + if (message.unorderedAckIds != null && message.unorderedAckIds.length) + for (var i = 0; i < message.unorderedAckIds.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.unorderedAckIds[i]); + return writer; + }; + + /** + * Encodes the specified AcknowledgeConfirmation message, length delimited. Does not implicitly {@link google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation + * @static + * @param {google.pubsub.v1.StreamingPullResponse.IAcknowledgeConfirmation} message AcknowledgeConfirmation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AcknowledgeConfirmation.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AcknowledgeConfirmation message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation} AcknowledgeConfirmation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AcknowledgeConfirmation.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.StreamingPullResponse.AcknowledgeConfirmation(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.ackIds && message.ackIds.length)) + message.ackIds = []; + message.ackIds.push(reader.string()); + break; + case 2: + if (!(message.invalidAckIds && message.invalidAckIds.length)) + message.invalidAckIds = []; + message.invalidAckIds.push(reader.string()); + break; + case 3: + if (!(message.unorderedAckIds && message.unorderedAckIds.length)) + message.unorderedAckIds = []; + message.unorderedAckIds.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AcknowledgeConfirmation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation} AcknowledgeConfirmation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AcknowledgeConfirmation.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AcknowledgeConfirmation message. + * @function verify + * @memberof google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AcknowledgeConfirmation.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ackIds != null && message.hasOwnProperty("ackIds")) { + if (!Array.isArray(message.ackIds)) + return "ackIds: array expected"; + for (var i = 0; i < message.ackIds.length; ++i) + if (!$util.isString(message.ackIds[i])) + return "ackIds: string[] expected"; + } + if (message.invalidAckIds != null && message.hasOwnProperty("invalidAckIds")) { + if (!Array.isArray(message.invalidAckIds)) + return "invalidAckIds: array expected"; + for (var i = 0; i < message.invalidAckIds.length; ++i) + if (!$util.isString(message.invalidAckIds[i])) + return "invalidAckIds: string[] expected"; + } + if (message.unorderedAckIds != null && message.hasOwnProperty("unorderedAckIds")) { + if (!Array.isArray(message.unorderedAckIds)) + return "unorderedAckIds: array expected"; + for (var i = 0; i < message.unorderedAckIds.length; ++i) + if (!$util.isString(message.unorderedAckIds[i])) + return "unorderedAckIds: string[] expected"; + } + return null; + }; + + /** + * Creates an AcknowledgeConfirmation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation} AcknowledgeConfirmation + */ + AcknowledgeConfirmation.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation) + return object; + var message = new $root.google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation(); + if (object.ackIds) { + if (!Array.isArray(object.ackIds)) + throw TypeError(".google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation.ackIds: array expected"); + message.ackIds = []; + for (var i = 0; i < object.ackIds.length; ++i) + message.ackIds[i] = String(object.ackIds[i]); + } + if (object.invalidAckIds) { + if (!Array.isArray(object.invalidAckIds)) + throw TypeError(".google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation.invalidAckIds: array expected"); + message.invalidAckIds = []; + for (var i = 0; i < object.invalidAckIds.length; ++i) + message.invalidAckIds[i] = String(object.invalidAckIds[i]); + } + if (object.unorderedAckIds) { + if (!Array.isArray(object.unorderedAckIds)) + throw TypeError(".google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation.unorderedAckIds: array expected"); + message.unorderedAckIds = []; + for (var i = 0; i < object.unorderedAckIds.length; ++i) + message.unorderedAckIds[i] = String(object.unorderedAckIds[i]); + } + return message; + }; + + /** + * Creates a plain object from an AcknowledgeConfirmation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation + * @static + * @param {google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation} message AcknowledgeConfirmation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AcknowledgeConfirmation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.ackIds = []; + object.invalidAckIds = []; + object.unorderedAckIds = []; + } + if (message.ackIds && message.ackIds.length) { + object.ackIds = []; + for (var j = 0; j < message.ackIds.length; ++j) + object.ackIds[j] = message.ackIds[j]; + } + if (message.invalidAckIds && message.invalidAckIds.length) { + object.invalidAckIds = []; + for (var j = 0; j < message.invalidAckIds.length; ++j) + object.invalidAckIds[j] = message.invalidAckIds[j]; + } + if (message.unorderedAckIds && message.unorderedAckIds.length) { + object.unorderedAckIds = []; + for (var j = 0; j < message.unorderedAckIds.length; ++j) + object.unorderedAckIds[j] = message.unorderedAckIds[j]; + } + return object; + }; + + /** + * Converts this AcknowledgeConfirmation to JSON. + * @function toJSON + * @memberof google.pubsub.v1.StreamingPullResponse.AcknowledgeConfirmation + * @instance + * @returns {Object.} JSON object + */ + AcknowledgeConfirmation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return AcknowledgeConfirmation; + })(); + + StreamingPullResponse.ModifyAckDeadlineConfirmation = (function() { + + /** + * Properties of a ModifyAckDeadlineConfirmation. + * @memberof google.pubsub.v1.StreamingPullResponse + * @interface IModifyAckDeadlineConfirmation + * @property {Array.|null} [ackIds] ModifyAckDeadlineConfirmation ackIds + * @property {Array.|null} [invalidAckIds] ModifyAckDeadlineConfirmation invalidAckIds + */ + + /** + * Constructs a new ModifyAckDeadlineConfirmation. + * @memberof google.pubsub.v1.StreamingPullResponse + * @classdesc Represents a ModifyAckDeadlineConfirmation. + * @implements IModifyAckDeadlineConfirmation + * @constructor + * @param {google.pubsub.v1.StreamingPullResponse.IModifyAckDeadlineConfirmation=} [properties] Properties to set + */ + function ModifyAckDeadlineConfirmation(properties) { + this.ackIds = []; + this.invalidAckIds = []; + 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]]; + } + + /** + * ModifyAckDeadlineConfirmation ackIds. + * @member {Array.} ackIds + * @memberof google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation + * @instance + */ + ModifyAckDeadlineConfirmation.prototype.ackIds = $util.emptyArray; + + /** + * ModifyAckDeadlineConfirmation invalidAckIds. + * @member {Array.} invalidAckIds + * @memberof google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation + * @instance + */ + ModifyAckDeadlineConfirmation.prototype.invalidAckIds = $util.emptyArray; + + /** + * Creates a new ModifyAckDeadlineConfirmation instance using the specified properties. + * @function create + * @memberof google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation + * @static + * @param {google.pubsub.v1.StreamingPullResponse.IModifyAckDeadlineConfirmation=} [properties] Properties to set + * @returns {google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation} ModifyAckDeadlineConfirmation instance + */ + ModifyAckDeadlineConfirmation.create = function create(properties) { + return new ModifyAckDeadlineConfirmation(properties); + }; + + /** + * Encodes the specified ModifyAckDeadlineConfirmation message. Does not implicitly {@link google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation.verify|verify} messages. + * @function encode + * @memberof google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation + * @static + * @param {google.pubsub.v1.StreamingPullResponse.IModifyAckDeadlineConfirmation} message ModifyAckDeadlineConfirmation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ModifyAckDeadlineConfirmation.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ackIds != null && message.ackIds.length) + for (var i = 0; i < message.ackIds.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.ackIds[i]); + if (message.invalidAckIds != null && message.invalidAckIds.length) + for (var i = 0; i < message.invalidAckIds.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.invalidAckIds[i]); + return writer; + }; + + /** + * Encodes the specified ModifyAckDeadlineConfirmation message, length delimited. Does not implicitly {@link google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation.verify|verify} messages. + * @function encodeDelimited + * @memberof google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation + * @static + * @param {google.pubsub.v1.StreamingPullResponse.IModifyAckDeadlineConfirmation} message ModifyAckDeadlineConfirmation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ModifyAckDeadlineConfirmation.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ModifyAckDeadlineConfirmation message from the specified reader or buffer. + * @function decode + * @memberof google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation} ModifyAckDeadlineConfirmation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ModifyAckDeadlineConfirmation.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.StreamingPullResponse.ModifyAckDeadlineConfirmation(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.ackIds && message.ackIds.length)) + message.ackIds = []; + message.ackIds.push(reader.string()); + break; + case 2: + if (!(message.invalidAckIds && message.invalidAckIds.length)) + message.invalidAckIds = []; + message.invalidAckIds.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ModifyAckDeadlineConfirmation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation} ModifyAckDeadlineConfirmation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ModifyAckDeadlineConfirmation.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ModifyAckDeadlineConfirmation message. + * @function verify + * @memberof google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ModifyAckDeadlineConfirmation.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ackIds != null && message.hasOwnProperty("ackIds")) { + if (!Array.isArray(message.ackIds)) + return "ackIds: array expected"; + for (var i = 0; i < message.ackIds.length; ++i) + if (!$util.isString(message.ackIds[i])) + return "ackIds: string[] expected"; + } + if (message.invalidAckIds != null && message.hasOwnProperty("invalidAckIds")) { + if (!Array.isArray(message.invalidAckIds)) + return "invalidAckIds: array expected"; + for (var i = 0; i < message.invalidAckIds.length; ++i) + if (!$util.isString(message.invalidAckIds[i])) + return "invalidAckIds: string[] expected"; + } + return null; + }; + + /** + * Creates a ModifyAckDeadlineConfirmation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation + * @static + * @param {Object.} object Plain object + * @returns {google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation} ModifyAckDeadlineConfirmation + */ + ModifyAckDeadlineConfirmation.fromObject = function fromObject(object) { + if (object instanceof $root.google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation) + return object; + var message = new $root.google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation(); + if (object.ackIds) { + if (!Array.isArray(object.ackIds)) + throw TypeError(".google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation.ackIds: array expected"); + message.ackIds = []; + for (var i = 0; i < object.ackIds.length; ++i) + message.ackIds[i] = String(object.ackIds[i]); + } + if (object.invalidAckIds) { + if (!Array.isArray(object.invalidAckIds)) + throw TypeError(".google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation.invalidAckIds: array expected"); + message.invalidAckIds = []; + for (var i = 0; i < object.invalidAckIds.length; ++i) + message.invalidAckIds[i] = String(object.invalidAckIds[i]); + } + return message; + }; + + /** + * Creates a plain object from a ModifyAckDeadlineConfirmation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation + * @static + * @param {google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation} message ModifyAckDeadlineConfirmation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ModifyAckDeadlineConfirmation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.ackIds = []; + object.invalidAckIds = []; + } + if (message.ackIds && message.ackIds.length) { + object.ackIds = []; + for (var j = 0; j < message.ackIds.length; ++j) + object.ackIds[j] = message.ackIds[j]; + } + if (message.invalidAckIds && message.invalidAckIds.length) { + object.invalidAckIds = []; + for (var j = 0; j < message.invalidAckIds.length; ++j) + object.invalidAckIds[j] = message.invalidAckIds[j]; + } + return object; + }; + + /** + * Converts this ModifyAckDeadlineConfirmation to JSON. + * @function toJSON + * @memberof google.pubsub.v1.StreamingPullResponse.ModifyAckDeadlineConfirmation + * @instance + * @returns {Object.} JSON object + */ + ModifyAckDeadlineConfirmation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ModifyAckDeadlineConfirmation; + })(); + StreamingPullResponse.SubscriptionProperties = (function() { /** * Properties of a SubscriptionProperties. * @memberof google.pubsub.v1.StreamingPullResponse * @interface ISubscriptionProperties + * @property {boolean|null} [exactlyOnceDeliveryEnabled] SubscriptionProperties exactlyOnceDeliveryEnabled * @property {boolean|null} [messageOrderingEnabled] SubscriptionProperties messageOrderingEnabled */ @@ -9607,6 +10207,14 @@ this[keys[i]] = properties[keys[i]]; } + /** + * SubscriptionProperties exactlyOnceDeliveryEnabled. + * @member {boolean} exactlyOnceDeliveryEnabled + * @memberof google.pubsub.v1.StreamingPullResponse.SubscriptionProperties + * @instance + */ + SubscriptionProperties.prototype.exactlyOnceDeliveryEnabled = false; + /** * SubscriptionProperties messageOrderingEnabled. * @member {boolean} messageOrderingEnabled @@ -9639,6 +10247,8 @@ SubscriptionProperties.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); + if (message.exactlyOnceDeliveryEnabled != null && Object.hasOwnProperty.call(message, "exactlyOnceDeliveryEnabled")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.exactlyOnceDeliveryEnabled); if (message.messageOrderingEnabled != null && Object.hasOwnProperty.call(message, "messageOrderingEnabled")) writer.uint32(/* id 2, wireType 0 =*/16).bool(message.messageOrderingEnabled); return writer; @@ -9675,6 +10285,9 @@ while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { + case 1: + message.exactlyOnceDeliveryEnabled = reader.bool(); + break; case 2: message.messageOrderingEnabled = reader.bool(); break; @@ -9713,6 +10326,9 @@ SubscriptionProperties.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; + if (message.exactlyOnceDeliveryEnabled != null && message.hasOwnProperty("exactlyOnceDeliveryEnabled")) + if (typeof message.exactlyOnceDeliveryEnabled !== "boolean") + return "exactlyOnceDeliveryEnabled: boolean expected"; if (message.messageOrderingEnabled != null && message.hasOwnProperty("messageOrderingEnabled")) if (typeof message.messageOrderingEnabled !== "boolean") return "messageOrderingEnabled: boolean expected"; @@ -9731,6 +10347,8 @@ if (object instanceof $root.google.pubsub.v1.StreamingPullResponse.SubscriptionProperties) return object; var message = new $root.google.pubsub.v1.StreamingPullResponse.SubscriptionProperties(); + if (object.exactlyOnceDeliveryEnabled != null) + message.exactlyOnceDeliveryEnabled = Boolean(object.exactlyOnceDeliveryEnabled); if (object.messageOrderingEnabled != null) message.messageOrderingEnabled = Boolean(object.messageOrderingEnabled); return message; @@ -9749,8 +10367,12 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { + object.exactlyOnceDeliveryEnabled = false; object.messageOrderingEnabled = false; + } + if (message.exactlyOnceDeliveryEnabled != null && message.hasOwnProperty("exactlyOnceDeliveryEnabled")) + object.exactlyOnceDeliveryEnabled = message.exactlyOnceDeliveryEnabled; if (message.messageOrderingEnabled != null && message.hasOwnProperty("messageOrderingEnabled")) object.messageOrderingEnabled = message.messageOrderingEnabled; return object; diff --git a/protos/protos.json b/protos/protos.json index 9ea5fa954..23cfd1526 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -821,6 +821,10 @@ "type": "bool", "id": 15 }, + "enableExactlyOnceDelivery": { + "type": "bool", + "id": 16 + }, "topicMessageRetentionDuration": { "type": "google.protobuf.Duration", "id": 17, @@ -1146,14 +1150,74 @@ "type": "ReceivedMessage", "id": 1 }, + "acknowlegeConfirmation": { + "type": "AcknowledgeConfirmation", + "id": 2 + }, + "modifyAckDeadlineConfirmation": { + "type": "ModifyAckDeadlineConfirmation", + "id": 3 + }, "subscriptionProperties": { "type": "SubscriptionProperties", "id": 4 } }, "nested": { + "AcknowledgeConfirmation": { + "fields": { + "ackIds": { + "rule": "repeated", + "type": "string", + "id": 1, + "options": { + "ctype": "CORD" + } + }, + "invalidAckIds": { + "rule": "repeated", + "type": "string", + "id": 2, + "options": { + "ctype": "CORD" + } + }, + "unorderedAckIds": { + "rule": "repeated", + "type": "string", + "id": 3, + "options": { + "ctype": "CORD" + } + } + } + }, + "ModifyAckDeadlineConfirmation": { + "fields": { + "ackIds": { + "rule": "repeated", + "type": "string", + "id": 1, + "options": { + "ctype": "CORD" + } + }, + "invalidAckIds": { + "rule": "repeated", + "type": "string", + "id": 2, + "options": { + "ctype": "CORD" + } + } + } + }, "SubscriptionProperties": { "fields": { + "exactlyOnceDeliveryEnabled": { + "type": "bool", + "id": 1 + }, "messageOrderingEnabled": { "type": "bool", "id": 2 diff --git a/samples/README.md b/samples/README.md index f74d19857..08e882ef6 100644 --- a/samples/README.md +++ b/samples/README.md @@ -132,7 +132,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node createPushSubscription.js ` +`node createPushSubscription.js ` ----- @@ -151,7 +151,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node createSubscription.js ` +`node createSubscription.js ` ----- @@ -170,7 +170,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node createSubscriptionWithDeadLetterPolicy.js ` +`node createSubscriptionWithDeadLetterPolicy.js ` ----- @@ -189,7 +189,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node createSubscriptionWithOrdering.js ` +`node createSubscriptionWithOrdering.js ` ----- @@ -208,7 +208,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node createTopic.js ` +`node createTopic.js ` ----- @@ -246,7 +246,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node deleteSchema.js ` +`node deleteSchema.js ` ----- @@ -265,7 +265,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node deleteSubscription.js ` +`node deleteSubscription.js ` ----- @@ -284,7 +284,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node deleteTopic.js ` +`node deleteTopic.js ` ----- @@ -303,7 +303,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node detachSubscription.js ` +`node detachSubscription.js ` ----- @@ -341,7 +341,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node getSubscription.js ` +`node getSubscription.js ` ----- @@ -360,7 +360,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node getSubscriptionPolicy.js ` +`node getSubscriptionPolicy.js ` ----- @@ -379,7 +379,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node getTopicPolicy.js ` +`node getTopicPolicy.js ` ----- @@ -455,7 +455,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node listTopicSubscriptions.js ` +`node listTopicSubscriptions.js ` ----- @@ -474,7 +474,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node listenForAvroRecords.js [timeout-in-seconds]` +`node listenForAvroRecords.js [timeout-in-seconds]` ----- @@ -493,7 +493,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node listenForErrors.js [timeout-in-seconds]` +`node listenForErrors.js [timeout-in-seconds]` ----- @@ -512,7 +512,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node listenForMessages.js [timeout-in-seconds]` +`node listenForMessages.js [timeout-in-seconds]` ----- @@ -550,7 +550,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node listenWithCustomAttributes.js [timeout-in-seconds]` +`node listenWithCustomAttributes.js [timeout-in-seconds]` ----- @@ -569,7 +569,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node modifyPushConfig.js ` +`node modifyPushConfig.js ` ----- @@ -588,7 +588,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node openTelemetryTracing.js ` +`node openTelemetryTracing.js ` ----- @@ -626,7 +626,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node publishBatchedMessages.js [max-messages [max-wait-in-seconds]]` +`node publishBatchedMessages.js [max-messages [max-wait-in-seconds]]` ----- @@ -645,7 +645,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node publishMessage.js ` +`node publishMessage.js ` ----- @@ -664,7 +664,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node publishMessageWithCustomAttributes.js ` +`node publishMessageWithCustomAttributes.js ` ----- @@ -683,7 +683,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node publishOrderedMessage.js ` +`node publishOrderedMessage.js ` ----- @@ -702,7 +702,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node publishProtobufMessages.js ` +`node publishProtobufMessages.js ` ----- @@ -721,7 +721,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node publishWithFlowControl.js ` +`node publishWithFlowControl.js ` ----- @@ -740,7 +740,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node publishWithRetrySettings.js ` +`node publishWithRetrySettings.js ` ----- @@ -759,7 +759,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node quickstart.js ` +`node quickstart.js ` ----- @@ -778,7 +778,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node removeDeadLetterPolicy.js ` +`node removeDeadLetterPolicy.js ` ----- @@ -797,7 +797,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node resumePublish.js ` +`node resumePublish.js ` ----- @@ -816,7 +816,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node setSubscriptionPolicy.js ` +`node setSubscriptionPolicy.js ` ----- @@ -835,7 +835,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node setTopicPolicy.js ` +`node setTopicPolicy.js ` ----- @@ -854,7 +854,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node subscribeWithFlowControlSettings.js [max-in-progress [timeout-in-seconds]]` +`node subscribeWithFlowControlSettings.js [max-in-progress [timeout-in-seconds]]` ----- @@ -873,7 +873,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node synchronousPull.js ` +`node synchronousPull.js ` ----- @@ -892,7 +892,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node synchronousPullWithDeliveryAttempts.js ` +`node synchronousPullWithDeliveryAttempts.js ` ----- @@ -911,7 +911,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node synchronousPullWithLeaseManagement.js ` +`node synchronousPullWithLeaseManagement.js ` ----- @@ -930,7 +930,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node testSubscriptionPermissions.js ` +`node testSubscriptionPermissions.js ` ----- @@ -949,7 +949,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node testTopicPermissions.js ` +`node testTopicPermissions.js ` ----- @@ -968,7 +968,7 @@ View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/sam __Usage:__ -`node updateDeadLetterPolicy.js ` +`node updateDeadLetterPolicy.js ` diff --git a/src/v1/subscriber_client.ts b/src/v1/subscriber_client.ts index f1ddcb033..71da17e5e 100644 --- a/src/v1/subscriber_client.ts +++ b/src/v1/subscriber_client.ts @@ -474,6 +474,18 @@ export class SubscriberClient { * backlog. `Pull` and `StreamingPull` requests will return * FAILED_PRECONDITION. If the subscription is a push subscription, pushes to * the endpoint will not be made. + * @param {boolean} request.enableExactlyOnceDelivery + * If true, Pub/Sub provides the following guarantees for the delivery of + * a message with a given value of `message_id` on this subscription: + * + * * The message sent to a subscriber is guaranteed not to be resent + * before the message's acknowledgement deadline expires. + * * An acknowledged message will not be resent to a subscriber. + * + * Note that subscribers may still receive multiple copies of a message + * when `enable_exactly_once_delivery` is true if the message was published + * multiple times by a publisher client. These copies are considered distinct + * by Pub/Sub and have distinct `message_id` values. * @param {google.protobuf.Duration} request.topicMessageRetentionDuration * Output only. Indicates the minimum duration for which a message is retained * after it is published to the subscription's topic. If this field is set,