"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExportParams = exports.Export_LabelsEntry = exports.Export = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const timestamp_1 = require("../../../../google/protobuf/timestamp");
const log_entry_1 = require("../../../../yandex/cloud/logging/v1/log_entry");
exports.protobufPackage = 'yandex.cloud.logging.v1';
const baseExport = {
    id: '',
    folderId: '',
    cloudId: '',
    name: '',
    description: '',
    groupId: '',
    sinkId: '',
};
exports.Export = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.id !== '') {
            writer.uint32(10).string(message.id);
        }
        if (message.folderId !== '') {
            writer.uint32(18).string(message.folderId);
        }
        if (message.cloudId !== '') {
            writer.uint32(26).string(message.cloudId);
        }
        if (message.createdAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(34).fork()).ldelim();
        }
        if (message.name !== '') {
            writer.uint32(42).string(message.name);
        }
        if (message.description !== '') {
            writer.uint32(50).string(message.description);
        }
        Object.entries(message.labels).forEach(([key, value]) => {
            exports.Export_LabelsEntry.encode({ key: key, value }, writer.uint32(58).fork()).ldelim();
        });
        if (message.groupId !== '') {
            writer.uint32(66).string(message.groupId);
        }
        if (message.sinkId !== '') {
            writer.uint32(74).string(message.sinkId);
        }
        if (message.params !== undefined) {
            exports.ExportParams.encode(message.params, writer.uint32(82).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseExport);
        message.labels = {};
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.id = reader.string();
                    break;
                case 2:
                    message.folderId = reader.string();
                    break;
                case 3:
                    message.cloudId = reader.string();
                    break;
                case 4:
                    message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 5:
                    message.name = reader.string();
                    break;
                case 6:
                    message.description = reader.string();
                    break;
                case 7:
                    const entry7 = exports.Export_LabelsEntry.decode(reader, reader.uint32());
                    if (entry7.value !== undefined) {
                        message.labels[entry7.key] = entry7.value;
                    }
                    break;
                case 8:
                    message.groupId = reader.string();
                    break;
                case 9:
                    message.sinkId = reader.string();
                    break;
                case 10:
                    message.params = exports.ExportParams.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseExport);
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        message.cloudId =
            object.cloudId !== undefined && object.cloudId !== null ? String(object.cloudId) : '';
        message.createdAt =
            object.createdAt !== undefined && object.createdAt !== null
                ? fromJsonTimestamp(object.createdAt)
                : undefined;
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.labels = Object.entries((_a = object.labels) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
            acc[key] = String(value);
            return acc;
        }, {});
        message.groupId =
            object.groupId !== undefined && object.groupId !== null ? String(object.groupId) : '';
        message.sinkId =
            object.sinkId !== undefined && object.sinkId !== null ? String(object.sinkId) : '';
        message.params =
            object.params !== undefined && object.params !== null
                ? exports.ExportParams.fromJSON(object.params)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.id !== undefined && (obj.id = message.id);
        message.folderId !== undefined && (obj.folderId = message.folderId);
        message.cloudId !== undefined && (obj.cloudId = message.cloudId);
        message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString());
        message.name !== undefined && (obj.name = message.name);
        message.description !== undefined && (obj.description = message.description);
        obj.labels = {};
        if (message.labels) {
            Object.entries(message.labels).forEach(([k, v]) => {
                obj.labels[k] = v;
            });
        }
        message.groupId !== undefined && (obj.groupId = message.groupId);
        message.sinkId !== undefined && (obj.sinkId = message.sinkId);
        message.params !== undefined &&
            (obj.params = message.params ? exports.ExportParams.toJSON(message.params) : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j;
        const message = Object.assign({}, baseExport);
        message.id = (_a = object.id) !== null && _a !== void 0 ? _a : '';
        message.folderId = (_b = object.folderId) !== null && _b !== void 0 ? _b : '';
        message.cloudId = (_c = object.cloudId) !== null && _c !== void 0 ? _c : '';
        message.createdAt = (_d = object.createdAt) !== null && _d !== void 0 ? _d : undefined;
        message.name = (_e = object.name) !== null && _e !== void 0 ? _e : '';
        message.description = (_f = object.description) !== null && _f !== void 0 ? _f : '';
        message.labels = Object.entries((_g = object.labels) !== null && _g !== void 0 ? _g : {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = String(value);
            }
            return acc;
        }, {});
        message.groupId = (_h = object.groupId) !== null && _h !== void 0 ? _h : '';
        message.sinkId = (_j = object.sinkId) !== null && _j !== void 0 ? _j : '';
        message.params =
            object.params !== undefined && object.params !== null
                ? exports.ExportParams.fromPartial(object.params)
                : undefined;
        return message;
    },
};
const baseExport_LabelsEntry = { key: '', value: '' };
exports.Export_LabelsEntry = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.key !== '') {
            writer.uint32(10).string(message.key);
        }
        if (message.value !== '') {
            writer.uint32(18).string(message.value);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseExport_LabelsEntry);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.key = reader.string();
                    break;
                case 2:
                    message.value = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseExport_LabelsEntry);
        message.key = object.key !== undefined && object.key !== null ? String(object.key) : '';
        message.value =
            object.value !== undefined && object.value !== null ? String(object.value) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.key !== undefined && (obj.key = message.key);
        message.value !== undefined && (obj.value = message.value);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseExport_LabelsEntry);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseExportParams = {
    resourceTypes: '',
    resourceIds: '',
    streamNames: '',
    levels: 0,
    filter: '',
};
exports.ExportParams = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.resourceTypes) {
            writer.uint32(10).string(v);
        }
        for (const v of message.resourceIds) {
            writer.uint32(18).string(v);
        }
        for (const v of message.streamNames) {
            writer.uint32(26).string(v);
        }
        writer.uint32(34).fork();
        for (const v of message.levels) {
            writer.int32(v);
        }
        writer.ldelim();
        if (message.filter !== '') {
            writer.uint32(42).string(message.filter);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseExportParams);
        message.resourceTypes = [];
        message.resourceIds = [];
        message.streamNames = [];
        message.levels = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.resourceTypes.push(reader.string());
                    break;
                case 2:
                    message.resourceIds.push(reader.string());
                    break;
                case 3:
                    message.streamNames.push(reader.string());
                    break;
                case 4:
                    if ((tag & 7) === 2) {
                        const end2 = reader.uint32() + reader.pos;
                        while (reader.pos < end2) {
                            message.levels.push(reader.int32());
                        }
                    }
                    else {
                        message.levels.push(reader.int32());
                    }
                    break;
                case 5:
                    message.filter = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a, _b, _c, _d;
        const message = Object.assign({}, baseExportParams);
        message.resourceTypes = ((_a = object.resourceTypes) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        message.resourceIds = ((_b = object.resourceIds) !== null && _b !== void 0 ? _b : []).map((e) => String(e));
        message.streamNames = ((_c = object.streamNames) !== null && _c !== void 0 ? _c : []).map((e) => String(e));
        message.levels = ((_d = object.levels) !== null && _d !== void 0 ? _d : []).map((e) => (0, log_entry_1.logLevel_LevelFromJSON)(e));
        message.filter =
            object.filter !== undefined && object.filter !== null ? String(object.filter) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.resourceTypes) {
            obj.resourceTypes = message.resourceTypes.map((e) => e);
        }
        else {
            obj.resourceTypes = [];
        }
        if (message.resourceIds) {
            obj.resourceIds = message.resourceIds.map((e) => e);
        }
        else {
            obj.resourceIds = [];
        }
        if (message.streamNames) {
            obj.streamNames = message.streamNames.map((e) => e);
        }
        else {
            obj.streamNames = [];
        }
        if (message.levels) {
            obj.levels = message.levels.map((e) => (0, log_entry_1.logLevel_LevelToJSON)(e));
        }
        else {
            obj.levels = [];
        }
        message.filter !== undefined && (obj.filter = message.filter);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e;
        const message = Object.assign({}, baseExportParams);
        message.resourceTypes = ((_a = object.resourceTypes) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
        message.resourceIds = ((_b = object.resourceIds) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
        message.streamNames = ((_c = object.streamNames) === null || _c === void 0 ? void 0 : _c.map((e) => e)) || [];
        message.levels = ((_d = object.levels) === null || _d === void 0 ? void 0 : _d.map((e) => e)) || [];
        message.filter = (_e = object.filter) !== null && _e !== void 0 ? _e : '';
        return message;
    },
};
function toTimestamp(date) {
    const seconds = date.getTime() / 1000;
    const nanos = (date.getTime() % 1000) * 1000000;
    return { seconds, nanos };
}
function fromTimestamp(t) {
    let millis = t.seconds * 1000;
    millis += t.nanos / 1000000;
    return new Date(millis);
}
function fromJsonTimestamp(o) {
    if (o instanceof Date) {
        return o;
    }
    else if (typeof o === 'string') {
        return new Date(o);
    }
    else {
        return fromTimestamp(timestamp_1.Timestamp.fromJSON(o));
    }
}
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
