@google-cloud/monitoring
Version:
Stackdriver Monitoring API client for Node.js
840 lines (790 loc) • 4.24 MB
JavaScript
// 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_monitoring_protos || ($protobuf.roots._google_cloud_monitoring_protos = {});
$root.google = (function() {
/**
* Namespace google.
* @exports google
* @namespace
*/
var google = {};
google.monitoring = (function() {
/**
* Namespace monitoring.
* @memberof google
* @namespace
*/
var monitoring = {};
monitoring.v3 = (function() {
/**
* Namespace v3.
* @memberof google.monitoring
* @namespace
*/
var v3 = {};
v3.AlertPolicy = (function() {
/**
* Properties of an AlertPolicy.
* @memberof google.monitoring.v3
* @interface IAlertPolicy
* @property {string|null} [name] AlertPolicy name
* @property {string|null} [displayName] AlertPolicy displayName
* @property {google.monitoring.v3.AlertPolicy.IDocumentation|null} [documentation] AlertPolicy documentation
* @property {Object.<string,string>|null} [userLabels] AlertPolicy userLabels
* @property {Array.<google.monitoring.v3.AlertPolicy.ICondition>|null} [conditions] AlertPolicy conditions
* @property {google.monitoring.v3.AlertPolicy.ConditionCombinerType|null} [combiner] AlertPolicy combiner
* @property {google.protobuf.IBoolValue|null} [enabled] AlertPolicy enabled
* @property {google.rpc.IStatus|null} [validity] AlertPolicy validity
* @property {Array.<string>|null} [notificationChannels] AlertPolicy notificationChannels
* @property {google.monitoring.v3.IMutationRecord|null} [creationRecord] AlertPolicy creationRecord
* @property {google.monitoring.v3.IMutationRecord|null} [mutationRecord] AlertPolicy mutationRecord
* @property {google.monitoring.v3.AlertPolicy.IAlertStrategy|null} [alertStrategy] AlertPolicy alertStrategy
* @property {google.monitoring.v3.AlertPolicy.Severity|null} [severity] AlertPolicy severity
*/
/**
* Constructs a new AlertPolicy.
* @memberof google.monitoring.v3
* @classdesc Represents an AlertPolicy.
* @implements IAlertPolicy
* @constructor
* @param {google.monitoring.v3.IAlertPolicy=} [properties] Properties to set
*/
function AlertPolicy(properties) {
this.userLabels = {};
this.conditions = [];
this.notificationChannels = [];
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]];
}
/**
* AlertPolicy name.
* @member {string} name
* @memberof google.monitoring.v3.AlertPolicy
* @instance
*/
AlertPolicy.prototype.name = "";
/**
* AlertPolicy displayName.
* @member {string} displayName
* @memberof google.monitoring.v3.AlertPolicy
* @instance
*/
AlertPolicy.prototype.displayName = "";
/**
* AlertPolicy documentation.
* @member {google.monitoring.v3.AlertPolicy.IDocumentation|null|undefined} documentation
* @memberof google.monitoring.v3.AlertPolicy
* @instance
*/
AlertPolicy.prototype.documentation = null;
/**
* AlertPolicy userLabels.
* @member {Object.<string,string>} userLabels
* @memberof google.monitoring.v3.AlertPolicy
* @instance
*/
AlertPolicy.prototype.userLabels = $util.emptyObject;
/**
* AlertPolicy conditions.
* @member {Array.<google.monitoring.v3.AlertPolicy.ICondition>} conditions
* @memberof google.monitoring.v3.AlertPolicy
* @instance
*/
AlertPolicy.prototype.conditions = $util.emptyArray;
/**
* AlertPolicy combiner.
* @member {google.monitoring.v3.AlertPolicy.ConditionCombinerType} combiner
* @memberof google.monitoring.v3.AlertPolicy
* @instance
*/
AlertPolicy.prototype.combiner = 0;
/**
* AlertPolicy enabled.
* @member {google.protobuf.IBoolValue|null|undefined} enabled
* @memberof google.monitoring.v3.AlertPolicy
* @instance
*/
AlertPolicy.prototype.enabled = null;
/**
* AlertPolicy validity.
* @member {google.rpc.IStatus|null|undefined} validity
* @memberof google.monitoring.v3.AlertPolicy
* @instance
*/
AlertPolicy.prototype.validity = null;
/**
* AlertPolicy notificationChannels.
* @member {Array.<string>} notificationChannels
* @memberof google.monitoring.v3.AlertPolicy
* @instance
*/
AlertPolicy.prototype.notificationChannels = $util.emptyArray;
/**
* AlertPolicy creationRecord.
* @member {google.monitoring.v3.IMutationRecord|null|undefined} creationRecord
* @memberof google.monitoring.v3.AlertPolicy
* @instance
*/
AlertPolicy.prototype.creationRecord = null;
/**
* AlertPolicy mutationRecord.
* @member {google.monitoring.v3.IMutationRecord|null|undefined} mutationRecord
* @memberof google.monitoring.v3.AlertPolicy
* @instance
*/
AlertPolicy.prototype.mutationRecord = null;
/**
* AlertPolicy alertStrategy.
* @member {google.monitoring.v3.AlertPolicy.IAlertStrategy|null|undefined} alertStrategy
* @memberof google.monitoring.v3.AlertPolicy
* @instance
*/
AlertPolicy.prototype.alertStrategy = null;
/**
* AlertPolicy severity.
* @member {google.monitoring.v3.AlertPolicy.Severity} severity
* @memberof google.monitoring.v3.AlertPolicy
* @instance
*/
AlertPolicy.prototype.severity = 0;
/**
* Creates a new AlertPolicy instance using the specified properties.
* @function create
* @memberof google.monitoring.v3.AlertPolicy
* @static
* @param {google.monitoring.v3.IAlertPolicy=} [properties] Properties to set
* @returns {google.monitoring.v3.AlertPolicy} AlertPolicy instance
*/
AlertPolicy.create = function create(properties) {
return new AlertPolicy(properties);
};
/**
* Encodes the specified AlertPolicy message. Does not implicitly {@link google.monitoring.v3.AlertPolicy.verify|verify} messages.
* @function encode
* @memberof google.monitoring.v3.AlertPolicy
* @static
* @param {google.monitoring.v3.IAlertPolicy} message AlertPolicy message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
AlertPolicy.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.name != null && Object.hasOwnProperty.call(message, "name"))
writer.uint32(/* id 1, wireType 2 =*/10).string(message.name);
if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName"))
writer.uint32(/* id 2, wireType 2 =*/18).string(message.displayName);
if (message.combiner != null && Object.hasOwnProperty.call(message, "combiner"))
writer.uint32(/* id 6, wireType 0 =*/48).int32(message.combiner);
if (message.creationRecord != null && Object.hasOwnProperty.call(message, "creationRecord"))
$root.google.monitoring.v3.MutationRecord.encode(message.creationRecord, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim();
if (message.mutationRecord != null && Object.hasOwnProperty.call(message, "mutationRecord"))
$root.google.monitoring.v3.MutationRecord.encode(message.mutationRecord, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim();
if (message.conditions != null && message.conditions.length)
for (var i = 0; i < message.conditions.length; ++i)
$root.google.monitoring.v3.AlertPolicy.Condition.encode(message.conditions[i], writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim();
if (message.documentation != null && Object.hasOwnProperty.call(message, "documentation"))
$root.google.monitoring.v3.AlertPolicy.Documentation.encode(message.documentation, writer.uint32(/* id 13, wireType 2 =*/106).fork()).ldelim();
if (message.notificationChannels != null && message.notificationChannels.length)
for (var i = 0; i < message.notificationChannels.length; ++i)
writer.uint32(/* id 14, wireType 2 =*/114).string(message.notificationChannels[i]);
if (message.userLabels != null && Object.hasOwnProperty.call(message, "userLabels"))
for (var keys = Object.keys(message.userLabels), i = 0; i < keys.length; ++i)
writer.uint32(/* id 16, wireType 2 =*/130).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.userLabels[keys[i]]).ldelim();
if (message.enabled != null && Object.hasOwnProperty.call(message, "enabled"))
$root.google.protobuf.BoolValue.encode(message.enabled, writer.uint32(/* id 17, wireType 2 =*/138).fork()).ldelim();
if (message.validity != null && Object.hasOwnProperty.call(message, "validity"))
$root.google.rpc.Status.encode(message.validity, writer.uint32(/* id 18, wireType 2 =*/146).fork()).ldelim();
if (message.alertStrategy != null && Object.hasOwnProperty.call(message, "alertStrategy"))
$root.google.monitoring.v3.AlertPolicy.AlertStrategy.encode(message.alertStrategy, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim();
if (message.severity != null && Object.hasOwnProperty.call(message, "severity"))
writer.uint32(/* id 22, wireType 0 =*/176).int32(message.severity);
return writer;
};
/**
* Encodes the specified AlertPolicy message, length delimited. Does not implicitly {@link google.monitoring.v3.AlertPolicy.verify|verify} messages.
* @function encodeDelimited
* @memberof google.monitoring.v3.AlertPolicy
* @static
* @param {google.monitoring.v3.IAlertPolicy} message AlertPolicy message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
AlertPolicy.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes an AlertPolicy message from the specified reader or buffer.
* @function decode
* @memberof google.monitoring.v3.AlertPolicy
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {google.monitoring.v3.AlertPolicy} AlertPolicy
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
AlertPolicy.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.monitoring.v3.AlertPolicy(), key, value;
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
message.name = reader.string();
break;
}
case 2: {
message.displayName = reader.string();
break;
}
case 13: {
message.documentation = $root.google.monitoring.v3.AlertPolicy.Documentation.decode(reader, reader.uint32());
break;
}
case 16: {
if (message.userLabels === $util.emptyObject)
message.userLabels = {};
var end2 = reader.uint32() + reader.pos;
key = "";
value = "";
while (reader.pos < end2) {
var tag2 = reader.uint32();
switch (tag2 >>> 3) {
case 1:
key = reader.string();
break;
case 2:
value = reader.string();
break;
default:
reader.skipType(tag2 & 7);
break;
}
}
message.userLabels[key] = value;
break;
}
case 12: {
if (!(message.conditions && message.conditions.length))
message.conditions = [];
message.conditions.push($root.google.monitoring.v3.AlertPolicy.Condition.decode(reader, reader.uint32()));
break;
}
case 6: {
message.combiner = reader.int32();
break;
}
case 17: {
message.enabled = $root.google.protobuf.BoolValue.decode(reader, reader.uint32());
break;
}
case 18: {
message.validity = $root.google.rpc.Status.decode(reader, reader.uint32());
break;
}
case 14: {
if (!(message.notificationChannels && message.notificationChannels.length))
message.notificationChannels = [];
message.notificationChannels.push(reader.string());
break;
}
case 10: {
message.creationRecord = $root.google.monitoring.v3.MutationRecord.decode(reader, reader.uint32());
break;
}
case 11: {
message.mutationRecord = $root.google.monitoring.v3.MutationRecord.decode(reader, reader.uint32());
break;
}
case 21: {
message.alertStrategy = $root.google.monitoring.v3.AlertPolicy.AlertStrategy.decode(reader, reader.uint32());
break;
}
case 22: {
message.severity = reader.int32();
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes an AlertPolicy message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof google.monitoring.v3.AlertPolicy
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {google.monitoring.v3.AlertPolicy} AlertPolicy
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
AlertPolicy.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies an AlertPolicy message.
* @function verify
* @memberof google.monitoring.v3.AlertPolicy
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
AlertPolicy.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.name != null && message.hasOwnProperty("name"))
if (!$util.isString(message.name))
return "name: string expected";
if (message.displayName != null && message.hasOwnProperty("displayName"))
if (!$util.isString(message.displayName))
return "displayName: string expected";
if (message.documentation != null && message.hasOwnProperty("documentation")) {
var error = $root.google.monitoring.v3.AlertPolicy.Documentation.verify(message.documentation);
if (error)
return "documentation." + error;
}
if (message.userLabels != null && message.hasOwnProperty("userLabels")) {
if (!$util.isObject(message.userLabels))
return "userLabels: object expected";
var key = Object.keys(message.userLabels);
for (var i = 0; i < key.length; ++i)
if (!$util.isString(message.userLabels[key[i]]))
return "userLabels: string{k:string} expected";
}
if (message.conditions != null && message.hasOwnProperty("conditions")) {
if (!Array.isArray(message.conditions))
return "conditions: array expected";
for (var i = 0; i < message.conditions.length; ++i) {
var error = $root.google.monitoring.v3.AlertPolicy.Condition.verify(message.conditions[i]);
if (error)
return "conditions." + error;
}
}
if (message.combiner != null && message.hasOwnProperty("combiner"))
switch (message.combiner) {
default:
return "combiner: enum value expected";
case 0:
case 1:
case 2:
case 3:
break;
}
if (message.enabled != null && message.hasOwnProperty("enabled")) {
var error = $root.google.protobuf.BoolValue.verify(message.enabled);
if (error)
return "enabled." + error;
}
if (message.validity != null && message.hasOwnProperty("validity")) {
var error = $root.google.rpc.Status.verify(message.validity);
if (error)
return "validity." + error;
}
if (message.notificationChannels != null && message.hasOwnProperty("notificationChannels")) {
if (!Array.isArray(message.notificationChannels))
return "notificationChannels: array expected";
for (var i = 0; i < message.notificationChannels.length; ++i)
if (!$util.isString(message.notificationChannels[i]))
return "notificationChannels: string[] expected";
}
if (message.creationRecord != null && message.hasOwnProperty("creationRecord")) {
var error = $root.google.monitoring.v3.MutationRecord.verify(message.creationRecord);
if (error)
return "creationRecord." + error;
}
if (message.mutationRecord != null && message.hasOwnProperty("mutationRecord")) {
var error = $root.google.monitoring.v3.MutationRecord.verify(message.mutationRecord);
if (error)
return "mutationRecord." + error;
}
if (message.alertStrategy != null && message.hasOwnProperty("alertStrategy")) {
var error = $root.google.monitoring.v3.AlertPolicy.AlertStrategy.verify(message.alertStrategy);
if (error)
return "alertStrategy." + error;
}
if (message.severity != null && message.hasOwnProperty("severity"))
switch (message.severity) {
default:
return "severity: enum value expected";
case 0:
case 1:
case 2:
case 3:
break;
}
return null;
};
/**
* Creates an AlertPolicy message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof google.monitoring.v3.AlertPolicy
* @static
* @param {Object.<string,*>} object Plain object
* @returns {google.monitoring.v3.AlertPolicy} AlertPolicy
*/
AlertPolicy.fromObject = function fromObject(object) {
if (object instanceof $root.google.monitoring.v3.AlertPolicy)
return object;
var message = new $root.google.monitoring.v3.AlertPolicy();
if (object.name != null)
message.name = String(object.name);
if (object.displayName != null)
message.displayName = String(object.displayName);
if (object.documentation != null) {
if (typeof object.documentation !== "object")
throw TypeError(".google.monitoring.v3.AlertPolicy.documentation: object expected");
message.documentation = $root.google.monitoring.v3.AlertPolicy.Documentation.fromObject(object.documentation);
}
if (object.userLabels) {
if (typeof object.userLabels !== "object")
throw TypeError(".google.monitoring.v3.AlertPolicy.userLabels: object expected");
message.userLabels = {};
for (var keys = Object.keys(object.userLabels), i = 0; i < keys.length; ++i)
message.userLabels[keys[i]] = String(object.userLabels[keys[i]]);
}
if (object.conditions) {
if (!Array.isArray(object.conditions))
throw TypeError(".google.monitoring.v3.AlertPolicy.conditions: array expected");
message.conditions = [];
for (var i = 0; i < object.conditions.length; ++i) {
if (typeof object.conditions[i] !== "object")
throw TypeError(".google.monitoring.v3.AlertPolicy.conditions: object expected");
message.conditions[i] = $root.google.monitoring.v3.AlertPolicy.Condition.fromObject(object.conditions[i]);
}
}
switch (object.combiner) {
default:
if (typeof object.combiner === "number") {
message.combiner = object.combiner;
break;
}
break;
case "COMBINE_UNSPECIFIED":
case 0:
message.combiner = 0;
break;
case "AND":
case 1:
message.combiner = 1;
break;
case "OR":
case 2:
message.combiner = 2;
break;
case "AND_WITH_MATCHING_RESOURCE":
case 3:
message.combiner = 3;
break;
}
if (object.enabled != null) {
if (typeof object.enabled !== "object")
throw TypeError(".google.monitoring.v3.AlertPolicy.enabled: object expected");
message.enabled = $root.google.protobuf.BoolValue.fromObject(object.enabled);
}
if (object.validity != null) {
if (typeof object.validity !== "object")
throw TypeError(".google.monitoring.v3.AlertPolicy.validity: object expected");
message.validity = $root.google.rpc.Status.fromObject(object.validity);
}
if (object.notificationChannels) {
if (!Array.isArray(object.notificationChannels))
throw TypeError(".google.monitoring.v3.AlertPolicy.notificationChannels: array expected");
message.notificationChannels = [];
for (var i = 0; i < object.notificationChannels.length; ++i)
message.notificationChannels[i] = String(object.notificationChannels[i]);
}
if (object.creationRecord != null) {
if (typeof object.creationRecord !== "object")
throw TypeError(".google.monitoring.v3.AlertPolicy.creationRecord: object expected");
message.creationRecord = $root.google.monitoring.v3.MutationRecord.fromObject(object.creationRecord);
}
if (object.mutationRecord != null) {
if (typeof object.mutationRecord !== "object")
throw TypeError(".google.monitoring.v3.AlertPolicy.mutationRecord: object expected");
message.mutationRecord = $root.google.monitoring.v3.MutationRecord.fromObject(object.mutationRecord);
}
if (object.alertStrategy != null) {
if (typeof object.alertStrategy !== "object")
throw TypeError(".google.monitoring.v3.AlertPolicy.alertStrategy: object expected");
message.alertStrategy = $root.google.monitoring.v3.AlertPolicy.AlertStrategy.fromObject(object.alertStrategy);
}
switch (object.severity) {
default:
if (typeof object.severity === "number") {
message.severity = object.severity;
break;
}
break;
case "SEVERITY_UNSPECIFIED":
case 0:
message.severity = 0;
break;
case "CRITICAL":
case 1:
message.severity = 1;
break;
case "ERROR":
case 2:
message.severity = 2;
break;
case "WARNING":
case 3:
message.severity = 3;
break;
}
return message;
};
/**
* Creates a plain object from an AlertPolicy message. Also converts values to other types if specified.
* @function toObject
* @memberof google.monitoring.v3.AlertPolicy
* @static
* @param {google.monitoring.v3.AlertPolicy} message AlertPolicy
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
AlertPolicy.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.arrays || options.defaults) {
object.conditions = [];
object.notificationChannels = [];
}
if (options.objects || options.defaults)
object.userLabels = {};
if (options.defaults) {
object.name = "";
object.displayName = "";
object.combiner = options.enums === String ? "COMBINE_UNSPECIFIED" : 0;
object.creationRecord = null;
object.mutationRecord = null;
object.documentation = null;
object.enabled = null;
object.validity = null;
object.alertStrategy = null;
object.severity = options.enums === String ? "SEVERITY_UNSPECIFIED" : 0;
}
if (message.name != null && message.hasOwnProperty("name"))
object.name = message.name;
if (message.displayName != null && message.hasOwnProperty("displayName"))
object.displayName = message.displayName;
if (message.combiner != null && message.hasOwnProperty("combiner"))
object.combiner = options.enums === String ? $root.google.monitoring.v3.AlertPolicy.ConditionCombinerType[message.combiner] === undefined ? message.combiner : $root.google.monitoring.v3.AlertPolicy.ConditionCombinerType[message.combiner] : message.combiner;
if (message.creationRecord != null && message.hasOwnProperty("creationRecord"))
object.creationRecord = $root.google.monitoring.v3.MutationRecord.toObject(message.creationRecord, options);
if (message.mutationRecord != null && message.hasOwnProperty("mutationRecord"))
object.mutationRecord = $root.google.monitoring.v3.MutationRecord.toObject(message.mutationRecord, options);
if (message.conditions && message.conditions.length) {
object.conditions = [];
for (var j = 0; j < message.conditions.length; ++j)
object.conditions[j] = $root.google.monitoring.v3.AlertPolicy.Condition.toObject(message.conditions[j], options);
}
if (message.documentation != null && message.hasOwnProperty("documentation"))
object.documentation = $root.google.monitoring.v3.AlertPolicy.Documentation.toObject(message.documentation, options);
if (message.notificationChannels && message.notificationChannels.length) {
object.notificationChannels = [];
for (var j = 0; j < message.notificationChannels.length; ++j)
object.notificationChannels[j] = message.notificationChannels[j];
}
var keys2;
if (message.userLabels && (keys2 = Object.keys(message.userLabels)).length) {
object.userLabels = {};
for (var j = 0; j < keys2.length; ++j)
object.userLabels[keys2[j]] = message.userLabels[keys2[j]];
}
if (message.enabled != null && message.hasOwnProperty("enabled"))
object.enabled = $root.google.protobuf.BoolValue.toObject(message.enabled, options);
if (message.validity != null && message.hasOwnProperty("validity"))
object.validity = $root.google.rpc.Status.toObject(message.validity, options);
if (message.alertStrategy != null && message.hasOwnProperty("alertStrategy"))
object.alertStrategy = $root.google.monitoring.v3.AlertPolicy.AlertStrategy.toObject(message.alertStrategy, options);
if (message.severity != null && message.hasOwnProperty("severity"))
object.severity = options.enums === String ? $root.google.monitoring.v3.AlertPolicy.Severity[message.severity] === undefined ? message.severity : $root.google.monitoring.v3.AlertPolicy.Severity[message.severity] : message.severity;
return object;
};
/**
* Converts this AlertPolicy to JSON.
* @function toJSON
* @memberof google.monitoring.v3.AlertPolicy
* @instance
* @returns {Object.<string,*>} JSON object
*/
AlertPolicy.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for AlertPolicy
* @function getTypeUrl
* @memberof google.monitoring.v3.AlertPolicy
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
AlertPolicy.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/google.monitoring.v3.AlertPolicy";
};
AlertPolicy.Documentation = (function() {
/**
* Properties of a Documentation.
* @memberof google.monitoring.v3.AlertPolicy
* @interface IDocumentation
* @property {string|null} [content] Documentation content
* @property {string|null} [mimeType] Documentation mimeType
* @property {string|null} [subject] Documentation subject
* @property {Array.<google.monitoring.v3.AlertPolicy.Documentation.ILink>|null} [links] Documentation links
*/
/**
* Constructs a new Documentation.
* @memberof google.monitoring.v3.AlertPolicy
* @classdesc Represents a Documentation.
* @implements IDocumentation
* @constructor
* @param {google.monitoring.v3.AlertPolicy.IDocumentation=} [properties] Properties to set
*/
function Documentation(properties) {
this.links = [];
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]];
}
/**
* Documentation content.
* @member {string} content
* @memberof google.monitoring.v3.AlertPolicy.Documentation
* @instance
*/
Documentation.prototype.content = "";
/**
* Documentation mimeType.
* @member {string} mimeType
* @memberof google.monitoring.v3.AlertPolicy.Documentation
* @instance
*/
Documentation.prototype.mimeType = "";
/**
* Documentation subject.
* @member {string} subject
* @memberof google.monitoring.v3.AlertPolicy.Documentation
* @instance
*/
Documentation.prototype.subject = "";
/**
* Documentation links.
* @member {Array.<google.monitoring.v3.AlertPolicy.Documentation.ILink>} links
* @memberof google.monitoring.v3.AlertPolicy.Documentation
* @instance
*/
Documentation.prototype.links = $util.emptyArray;
/**
* Creates a new Documentation instance using the specified properties.
* @function create
* @memberof google.monitoring.v3.AlertPolicy.Documentation
* @static
* @param {google.monitoring.v3.AlertPolicy.IDocumentation=} [properties] Properties to set
* @returns {google.monitoring.v3.AlertPolicy.Documentation} Documentation instance
*/
Documentation.create = function create(properties) {
return new Documentation(properties);
};
/**
* Encodes the specified Documentation message. Does not implicitly {@link google.monitoring.v3.AlertPolicy.Documentation.verify|verify} messages.
* @function encode
* @memberof google.monitoring.v3.AlertPolicy.Documentation
* @static
* @param {google.monitoring.v3.AlertPolicy.IDocumentation} message Documentation message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Documentation.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.content != null && Object.hasOwnProperty.call(message, "content"))
writer.uint32(/* id 1, wireType 2 =*/10).string(message.content);
if (message.mimeType != null && Object.hasOwnProperty.call(message, "mimeType"))
writer.uint32(/* id 2, wireType 2 =*/18).string(message.mimeType);
if (message.subject != null && Object.hasOwnProperty.call(message, "subject"))
writer.uint32(/* id 3, wireType 2 =*/26).string(message.subject);
if (message.links != null && message.links.length)
for (var i = 0; i < message.links.length; ++i)
$root.google.monitoring.v3.AlertPolicy.Documentation.Link.encode(message.links[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
return writer;
};
/**
* Encodes the specified Documentation message, length delimited. Does not implicitly {@link google.monitoring.v3.AlertPolicy.Documentation.verify|verify} messages.
* @function encodeDelimited
* @memberof google.monitoring.v3.AlertPolicy.Documentation
* @static
* @param {google.monitoring.v3.AlertPolicy.IDocumentation} message Documentation message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Documentation.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a Documentation message from the specified reader or buffer.
* @function decode
* @memberof google.monitoring.v3.AlertPolicy.Documentation
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {google.monitoring.v3.AlertPolicy.Documentation} Documentation
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
Documentation.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.monitoring.v3.AlertPolicy.Documentation();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
message.content = reader.string();
break;
}
case 2: {
message.mimeType = reader.string();
break;
}
case 3: {