@google-cloud/pubsub
Version:
Cloud Pub/Sub Client Library for Node.js
900 lines (825 loc) • 2.74 MB
JavaScript
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
(function(global, factory) { /* global define, require, module */
/* AMD */ if (typeof define === 'function' && define.amd)
define(["protobufjs/minimal"], factory);
/* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports)
module.exports = factory(require("google-gax/build/src/protobuf").protobufMinimal);
})(this, function($protobuf) {
"use strict";
// Common aliases
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
// Exported root namespace
var $root = $protobuf.roots._google_cloud_pubsub_protos || ($protobuf.roots._google_cloud_pubsub_protos = {});
$root.google = (function() {
/**
* Namespace google.
* @exports google
* @namespace
*/
var google = {};
google.pubsub = (function() {
/**
* Namespace pubsub.
* @memberof google
* @namespace
*/
var pubsub = {};
pubsub.v1 = (function() {
/**
* Namespace v1.
* @memberof google.pubsub
* @namespace
*/
var v1 = {};
v1.Publisher = (function() {
/**
* Constructs a new Publisher service.
* @memberof google.pubsub.v1
* @classdesc Represents a Publisher
* @extends $protobuf.rpc.Service
* @constructor
* @param {$protobuf.RPCImpl} rpcImpl RPC implementation
* @param {boolean} [requestDelimited=false] Whether requests are length-delimited
* @param {boolean} [responseDelimited=false] Whether responses are length-delimited
*/
function Publisher(rpcImpl, requestDelimited, responseDelimited) {
$protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited);
}
(Publisher.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Publisher;
/**
* Creates new Publisher service using the specified rpc implementation.
* @function create
* @memberof google.pubsub.v1.Publisher
* @static
* @param {$protobuf.RPCImpl} rpcImpl RPC implementation
* @param {boolean} [requestDelimited=false] Whether requests are length-delimited
* @param {boolean} [responseDelimited=false] Whether responses are length-delimited
* @returns {Publisher} RPC service. Useful where requests and/or responses are streamed.
*/
Publisher.create = function create(rpcImpl, requestDelimited, responseDelimited) {
return new this(rpcImpl, requestDelimited, responseDelimited);
};
/**
* Callback as used by {@link google.pubsub.v1.Publisher|createTopic}.
* @memberof google.pubsub.v1.Publisher
* @typedef CreateTopicCallback
* @type {function}
* @param {Error|null} error Error, if any
* @param {google.pubsub.v1.Topic} [response] Topic
*/
/**
* Calls CreateTopic.
* @function createTopic
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.ITopic} request Topic message or plain object
* @param {google.pubsub.v1.Publisher.CreateTopicCallback} callback Node-style callback called with the error, if any, and Topic
* @returns {undefined}
* @variation 1
*/
Object.defineProperty(Publisher.prototype.createTopic = function createTopic(request, callback) {
return this.rpcCall(createTopic, $root.google.pubsub.v1.Topic, $root.google.pubsub.v1.Topic, request, callback);
}, "name", { value: "CreateTopic" });
/**
* Calls CreateTopic.
* @function createTopic
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.ITopic} request Topic message or plain object
* @returns {Promise<google.pubsub.v1.Topic>} Promise
* @variation 2
*/
/**
* Callback as used by {@link google.pubsub.v1.Publisher|updateTopic}.
* @memberof google.pubsub.v1.Publisher
* @typedef UpdateTopicCallback
* @type {function}
* @param {Error|null} error Error, if any
* @param {google.pubsub.v1.Topic} [response] Topic
*/
/**
* Calls UpdateTopic.
* @function updateTopic
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.IUpdateTopicRequest} request UpdateTopicRequest message or plain object
* @param {google.pubsub.v1.Publisher.UpdateTopicCallback} callback Node-style callback called with the error, if any, and Topic
* @returns {undefined}
* @variation 1
*/
Object.defineProperty(Publisher.prototype.updateTopic = function updateTopic(request, callback) {
return this.rpcCall(updateTopic, $root.google.pubsub.v1.UpdateTopicRequest, $root.google.pubsub.v1.Topic, request, callback);
}, "name", { value: "UpdateTopic" });
/**
* Calls UpdateTopic.
* @function updateTopic
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.IUpdateTopicRequest} request UpdateTopicRequest message or plain object
* @returns {Promise<google.pubsub.v1.Topic>} Promise
* @variation 2
*/
/**
* Callback as used by {@link google.pubsub.v1.Publisher|publish}.
* @memberof google.pubsub.v1.Publisher
* @typedef PublishCallback
* @type {function}
* @param {Error|null} error Error, if any
* @param {google.pubsub.v1.PublishResponse} [response] PublishResponse
*/
/**
* Calls Publish.
* @function publish
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.IPublishRequest} request PublishRequest message or plain object
* @param {google.pubsub.v1.Publisher.PublishCallback} callback Node-style callback called with the error, if any, and PublishResponse
* @returns {undefined}
* @variation 1
*/
Object.defineProperty(Publisher.prototype.publish = function publish(request, callback) {
return this.rpcCall(publish, $root.google.pubsub.v1.PublishRequest, $root.google.pubsub.v1.PublishResponse, request, callback);
}, "name", { value: "Publish" });
/**
* Calls Publish.
* @function publish
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.IPublishRequest} request PublishRequest message or plain object
* @returns {Promise<google.pubsub.v1.PublishResponse>} Promise
* @variation 2
*/
/**
* Callback as used by {@link google.pubsub.v1.Publisher|getTopic}.
* @memberof google.pubsub.v1.Publisher
* @typedef GetTopicCallback
* @type {function}
* @param {Error|null} error Error, if any
* @param {google.pubsub.v1.Topic} [response] Topic
*/
/**
* Calls GetTopic.
* @function getTopic
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.IGetTopicRequest} request GetTopicRequest message or plain object
* @param {google.pubsub.v1.Publisher.GetTopicCallback} callback Node-style callback called with the error, if any, and Topic
* @returns {undefined}
* @variation 1
*/
Object.defineProperty(Publisher.prototype.getTopic = function getTopic(request, callback) {
return this.rpcCall(getTopic, $root.google.pubsub.v1.GetTopicRequest, $root.google.pubsub.v1.Topic, request, callback);
}, "name", { value: "GetTopic" });
/**
* Calls GetTopic.
* @function getTopic
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.IGetTopicRequest} request GetTopicRequest message or plain object
* @returns {Promise<google.pubsub.v1.Topic>} Promise
* @variation 2
*/
/**
* Callback as used by {@link google.pubsub.v1.Publisher|listTopics}.
* @memberof google.pubsub.v1.Publisher
* @typedef ListTopicsCallback
* @type {function}
* @param {Error|null} error Error, if any
* @param {google.pubsub.v1.ListTopicsResponse} [response] ListTopicsResponse
*/
/**
* Calls ListTopics.
* @function listTopics
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.IListTopicsRequest} request ListTopicsRequest message or plain object
* @param {google.pubsub.v1.Publisher.ListTopicsCallback} callback Node-style callback called with the error, if any, and ListTopicsResponse
* @returns {undefined}
* @variation 1
*/
Object.defineProperty(Publisher.prototype.listTopics = function listTopics(request, callback) {
return this.rpcCall(listTopics, $root.google.pubsub.v1.ListTopicsRequest, $root.google.pubsub.v1.ListTopicsResponse, request, callback);
}, "name", { value: "ListTopics" });
/**
* Calls ListTopics.
* @function listTopics
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.IListTopicsRequest} request ListTopicsRequest message or plain object
* @returns {Promise<google.pubsub.v1.ListTopicsResponse>} Promise
* @variation 2
*/
/**
* Callback as used by {@link google.pubsub.v1.Publisher|listTopicSubscriptions}.
* @memberof google.pubsub.v1.Publisher
* @typedef ListTopicSubscriptionsCallback
* @type {function}
* @param {Error|null} error Error, if any
* @param {google.pubsub.v1.ListTopicSubscriptionsResponse} [response] ListTopicSubscriptionsResponse
*/
/**
* Calls ListTopicSubscriptions.
* @function listTopicSubscriptions
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.IListTopicSubscriptionsRequest} request ListTopicSubscriptionsRequest message or plain object
* @param {google.pubsub.v1.Publisher.ListTopicSubscriptionsCallback} callback Node-style callback called with the error, if any, and ListTopicSubscriptionsResponse
* @returns {undefined}
* @variation 1
*/
Object.defineProperty(Publisher.prototype.listTopicSubscriptions = function listTopicSubscriptions(request, callback) {
return this.rpcCall(listTopicSubscriptions, $root.google.pubsub.v1.ListTopicSubscriptionsRequest, $root.google.pubsub.v1.ListTopicSubscriptionsResponse, request, callback);
}, "name", { value: "ListTopicSubscriptions" });
/**
* Calls ListTopicSubscriptions.
* @function listTopicSubscriptions
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.IListTopicSubscriptionsRequest} request ListTopicSubscriptionsRequest message or plain object
* @returns {Promise<google.pubsub.v1.ListTopicSubscriptionsResponse>} Promise
* @variation 2
*/
/**
* Callback as used by {@link google.pubsub.v1.Publisher|listTopicSnapshots}.
* @memberof google.pubsub.v1.Publisher
* @typedef ListTopicSnapshotsCallback
* @type {function}
* @param {Error|null} error Error, if any
* @param {google.pubsub.v1.ListTopicSnapshotsResponse} [response] ListTopicSnapshotsResponse
*/
/**
* Calls ListTopicSnapshots.
* @function listTopicSnapshots
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.IListTopicSnapshotsRequest} request ListTopicSnapshotsRequest message or plain object
* @param {google.pubsub.v1.Publisher.ListTopicSnapshotsCallback} callback Node-style callback called with the error, if any, and ListTopicSnapshotsResponse
* @returns {undefined}
* @variation 1
*/
Object.defineProperty(Publisher.prototype.listTopicSnapshots = function listTopicSnapshots(request, callback) {
return this.rpcCall(listTopicSnapshots, $root.google.pubsub.v1.ListTopicSnapshotsRequest, $root.google.pubsub.v1.ListTopicSnapshotsResponse, request, callback);
}, "name", { value: "ListTopicSnapshots" });
/**
* Calls ListTopicSnapshots.
* @function listTopicSnapshots
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.IListTopicSnapshotsRequest} request ListTopicSnapshotsRequest message or plain object
* @returns {Promise<google.pubsub.v1.ListTopicSnapshotsResponse>} Promise
* @variation 2
*/
/**
* Callback as used by {@link google.pubsub.v1.Publisher|deleteTopic}.
* @memberof google.pubsub.v1.Publisher
* @typedef DeleteTopicCallback
* @type {function}
* @param {Error|null} error Error, if any
* @param {google.protobuf.Empty} [response] Empty
*/
/**
* Calls DeleteTopic.
* @function deleteTopic
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.IDeleteTopicRequest} request DeleteTopicRequest message or plain object
* @param {google.pubsub.v1.Publisher.DeleteTopicCallback} callback Node-style callback called with the error, if any, and Empty
* @returns {undefined}
* @variation 1
*/
Object.defineProperty(Publisher.prototype.deleteTopic = function deleteTopic(request, callback) {
return this.rpcCall(deleteTopic, $root.google.pubsub.v1.DeleteTopicRequest, $root.google.protobuf.Empty, request, callback);
}, "name", { value: "DeleteTopic" });
/**
* Calls DeleteTopic.
* @function deleteTopic
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.IDeleteTopicRequest} request DeleteTopicRequest message or plain object
* @returns {Promise<google.protobuf.Empty>} Promise
* @variation 2
*/
/**
* Callback as used by {@link google.pubsub.v1.Publisher|detachSubscription}.
* @memberof google.pubsub.v1.Publisher
* @typedef DetachSubscriptionCallback
* @type {function}
* @param {Error|null} error Error, if any
* @param {google.pubsub.v1.DetachSubscriptionResponse} [response] DetachSubscriptionResponse
*/
/**
* Calls DetachSubscription.
* @function detachSubscription
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.IDetachSubscriptionRequest} request DetachSubscriptionRequest message or plain object
* @param {google.pubsub.v1.Publisher.DetachSubscriptionCallback} callback Node-style callback called with the error, if any, and DetachSubscriptionResponse
* @returns {undefined}
* @variation 1
*/
Object.defineProperty(Publisher.prototype.detachSubscription = function detachSubscription(request, callback) {
return this.rpcCall(detachSubscription, $root.google.pubsub.v1.DetachSubscriptionRequest, $root.google.pubsub.v1.DetachSubscriptionResponse, request, callback);
}, "name", { value: "DetachSubscription" });
/**
* Calls DetachSubscription.
* @function detachSubscription
* @memberof google.pubsub.v1.Publisher
* @instance
* @param {google.pubsub.v1.IDetachSubscriptionRequest} request DetachSubscriptionRequest message or plain object
* @returns {Promise<google.pubsub.v1.DetachSubscriptionResponse>} Promise
* @variation 2
*/
return Publisher;
})();
v1.MessageStoragePolicy = (function() {
/**
* Properties of a MessageStoragePolicy.
* @memberof google.pubsub.v1
* @interface IMessageStoragePolicy
* @property {Array.<string>|null} [allowedPersistenceRegions] MessageStoragePolicy allowedPersistenceRegions
* @property {boolean|null} [enforceInTransit] MessageStoragePolicy enforceInTransit
*/
/**
* Constructs a new MessageStoragePolicy.
* @memberof google.pubsub.v1
* @classdesc Represents a MessageStoragePolicy.
* @implements IMessageStoragePolicy
* @constructor
* @param {google.pubsub.v1.IMessageStoragePolicy=} [properties] Properties to set
*/
function MessageStoragePolicy(properties) {
this.allowedPersistenceRegions = [];
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]];
}
/**
* MessageStoragePolicy allowedPersistenceRegions.
* @member {Array.<string>} allowedPersistenceRegions
* @memberof google.pubsub.v1.MessageStoragePolicy
* @instance
*/
MessageStoragePolicy.prototype.allowedPersistenceRegions = $util.emptyArray;
/**
* MessageStoragePolicy enforceInTransit.
* @member {boolean} enforceInTransit
* @memberof google.pubsub.v1.MessageStoragePolicy
* @instance
*/
MessageStoragePolicy.prototype.enforceInTransit = false;
/**
* Creates a new MessageStoragePolicy instance using the specified properties.
* @function create
* @memberof google.pubsub.v1.MessageStoragePolicy
* @static
* @param {google.pubsub.v1.IMessageStoragePolicy=} [properties] Properties to set
* @returns {google.pubsub.v1.MessageStoragePolicy} MessageStoragePolicy instance
*/
MessageStoragePolicy.create = function create(properties) {
return new MessageStoragePolicy(properties);
};
/**
* Encodes the specified MessageStoragePolicy message. Does not implicitly {@link google.pubsub.v1.MessageStoragePolicy.verify|verify} messages.
* @function encode
* @memberof google.pubsub.v1.MessageStoragePolicy
* @static
* @param {google.pubsub.v1.IMessageStoragePolicy} message MessageStoragePolicy message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
MessageStoragePolicy.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.allowedPersistenceRegions != null && message.allowedPersistenceRegions.length)
for (var i = 0; i < message.allowedPersistenceRegions.length; ++i)
writer.uint32(/* id 1, wireType 2 =*/10).string(message.allowedPersistenceRegions[i]);
if (message.enforceInTransit != null && Object.hasOwnProperty.call(message, "enforceInTransit"))
writer.uint32(/* id 2, wireType 0 =*/16).bool(message.enforceInTransit);
return writer;
};
/**
* Encodes the specified MessageStoragePolicy message, length delimited. Does not implicitly {@link google.pubsub.v1.MessageStoragePolicy.verify|verify} messages.
* @function encodeDelimited
* @memberof google.pubsub.v1.MessageStoragePolicy
* @static
* @param {google.pubsub.v1.IMessageStoragePolicy} message MessageStoragePolicy message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
MessageStoragePolicy.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a MessageStoragePolicy message from the specified reader or buffer.
* @function decode
* @memberof google.pubsub.v1.MessageStoragePolicy
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {google.pubsub.v1.MessageStoragePolicy} MessageStoragePolicy
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
MessageStoragePolicy.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.pubsub.v1.MessageStoragePolicy();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
if (!(message.allowedPersistenceRegions && message.allowedPersistenceRegions.length))
message.allowedPersistenceRegions = [];
message.allowedPersistenceRegions.push(reader.string());
break;
}
case 2: {
message.enforceInTransit = reader.bool();
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a MessageStoragePolicy message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof google.pubsub.v1.MessageStoragePolicy
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {google.pubsub.v1.MessageStoragePolicy} MessageStoragePolicy
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
MessageStoragePolicy.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a MessageStoragePolicy message.
* @function verify
* @memberof google.pubsub.v1.MessageStoragePolicy
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
MessageStoragePolicy.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.allowedPersistenceRegions != null && message.hasOwnProperty("allowedPersistenceRegions")) {
if (!Array.isArray(message.allowedPersistenceRegions))
return "allowedPersistenceRegions: array expected";
for (var i = 0; i < message.allowedPersistenceRegions.length; ++i)
if (!$util.isString(message.allowedPersistenceRegions[i]))
return "allowedPersistenceRegions: string[] expected";
}
if (message.enforceInTransit != null && message.hasOwnProperty("enforceInTransit"))
if (typeof message.enforceInTransit !== "boolean")
return "enforceInTransit: boolean expected";
return null;
};
/**
* Creates a MessageStoragePolicy message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof google.pubsub.v1.MessageStoragePolicy
* @static
* @param {Object.<string,*>} object Plain object
* @returns {google.pubsub.v1.MessageStoragePolicy} MessageStoragePolicy
*/
MessageStoragePolicy.fromObject = function fromObject(object) {
if (object instanceof $root.google.pubsub.v1.MessageStoragePolicy)
return object;
var message = new $root.google.pubsub.v1.MessageStoragePolicy();
if (object.allowedPersistenceRegions) {
if (!Array.isArray(object.allowedPersistenceRegions))
throw TypeError(".google.pubsub.v1.MessageStoragePolicy.allowedPersistenceRegions: array expected");
message.allowedPersistenceRegions = [];
for (var i = 0; i < object.allowedPersistenceRegions.length; ++i)
message.allowedPersistenceRegions[i] = String(object.allowedPersistenceRegions[i]);
}
if (object.enforceInTransit != null)
message.enforceInTransit = Boolean(object.enforceInTransit);
return message;
};
/**
* Creates a plain object from a MessageStoragePolicy message. Also converts values to other types if specified.
* @function toObject
* @memberof google.pubsub.v1.MessageStoragePolicy
* @static
* @param {google.pubsub.v1.MessageStoragePolicy} message MessageStoragePolicy
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
MessageStoragePolicy.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.arrays || options.defaults)
object.allowedPersistenceRegions = [];
if (options.defaults)
object.enforceInTransit = false;
if (message.allowedPersistenceRegions && message.allowedPersistenceRegions.length) {
object.allowedPersistenceRegions = [];
for (var j = 0; j < message.allowedPersistenceRegions.length; ++j)
object.allowedPersistenceRegions[j] = message.allowedPersistenceRegions[j];
}
if (message.enforceInTransit != null && message.hasOwnProperty("enforceInTransit"))
object.enforceInTransit = message.enforceInTransit;
return object;
};
/**
* Converts this MessageStoragePolicy to JSON.
* @function toJSON
* @memberof google.pubsub.v1.MessageStoragePolicy
* @instance
* @returns {Object.<string,*>} JSON object
*/
MessageStoragePolicy.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for MessageStoragePolicy
* @function getTypeUrl
* @memberof google.pubsub.v1.MessageStoragePolicy
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
MessageStoragePolicy.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/google.pubsub.v1.MessageStoragePolicy";
};
return MessageStoragePolicy;
})();
v1.SchemaSettings = (function() {
/**
* Properties of a SchemaSettings.
* @memberof google.pubsub.v1
* @interface ISchemaSettings
* @property {string|null} [schema] SchemaSettings schema
* @property {google.pubsub.v1.Encoding|null} [encoding] SchemaSettings encoding
* @property {string|null} [firstRevisionId] SchemaSettings firstRevisionId
* @property {string|null} [lastRevisionId] SchemaSettings lastRevisionId
*/
/**
* Constructs a new SchemaSettings.
* @memberof google.pubsub.v1
* @classdesc Represents a SchemaSettings.
* @implements ISchemaSettings
* @constructor
* @param {google.pubsub.v1.ISchemaSettings=} [properties] Properties to set
*/
function SchemaSettings(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]];
}
/**
* SchemaSettings schema.
* @member {string} schema
* @memberof google.pubsub.v1.SchemaSettings
* @instance
*/
SchemaSettings.prototype.schema = "";
/**
* SchemaSettings encoding.
* @member {google.pubsub.v1.Encoding} encoding
* @memberof google.pubsub.v1.SchemaSettings
* @instance
*/
SchemaSettings.prototype.encoding = 0;
/**
* SchemaSettings firstRevisionId.
* @member {string} firstRevisionId
* @memberof google.pubsub.v1.SchemaSettings
* @instance
*/
SchemaSettings.prototype.firstRevisionId = "";
/**
* SchemaSettings lastRevisionId.
* @member {string} lastRevisionId
* @memberof google.pubsub.v1.SchemaSettings
* @instance
*/
SchemaSettings.prototype.lastRevisionId = "";
/**
* Creates a new SchemaSettings instance using the specified properties.
* @function create
* @memberof google.pubsub.v1.SchemaSettings
* @static
* @param {google.pubsub.v1.ISchemaSettings=} [properties] Properties to set
* @returns {google.pubsub.v1.SchemaSettings} SchemaSettings instance
*/
SchemaSettings.create = function create(properties) {
return new SchemaSettings(properties);
};
/**
* Encodes the specified SchemaSettings message. Does not implicitly {@link google.pubsub.v1.SchemaSettings.verify|verify} messages.
* @function encode
* @memberof google.pubsub.v1.SchemaSettings
* @static
* @param {google.pubsub.v1.ISchemaSettings} message SchemaSettings message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
SchemaSettings.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.schema != null && Object.hasOwnProperty.call(message, "schema"))
writer.uint32(/* id 1, wireType 2 =*/10).string(message.schema);
if (message.encoding != null && Object.hasOwnProperty.call(message, "encoding"))
writer.uint32(/* id 2, wireType 0 =*/16).int32(message.encoding);
if (message.firstRevisionId != null && Object.hasOwnProperty.call(message, "firstRevisionId"))
writer.uint32(/* id 3, wireType 2 =*/26).string(message.firstRevisionId);
if (message.lastRevisionId != null && Object.hasOwnProperty.call(message, "lastRevisionId"))
writer.uint32(/* id 4, wireType 2 =*/34).string(message.lastRevisionId);
return writer;
};
/**
* Encodes the specified SchemaSettings message, length delimited. Does not implicitly {@link google.pubsub.v1.SchemaSettings.verify|verify} messages.
* @function encodeDelimited
* @memberof google.pubsub.v1.SchemaSettings
* @static
* @param {google.pubsub.v1.ISchemaSettings} message SchemaSettings message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
SchemaSettings.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a SchemaSettings message from the specified reader or buffer.
* @function decode
* @memberof google.pubsub.v1.SchemaSettings
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {google.pubsub.v1.SchemaSettings} SchemaSettings
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
SchemaSettings.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.pubsub.v1.SchemaSettings();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
message.schema = reader.string();
break;
}
case 2: {
message.encoding = reader.int32();
break;
}
case 3: {
message.firstRevisionId = reader.string();
break;
}
case 4: {
message.lastRevisionId = reader.string();
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a SchemaSettings message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof google.pubsub.v1.SchemaSettings
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {google.pubsub.v1.SchemaSettings} SchemaSettings
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
SchemaSettings.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a SchemaSettings message.
* @function verify
* @memberof google.pubsub.v1.SchemaSettings
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
SchemaSettings.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.schema != null && message.hasOwnProperty("schema"))
if (!$util.isString(message.schema))
return "schema: string expected";
if (message.encoding != null && message.hasOwnProperty("encoding"))
switch (message.encoding) {
default:
return "encoding: enum value expected";
case 0:
case 1:
case 2:
break;
}
if (message.firstRevisionId != null && message.hasOwnProperty("firstRevisionId"))
if (!$util.isString(message.firstRevisionId))
return "firstRevisionId: string expected";
if (message.lastRevisionId != null && message.hasOwnProperty("lastRevisionId"))
if (!$util.isString(message.lastRevisionId))
return "lastRevisionId: string expected";
return null;
};
/**
* Creates a SchemaSettings message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof google.pubsub.v1.SchemaSettings
* @static
* @param {Object.<string,*>} object Plain object
* @returns {google.pubsub.v1.SchemaSettings} SchemaSettings
*/
SchemaSettings.fromObject = function fromObject(object) {
if (object instanceof $root.google.pubsub.v1.SchemaSettings)
return object;
var message = new $root.google.pubsub.v1.SchemaSettings();
if (object.schema != null)
message.schema = String(object.schema);
switch (object.encoding) {
default:
if (typeof object.encoding === "number") {
message.encoding = object.encoding;
break;
}
break;
case "ENCODING_UNSPECIFIED":
case 0:
message.encoding = 0;
break;
case "JSON":
case 1:
message.encoding = 1;
break;
case "BINARY":
case 2:
message.encoding = 2;
break;
}
if (object.firstRevisionId != null)
message.firstRevisionId = String(object.firstRevisionId);
if (object.lastRevisionId != null)
message.lastRevisionId = String(object.lastRevisionId);
return message;
};
/**
* Creates a plain object from a SchemaSettings message. Also converts values to other types if specified.
* @function toObject
* @memberof google.pubsub.v1.SchemaSettings
* @static
* @param {google.pubsub.v1.SchemaSettings} message SchemaSettings
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
SchemaSettings.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.defaults) {
object.schema = "";
object.encoding = options.enums === String ? "ENCODING_UNSPECIFIED" : 0;
object.firstRevisionId = "";
object.lastRevisionId = "";
}
if (message.schema != null && message.hasOwnProperty("schema"))
object.schema = message.schema;
if (message.encoding != null && message.hasOwnProperty("encoding"))
object.encoding = options.enums === String ? $root.google.pubsub.v1.Encoding[message.encoding] === undefined ? message.encoding : $root.google.pubsub.v1.Encoding[message.encoding] : message.encoding;
if (message.firstRevisionId != null && message.ha