UNPKG

@google-cloud/service-control

Version:
1,013 lines (941 loc) 2.03 MB
// Copyright 2025 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_service_control_protos || ($protobuf.roots._google_cloud_service_control_protos = {}); $root.google = (function() { /** * Namespace google. * @exports google * @namespace */ var google = {}; google.protobuf = (function() { /** * Namespace protobuf. * @memberof google * @namespace */ var protobuf = {}; protobuf.Any = (function() { /** * Properties of an Any. * @memberof google.protobuf * @interface IAny * @property {string|null} [type_url] Any type_url * @property {Uint8Array|null} [value] Any value */ /** * Constructs a new Any. * @memberof google.protobuf * @classdesc Represents an Any. * @implements IAny * @constructor * @param {google.protobuf.IAny=} [properties] Properties to set */ function Any(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]]; } /** * Any type_url. * @member {string} type_url * @memberof google.protobuf.Any * @instance */ Any.prototype.type_url = ""; /** * Any value. * @member {Uint8Array} value * @memberof google.protobuf.Any * @instance */ Any.prototype.value = $util.newBuffer([]); /** * Creates a new Any instance using the specified properties. * @function create * @memberof google.protobuf.Any * @static * @param {google.protobuf.IAny=} [properties] Properties to set * @returns {google.protobuf.Any} Any instance */ Any.create = function create(properties) { return new Any(properties); }; /** * Encodes the specified Any message. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. * @function encode * @memberof google.protobuf.Any * @static * @param {google.protobuf.IAny} message Any message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Any.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.type_url != null && Object.hasOwnProperty.call(message, "type_url")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.type_url); if (message.value != null && Object.hasOwnProperty.call(message, "value")) writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.value); return writer; }; /** * Encodes the specified Any message, length delimited. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. * @function encodeDelimited * @memberof google.protobuf.Any * @static * @param {google.protobuf.IAny} message Any message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Any.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes an Any message from the specified reader or buffer. * @function decode * @memberof google.protobuf.Any * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {google.protobuf.Any} Any * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Any.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.protobuf.Any(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { case 1: { message.type_url = reader.string(); break; } case 2: { message.value = reader.bytes(); break; } default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes an Any message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof google.protobuf.Any * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {google.protobuf.Any} Any * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Any.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies an Any message. * @function verify * @memberof google.protobuf.Any * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ Any.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.type_url != null && message.hasOwnProperty("type_url")) if (!$util.isString(message.type_url)) return "type_url: string expected"; if (message.value != null && message.hasOwnProperty("value")) if (!(message.value && typeof message.value.length === "number" || $util.isString(message.value))) return "value: buffer expected"; return null; }; /** * Creates an Any message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof google.protobuf.Any * @static * @param {Object.<string,*>} object Plain object * @returns {google.protobuf.Any} Any */ Any.fromObject = function fromObject(object) { if (object instanceof $root.google.protobuf.Any) return object; var message = new $root.google.protobuf.Any(); if (object.type_url != null) message.type_url = String(object.type_url); if (object.value != null) if (typeof object.value === "string") $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); else if (object.value.length >= 0) message.value = object.value; return message; }; /** * Creates a plain object from an Any message. Also converts values to other types if specified. * @function toObject * @memberof google.protobuf.Any * @static * @param {google.protobuf.Any} message Any * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ Any.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { object.type_url = ""; if (options.bytes === String) object.value = ""; else { object.value = []; if (options.bytes !== Array) object.value = $util.newBuffer(object.value); } } if (message.type_url != null && message.hasOwnProperty("type_url")) object.type_url = message.type_url; if (message.value != null && message.hasOwnProperty("value")) object.value = options.bytes === String ? $util.base64.encode(message.value, 0, message.value.length) : options.bytes === Array ? Array.prototype.slice.call(message.value) : message.value; return object; }; /** * Converts this Any to JSON. * @function toJSON * @memberof google.protobuf.Any * @instance * @returns {Object.<string,*>} JSON object */ Any.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** * Gets the default type url for Any * @function getTypeUrl * @memberof google.protobuf.Any * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ Any.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } return typeUrlPrefix + "/google.protobuf.Any"; }; return Any; })(); protobuf.Timestamp = (function() { /** * Properties of a Timestamp. * @memberof google.protobuf * @interface ITimestamp * @property {number|Long|null} [seconds] Timestamp seconds * @property {number|null} [nanos] Timestamp nanos */ /** * Constructs a new Timestamp. * @memberof google.protobuf * @classdesc Represents a Timestamp. * @implements ITimestamp * @constructor * @param {google.protobuf.ITimestamp=} [properties] Properties to set */ function Timestamp(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]]; } /** * Timestamp seconds. * @member {number|Long} seconds * @memberof google.protobuf.Timestamp * @instance */ Timestamp.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; /** * Timestamp nanos. * @member {number} nanos * @memberof google.protobuf.Timestamp * @instance */ Timestamp.prototype.nanos = 0; /** * Creates a new Timestamp instance using the specified properties. * @function create * @memberof google.protobuf.Timestamp * @static * @param {google.protobuf.ITimestamp=} [properties] Properties to set * @returns {google.protobuf.Timestamp} Timestamp instance */ Timestamp.create = function create(properties) { return new Timestamp(properties); }; /** * Encodes the specified Timestamp message. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. * @function encode * @memberof google.protobuf.Timestamp * @static * @param {google.protobuf.ITimestamp} message Timestamp message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Timestamp.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.seconds != null && Object.hasOwnProperty.call(message, "seconds")) writer.uint32(/* id 1, wireType 0 =*/8).int64(message.seconds); if (message.nanos != null && Object.hasOwnProperty.call(message, "nanos")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.nanos); return writer; }; /** * Encodes the specified Timestamp message, length delimited. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. * @function encodeDelimited * @memberof google.protobuf.Timestamp * @static * @param {google.protobuf.ITimestamp} message Timestamp message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Timestamp.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a Timestamp message from the specified reader or buffer. * @function decode * @memberof google.protobuf.Timestamp * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {google.protobuf.Timestamp} Timestamp * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Timestamp.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.protobuf.Timestamp(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { case 1: { message.seconds = reader.int64(); break; } case 2: { message.nanos = reader.int32(); break; } default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a Timestamp message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof google.protobuf.Timestamp * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {google.protobuf.Timestamp} Timestamp * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Timestamp.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a Timestamp message. * @function verify * @memberof google.protobuf.Timestamp * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ Timestamp.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.seconds != null && message.hasOwnProperty("seconds")) if (!$util.isInteger(message.seconds) && !(message.seconds && $util.isInteger(message.seconds.low) && $util.isInteger(message.seconds.high))) return "seconds: integer|Long expected"; if (message.nanos != null && message.hasOwnProperty("nanos")) if (!$util.isInteger(message.nanos)) return "nanos: integer expected"; return null; }; /** * Creates a Timestamp message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof google.protobuf.Timestamp * @static * @param {Object.<string,*>} object Plain object * @returns {google.protobuf.Timestamp} Timestamp */ Timestamp.fromObject = function fromObject(object) { if (object instanceof $root.google.protobuf.Timestamp) return object; var message = new $root.google.protobuf.Timestamp(); if (object.seconds != null) if ($util.Long) (message.seconds = $util.Long.fromValue(object.seconds)).unsigned = false; else if (typeof object.seconds === "string") message.seconds = parseInt(object.seconds, 10); else if (typeof object.seconds === "number") message.seconds = object.seconds; else if (typeof object.seconds === "object") message.seconds = new $util.LongBits(object.seconds.low >>> 0, object.seconds.high >>> 0).toNumber(); if (object.nanos != null) message.nanos = object.nanos | 0; return message; }; /** * Creates a plain object from a Timestamp message. Also converts values to other types if specified. * @function toObject * @memberof google.protobuf.Timestamp * @static * @param {google.protobuf.Timestamp} message Timestamp * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ Timestamp.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { if ($util.Long) { var long = new $util.Long(0, 0, false); object.seconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; } else object.seconds = options.longs === String ? "0" : 0; object.nanos = 0; } if (message.seconds != null && message.hasOwnProperty("seconds")) if (typeof message.seconds === "number") object.seconds = options.longs === String ? String(message.seconds) : message.seconds; else object.seconds = options.longs === String ? $util.Long.prototype.toString.call(message.seconds) : options.longs === Number ? new $util.LongBits(message.seconds.low >>> 0, message.seconds.high >>> 0).toNumber() : message.seconds; if (message.nanos != null && message.hasOwnProperty("nanos")) object.nanos = message.nanos; return object; }; /** * Converts this Timestamp to JSON. * @function toJSON * @memberof google.protobuf.Timestamp * @instance * @returns {Object.<string,*>} JSON object */ Timestamp.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** * Gets the default type url for Timestamp * @function getTypeUrl * @memberof google.protobuf.Timestamp * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ Timestamp.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } return typeUrlPrefix + "/google.protobuf.Timestamp"; }; return Timestamp; })(); protobuf.Duration = (function() { /** * Properties of a Duration. * @memberof google.protobuf * @interface IDuration * @property {number|Long|null} [seconds] Duration seconds * @property {number|null} [nanos] Duration nanos */ /** * Constructs a new Duration. * @memberof google.protobuf * @classdesc Represents a Duration. * @implements IDuration * @constructor * @param {google.protobuf.IDuration=} [properties] Properties to set */ function Duration(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]]; } /** * Duration seconds. * @member {number|Long} seconds * @memberof google.protobuf.Duration * @instance */ Duration.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; /** * Duration nanos. * @member {number} nanos * @memberof google.protobuf.Duration * @instance */ Duration.prototype.nanos = 0; /** * Creates a new Duration instance using the specified properties. * @function create * @memberof google.protobuf.Duration * @static * @param {google.protobuf.IDuration=} [properties] Properties to set * @returns {google.protobuf.Duration} Duration instance */ Duration.create = function create(properties) { return new Duration(properties); }; /** * Encodes the specified Duration message. Does not implicitly {@link google.protobuf.Duration.verify|verify} messages. * @function encode * @memberof google.protobuf.Duration * @static * @param {google.protobuf.IDuration} message Duration message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Duration.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.seconds != null && Object.hasOwnProperty.call(message, "seconds")) writer.uint32(/* id 1, wireType 0 =*/8).int64(message.seconds); if (message.nanos != null && Object.hasOwnProperty.call(message, "nanos")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.nanos); return writer; }; /** * Encodes the specified Duration message, length delimited. Does not implicitly {@link google.protobuf.Duration.verify|verify} messages. * @function encodeDelimited * @memberof google.protobuf.Duration * @static * @param {google.protobuf.IDuration} message Duration message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Duration.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a Duration message from the specified reader or buffer. * @function decode * @memberof google.protobuf.Duration * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {google.protobuf.Duration} Duration * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Duration.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.protobuf.Duration(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { case 1: { message.seconds = reader.int64(); break; } case 2: { message.nanos = reader.int32(); break; } default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a Duration message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof google.protobuf.Duration * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {google.protobuf.Duration} Duration * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Duration.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a Duration message. * @function verify * @memberof google.protobuf.Duration * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ Duration.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.seconds != null && message.hasOwnProperty("seconds")) if (!$util.isInteger(message.seconds) && !(message.seconds && $util.isInteger(message.seconds.low) && $util.isInteger(message.seconds.high))) return "seconds: integer|Long expected"; if (message.nanos != null && message.hasOwnProperty("nanos")) if (!$util.isInteger(message.nanos)) return "nanos: integer expected"; return null; }; /** * Creates a Duration message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof google.protobuf.Duration * @static * @param {Object.<string,*>} object Plain object * @returns {google.protobuf.Duration} Duration */ Duration.fromObject = function fromObject(object) { if (object instanceof $root.google.protobuf.Duration) return object; var message = new $root.google.protobuf.Duration(); if (object.seconds != null) if ($util.Long) (message.seconds = $util.Long.fromValue(object.seconds)).unsigned = false; else if (typeof object.seconds === "string") message.seconds = parseInt(object.seconds, 10); else if (typeof object.seconds === "number") message.seconds = object.seconds; else if (typeof object.seconds === "object") message.seconds = new $util.LongBits(object.seconds.low >>> 0, object.seconds.high >>> 0).toNumber(); if (object.nanos != null) message.nanos = object.nanos | 0; return message; }; /** * Creates a plain object from a Duration message. Also converts values to other types if specified. * @function toObject * @memberof google.protobuf.Duration * @static * @param {google.protobuf.Duration} message Duration * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ Duration.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { if ($util.Long) { var long = new $util.Long(0, 0, false); object.seconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; } else object.seconds = options.longs === String ? "0" : 0; object.nanos = 0; } if (message.seconds != null && message.hasOwnProperty("seconds")) if (typeof message.seconds === "number") object.seconds = options.longs === String ? String(message.seconds) : message.seconds; else object.seconds = options.longs === String ? $util.Long.prototype.toString.call(message.seconds) : options.longs === Number ? new $util.LongBits(message.seconds.low >>> 0, message.seconds.high >>> 0).toNumber() : message.seconds; if (message.nanos != null && message.hasOwnProperty("nanos")) object.nanos = message.nanos; return object; }; /** * Converts this Duration to JSON. * @function toJSON * @memberof google.protobuf.Duration * @instance * @returns {Object.<string,*>} JSON object */ Duration.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** * Gets the default type url for Duration * @function getTypeUrl * @memberof google.protobuf.Duration * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ Duration.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } return typeUrlPrefix + "/google.protobuf.Duration"; }; return Duration; })(); protobuf.Struct = (function() { /** * Properties of a Struct. * @memberof google.protobuf * @interface IStruct * @property {Object.<string,google.protobuf.IValue>|null} [fields] Struct fields */ /** * Constructs a new Struct. * @memberof google.protobuf * @classdesc Represents a Struct. * @implements IStruct * @constructor * @param {google.protobuf.IStruct=} [properties] Properties to set */ function Struct(properties) { this.fields = {}; 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]]; } /** * Struct fields. * @member {Object.<string,google.protobuf.IValue>} fields * @memberof google.protobuf.Struct * @instance */ Struct.prototype.fields = $util.emptyObject; /** * Creates a new Struct instance using the specified properties. * @function create * @memberof google.protobuf.Struct * @static * @param {google.protobuf.IStruct=} [properties] Properties to set * @returns {google.protobuf.Struct} Struct instance */ Struct.create = function create(properties) { return new Struct(properties); }; /** * Encodes the specified Struct message. Does not implicitly {@link google.protobuf.Struct.verify|verify} messages. * @function encode * @memberof google.protobuf.Struct * @static * @param {google.protobuf.IStruct} message Struct message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Struct.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.fields != null && Object.hasOwnProperty.call(message, "fields")) for (var keys = Object.keys(message.fields), i = 0; i < keys.length; ++i) { writer.uint32(/* id 1, wireType 2 =*/10).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); $root.google.protobuf.Value.encode(message.fields[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); } return writer; }; /** * Encodes the specified Struct message, length delimited. Does not implicitly {@link google.protobuf.Struct.verify|verify} messages. * @function encodeDelimited * @memberof google.protobuf.Struct * @static * @param {google.protobuf.IStruct} message Struct message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Struct.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a Struct message from the specified reader or buffer. * @function decode * @memberof google.protobuf.Struct * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {google.protobuf.Struct} Struct * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Struct.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.protobuf.Struct(), key, value; while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { case 1: { if (message.fields === $util.emptyObject) message.fields = {}; var end2 = reader.uint32() + reader.pos; key = ""; value = null; while (reader.pos < end2) { var tag2 = reader.uint32(); switch (tag2 >>> 3) { case 1: key = reader.string(); break; case 2: value = $root.google.protobuf.Value.decode(reader, reader.uint32()); break; default: reader.skipType(tag2 & 7); break; } } message.fields[key] = value; break; } default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a Struct message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof google.protobuf.Struct * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {google.protobuf.Struct} Struct * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Struct.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a Struct message. * @function verify * @memberof google.protobuf.Struct * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ Struct.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.fields != null && message.hasOwnProperty("fields")) { if (!$util.isObject(message.fields)) return "fields: object expected"; var key = Object.keys(message.fields); for (var i = 0; i < key.length; ++i) { var error = $root.google.protobuf.Value.verify(message.fields[key[i]]); if (error) return "fields." + error; } } return null; }; /** * Creates a Struct message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof google.protobuf.Struct * @static * @param {Object.<string,*>} object Plain object * @returns {google.protobuf.Struct} Struct */ Struct.fromObject = function fromObject(object) { if (object instanceof $root.google.protobuf.Struct) return object; var message = new $root.google.protobuf.Struct(); if (object.fields) { if (typeof object.fields !== "object") throw TypeError(".google.protobuf.Struct.fields: object expected"); message.fields = {}; for (var keys = Object.keys(object.fields), i = 0; i < keys.length; ++i) { if (typeof object.fields[keys[i]] !== "object") throw TypeError(".google.protobuf.Struct.fields: object expected"); message.fields[keys[i]] = $root.google.protobuf.Value.fromObject(object.fields[keys[i]]); } } return message; }; /** * Creates a plain object from a Struct message. Also converts values to other types if specified. * @function toObject * @memberof google.protobuf.Struct * @static * @param {google.protobuf.Struct} message Struct * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ Struct.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.objects || options.defaults) object.fields = {}; var keys2; if (message.fields && (keys2 = Object.keys(message.fields)).length) { object.fields = {}; for (var j = 0; j < keys2.length; ++j) object.fields[keys2[j]] = $root.google.protobuf.Value.toObject(message.fields[keys2[j]], options); } return object; }; /** * Converts this Struct to JSON. * @function toJSON * @memberof google.protobuf.Struct * @instance * @returns {Object.<string,*>} JSON object */ Struct.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** * Gets the default type url for Struct * @function getTypeUrl * @memberof google.protobuf.Struct * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ Struct.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix