google-ads-api-client
Version:
A friendly and exhaustive client to the google-ads-api, code generated directly from google's published protobuf schema.
192 lines • 10.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MetricValueSet = exports.MetricValue = void 0;
const runtime_1 = require("@protobuf-ts/runtime");
const runtime_2 = require("@protobuf-ts/runtime");
const runtime_3 = require("@protobuf-ts/runtime");
const runtime_4 = require("@protobuf-ts/runtime");
const runtime_5 = require("@protobuf-ts/runtime");
const distribution_1 = require("./distribution");
const timestamp_1 = require("../../../protobuf/timestamp");
// @generated message type with reflection information, may provide speed optimized methods
class MetricValue$Type extends runtime_5.MessageType {
constructor() {
super("google.api.servicecontrol.v1.MetricValue", [
{ no: 1, name: "labels", kind: "map", K: 9 /*ScalarType.STRING*/, V: { kind: "scalar", T: 9 /*ScalarType.STRING*/ } },
{ no: 2, name: "start_time", kind: "message", T: () => timestamp_1.Timestamp },
{ no: 3, name: "end_time", kind: "message", T: () => timestamp_1.Timestamp },
{ no: 4, name: "bool_value", kind: "scalar", oneof: "value", T: 8 /*ScalarType.BOOL*/ },
{ no: 5, name: "int64_value", kind: "scalar", oneof: "value", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 6, name: "double_value", kind: "scalar", oneof: "value", T: 1 /*ScalarType.DOUBLE*/ },
{ no: 7, name: "string_value", kind: "scalar", oneof: "value", T: 9 /*ScalarType.STRING*/ },
{ no: 8, name: "distribution_value", kind: "message", oneof: "value", T: () => distribution_1.Distribution }
]);
}
create(value) {
const message = { labels: {}, value: { oneofKind: undefined } };
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
(0, runtime_3.reflectionMergePartial)(this, message, value);
return message;
}
internalBinaryRead(reader, length, options, target) {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* map<string, string> labels */ 1:
this.binaryReadMap1(message.labels, reader, options);
break;
case /* google.protobuf.Timestamp start_time */ 2:
message.startTime = timestamp_1.Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.startTime);
break;
case /* google.protobuf.Timestamp end_time */ 3:
message.endTime = timestamp_1.Timestamp.internalBinaryRead(reader, reader.uint32(), options, message.endTime);
break;
case /* bool bool_value */ 4:
message.value = {
oneofKind: "boolValue",
boolValue: reader.bool()
};
break;
case /* int64 int64_value */ 5:
message.value = {
oneofKind: "int64Value",
int64Value: reader.int64().toBigInt()
};
break;
case /* double double_value */ 6:
message.value = {
oneofKind: "doubleValue",
doubleValue: reader.double()
};
break;
case /* string string_value */ 7:
message.value = {
oneofKind: "stringValue",
stringValue: reader.string()
};
break;
case /* google.api.servicecontrol.v1.Distribution distribution_value */ 8:
message.value = {
oneofKind: "distributionValue",
distributionValue: distribution_1.Distribution.internalBinaryRead(reader, reader.uint32(), options, message.value.distributionValue)
};
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? runtime_2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
binaryReadMap1(map, reader, options) {
let len = reader.uint32(), end = reader.pos + len, key, val;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case 1:
key = reader.string();
break;
case 2:
val = reader.string();
break;
default: throw new globalThis.Error("unknown map entry field for field google.api.servicecontrol.v1.MetricValue.labels");
}
}
map[key ?? ""] = val ?? "";
}
internalBinaryWrite(message, writer, options) {
/* map<string, string> labels = 1; */
for (let k of Object.keys(message.labels))
writer.tag(1, runtime_1.WireType.LengthDelimited).fork().tag(1, runtime_1.WireType.LengthDelimited).string(k).tag(2, runtime_1.WireType.LengthDelimited).string(message.labels[k]).join();
/* google.protobuf.Timestamp start_time = 2; */
if (message.startTime)
timestamp_1.Timestamp.internalBinaryWrite(message.startTime, writer.tag(2, runtime_1.WireType.LengthDelimited).fork(), options).join();
/* google.protobuf.Timestamp end_time = 3; */
if (message.endTime)
timestamp_1.Timestamp.internalBinaryWrite(message.endTime, writer.tag(3, runtime_1.WireType.LengthDelimited).fork(), options).join();
/* bool bool_value = 4; */
if (message.value.oneofKind === "boolValue")
writer.tag(4, runtime_1.WireType.Varint).bool(message.value.boolValue);
/* int64 int64_value = 5; */
if (message.value.oneofKind === "int64Value")
writer.tag(5, runtime_1.WireType.Varint).int64(message.value.int64Value);
/* double double_value = 6; */
if (message.value.oneofKind === "doubleValue")
writer.tag(6, runtime_1.WireType.Bit64).double(message.value.doubleValue);
/* string string_value = 7; */
if (message.value.oneofKind === "stringValue")
writer.tag(7, runtime_1.WireType.LengthDelimited).string(message.value.stringValue);
/* google.api.servicecontrol.v1.Distribution distribution_value = 8; */
if (message.value.oneofKind === "distributionValue")
distribution_1.Distribution.internalBinaryWrite(message.value.distributionValue, writer.tag(8, runtime_1.WireType.LengthDelimited).fork(), options).join();
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message google.api.servicecontrol.v1.MetricValue
*/
exports.MetricValue = new MetricValue$Type();
// @generated message type with reflection information, may provide speed optimized methods
class MetricValueSet$Type extends runtime_5.MessageType {
constructor() {
super("google.api.servicecontrol.v1.MetricValueSet", [
{ no: 1, name: "metric_name", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 2, name: "metric_values", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => exports.MetricValue }
]);
}
create(value) {
const message = { metricName: "", metricValues: [] };
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
(0, runtime_3.reflectionMergePartial)(this, message, value);
return message;
}
internalBinaryRead(reader, length, options, target) {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* string metric_name */ 1:
message.metricName = reader.string();
break;
case /* repeated google.api.servicecontrol.v1.MetricValue metric_values */ 2:
message.metricValues.push(exports.MetricValue.internalBinaryRead(reader, reader.uint32(), options));
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? runtime_2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message, writer, options) {
/* string metric_name = 1; */
if (message.metricName !== "")
writer.tag(1, runtime_1.WireType.LengthDelimited).string(message.metricName);
/* repeated google.api.servicecontrol.v1.MetricValue metric_values = 2; */
for (let i = 0; i < message.metricValues.length; i++)
exports.MetricValue.internalBinaryWrite(message.metricValues[i], writer.tag(2, runtime_1.WireType.LengthDelimited).fork(), options).join();
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message google.api.servicecontrol.v1.MetricValueSet
*/
exports.MetricValueSet = new MetricValueSet$Type();
//# sourceMappingURL=metric_value.js.map