"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Trail_DnsDataEventsFilter = exports.Trail_FilteringPolicy = exports.Trail_ManagementEventsFiltering = exports.Trail_EventTypes = exports.Trail_DataEventsFiltering = exports.Trail_EventFilterElementCategory = exports.Trail_EventFilterElement = exports.Trail_EventFilter = exports.Trail_Resource = exports.Trail_PathFilterElementSome = exports.Trail_PathFilterElementAny = exports.Trail_PathFilterElement = exports.Trail_PathFilter = exports.Trail_Filter = exports.Trail_DataStream = exports.Trail_CloudLogging = exports.Trail_ObjectStorage = exports.Trail_Destination = exports.Trail_LabelsEntry = exports.Trail = exports.trail_EventAccessTypeFilterToJSON = exports.trail_EventAccessTypeFilterFromJSON = exports.Trail_EventAccessTypeFilter = exports.trail_EventCategoryFilterToJSON = exports.trail_EventCategoryFilterFromJSON = exports.Trail_EventCategoryFilter = exports.trail_StatusToJSON = exports.trail_StatusFromJSON = exports.Trail_Status = 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");
exports.protobufPackage = 'yandex.cloud.audittrails.v1';
var Trail_Status;
(function (Trail_Status) {
    Trail_Status[Trail_Status["STATUS_UNSPECIFIED"] = 0] = "STATUS_UNSPECIFIED";
    /** ACTIVE - The trail is active and Audit events are processed */
    Trail_Status[Trail_Status["ACTIVE"] = 1] = "ACTIVE";
    /** ERROR - The trail configuration has issues that are preventing Audit Trails from delivering events */
    Trail_Status[Trail_Status["ERROR"] = 2] = "ERROR";
    /** DELETED - The trail is being deleted */
    Trail_Status[Trail_Status["DELETED"] = 3] = "DELETED";
    Trail_Status[Trail_Status["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(Trail_Status = exports.Trail_Status || (exports.Trail_Status = {}));
function trail_StatusFromJSON(object) {
    switch (object) {
        case 0:
        case 'STATUS_UNSPECIFIED':
            return Trail_Status.STATUS_UNSPECIFIED;
        case 1:
        case 'ACTIVE':
            return Trail_Status.ACTIVE;
        case 2:
        case 'ERROR':
            return Trail_Status.ERROR;
        case 3:
        case 'DELETED':
            return Trail_Status.DELETED;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return Trail_Status.UNRECOGNIZED;
    }
}
exports.trail_StatusFromJSON = trail_StatusFromJSON;
function trail_StatusToJSON(object) {
    switch (object) {
        case Trail_Status.STATUS_UNSPECIFIED:
            return 'STATUS_UNSPECIFIED';
        case Trail_Status.ACTIVE:
            return 'ACTIVE';
        case Trail_Status.ERROR:
            return 'ERROR';
        case Trail_Status.DELETED:
            return 'DELETED';
        default:
            return 'UNKNOWN';
    }
}
exports.trail_StatusToJSON = trail_StatusToJSON;
var Trail_EventCategoryFilter;
(function (Trail_EventCategoryFilter) {
    Trail_EventCategoryFilter[Trail_EventCategoryFilter["EVENT_CATEGORY_FILTER_UNSPECIFIED"] = 0] = "EVENT_CATEGORY_FILTER_UNSPECIFIED";
    /** CONTROL_PLANE - The events that are generated during the interaction with the service's resources */
    Trail_EventCategoryFilter[Trail_EventCategoryFilter["CONTROL_PLANE"] = 1] = "CONTROL_PLANE";
    /** DATA_PLANE - Events that are generated during interaction with data within the service's resources */
    Trail_EventCategoryFilter[Trail_EventCategoryFilter["DATA_PLANE"] = 2] = "DATA_PLANE";
    Trail_EventCategoryFilter[Trail_EventCategoryFilter["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(Trail_EventCategoryFilter = exports.Trail_EventCategoryFilter || (exports.Trail_EventCategoryFilter = {}));
function trail_EventCategoryFilterFromJSON(object) {
    switch (object) {
        case 0:
        case 'EVENT_CATEGORY_FILTER_UNSPECIFIED':
            return Trail_EventCategoryFilter.EVENT_CATEGORY_FILTER_UNSPECIFIED;
        case 1:
        case 'CONTROL_PLANE':
            return Trail_EventCategoryFilter.CONTROL_PLANE;
        case 2:
        case 'DATA_PLANE':
            return Trail_EventCategoryFilter.DATA_PLANE;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return Trail_EventCategoryFilter.UNRECOGNIZED;
    }
}
exports.trail_EventCategoryFilterFromJSON = trail_EventCategoryFilterFromJSON;
function trail_EventCategoryFilterToJSON(object) {
    switch (object) {
        case Trail_EventCategoryFilter.EVENT_CATEGORY_FILTER_UNSPECIFIED:
            return 'EVENT_CATEGORY_FILTER_UNSPECIFIED';
        case Trail_EventCategoryFilter.CONTROL_PLANE:
            return 'CONTROL_PLANE';
        case Trail_EventCategoryFilter.DATA_PLANE:
            return 'DATA_PLANE';
        default:
            return 'UNKNOWN';
    }
}
exports.trail_EventCategoryFilterToJSON = trail_EventCategoryFilterToJSON;
var Trail_EventAccessTypeFilter;
(function (Trail_EventAccessTypeFilter) {
    Trail_EventAccessTypeFilter[Trail_EventAccessTypeFilter["EVENT_ACCESS_TYPE_FILTER_UNSPECIFIED"] = 0] = "EVENT_ACCESS_TYPE_FILTER_UNSPECIFIED";
    /** WRITE - Events for operations that do perform some modification */
    Trail_EventAccessTypeFilter[Trail_EventAccessTypeFilter["WRITE"] = 1] = "WRITE";
    /** READ - Events for operations that do not perform any modifications */
    Trail_EventAccessTypeFilter[Trail_EventAccessTypeFilter["READ"] = 2] = "READ";
    Trail_EventAccessTypeFilter[Trail_EventAccessTypeFilter["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(Trail_EventAccessTypeFilter = exports.Trail_EventAccessTypeFilter || (exports.Trail_EventAccessTypeFilter = {}));
function trail_EventAccessTypeFilterFromJSON(object) {
    switch (object) {
        case 0:
        case 'EVENT_ACCESS_TYPE_FILTER_UNSPECIFIED':
            return Trail_EventAccessTypeFilter.EVENT_ACCESS_TYPE_FILTER_UNSPECIFIED;
        case 1:
        case 'WRITE':
            return Trail_EventAccessTypeFilter.WRITE;
        case 2:
        case 'READ':
            return Trail_EventAccessTypeFilter.READ;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return Trail_EventAccessTypeFilter.UNRECOGNIZED;
    }
}
exports.trail_EventAccessTypeFilterFromJSON = trail_EventAccessTypeFilterFromJSON;
function trail_EventAccessTypeFilterToJSON(object) {
    switch (object) {
        case Trail_EventAccessTypeFilter.EVENT_ACCESS_TYPE_FILTER_UNSPECIFIED:
            return 'EVENT_ACCESS_TYPE_FILTER_UNSPECIFIED';
        case Trail_EventAccessTypeFilter.WRITE:
            return 'WRITE';
        case Trail_EventAccessTypeFilter.READ:
            return 'READ';
        default:
            return 'UNKNOWN';
    }
}
exports.trail_EventAccessTypeFilterToJSON = trail_EventAccessTypeFilterToJSON;
const baseTrail = {
    id: '',
    folderId: '',
    name: '',
    description: '',
    serviceAccountId: '',
    status: 0,
    statusErrorMessage: '',
    cloudId: '',
};
exports.Trail = {
    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.createdAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(26).fork()).ldelim();
        }
        if (message.updatedAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.updatedAt), 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.Trail_LabelsEntry.encode({ key: key, value }, writer.uint32(58).fork()).ldelim();
        });
        if (message.destination !== undefined) {
            exports.Trail_Destination.encode(message.destination, writer.uint32(66).fork()).ldelim();
        }
        if (message.serviceAccountId !== '') {
            writer.uint32(74).string(message.serviceAccountId);
        }
        if (message.status !== 0) {
            writer.uint32(80).int32(message.status);
        }
        if (message.filter !== undefined) {
            exports.Trail_Filter.encode(message.filter, writer.uint32(90).fork()).ldelim();
        }
        if (message.statusErrorMessage !== '') {
            writer.uint32(98).string(message.statusErrorMessage);
        }
        if (message.cloudId !== '') {
            writer.uint32(114).string(message.cloudId);
        }
        if (message.filteringPolicy !== undefined) {
            exports.Trail_FilteringPolicy.encode(message.filteringPolicy, writer.uint32(122).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({}, baseTrail);
        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.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 4:
                    message.updatedAt = 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.Trail_LabelsEntry.decode(reader, reader.uint32());
                    if (entry7.value !== undefined) {
                        message.labels[entry7.key] = entry7.value;
                    }
                    break;
                case 8:
                    message.destination = exports.Trail_Destination.decode(reader, reader.uint32());
                    break;
                case 9:
                    message.serviceAccountId = reader.string();
                    break;
                case 10:
                    message.status = reader.int32();
                    break;
                case 11:
                    message.filter = exports.Trail_Filter.decode(reader, reader.uint32());
                    break;
                case 12:
                    message.statusErrorMessage = reader.string();
                    break;
                case 14:
                    message.cloudId = reader.string();
                    break;
                case 15:
                    message.filteringPolicy = exports.Trail_FilteringPolicy.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseTrail);
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        message.createdAt =
            object.createdAt !== undefined && object.createdAt !== null
                ? fromJsonTimestamp(object.createdAt)
                : undefined;
        message.updatedAt =
            object.updatedAt !== undefined && object.updatedAt !== null
                ? fromJsonTimestamp(object.updatedAt)
                : 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.destination =
            object.destination !== undefined && object.destination !== null
                ? exports.Trail_Destination.fromJSON(object.destination)
                : undefined;
        message.serviceAccountId =
            object.serviceAccountId !== undefined && object.serviceAccountId !== null
                ? String(object.serviceAccountId)
                : '';
        message.status =
            object.status !== undefined && object.status !== null
                ? trail_StatusFromJSON(object.status)
                : 0;
        message.filter =
            object.filter !== undefined && object.filter !== null
                ? exports.Trail_Filter.fromJSON(object.filter)
                : undefined;
        message.statusErrorMessage =
            object.statusErrorMessage !== undefined && object.statusErrorMessage !== null
                ? String(object.statusErrorMessage)
                : '';
        message.cloudId =
            object.cloudId !== undefined && object.cloudId !== null ? String(object.cloudId) : '';
        message.filteringPolicy =
            object.filteringPolicy !== undefined && object.filteringPolicy !== null
                ? exports.Trail_FilteringPolicy.fromJSON(object.filteringPolicy)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.id !== undefined && (obj.id = message.id);
        message.folderId !== undefined && (obj.folderId = message.folderId);
        message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString());
        message.updatedAt !== undefined && (obj.updatedAt = message.updatedAt.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.destination !== undefined &&
            (obj.destination = message.destination
                ? exports.Trail_Destination.toJSON(message.destination)
                : undefined);
        message.serviceAccountId !== undefined && (obj.serviceAccountId = message.serviceAccountId);
        message.status !== undefined && (obj.status = trail_StatusToJSON(message.status));
        message.filter !== undefined &&
            (obj.filter = message.filter ? exports.Trail_Filter.toJSON(message.filter) : undefined);
        message.statusErrorMessage !== undefined &&
            (obj.statusErrorMessage = message.statusErrorMessage);
        message.cloudId !== undefined && (obj.cloudId = message.cloudId);
        message.filteringPolicy !== undefined &&
            (obj.filteringPolicy = message.filteringPolicy
                ? exports.Trail_FilteringPolicy.toJSON(message.filteringPolicy)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
        const message = Object.assign({}, baseTrail);
        message.id = (_a = object.id) !== null && _a !== void 0 ? _a : '';
        message.folderId = (_b = object.folderId) !== null && _b !== void 0 ? _b : '';
        message.createdAt = (_c = object.createdAt) !== null && _c !== void 0 ? _c : undefined;
        message.updatedAt = (_d = object.updatedAt) !== 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.destination =
            object.destination !== undefined && object.destination !== null
                ? exports.Trail_Destination.fromPartial(object.destination)
                : undefined;
        message.serviceAccountId = (_h = object.serviceAccountId) !== null && _h !== void 0 ? _h : '';
        message.status = (_j = object.status) !== null && _j !== void 0 ? _j : 0;
        message.filter =
            object.filter !== undefined && object.filter !== null
                ? exports.Trail_Filter.fromPartial(object.filter)
                : undefined;
        message.statusErrorMessage = (_k = object.statusErrorMessage) !== null && _k !== void 0 ? _k : '';
        message.cloudId = (_l = object.cloudId) !== null && _l !== void 0 ? _l : '';
        message.filteringPolicy =
            object.filteringPolicy !== undefined && object.filteringPolicy !== null
                ? exports.Trail_FilteringPolicy.fromPartial(object.filteringPolicy)
                : undefined;
        return message;
    },
};
const baseTrail_LabelsEntry = { key: '', value: '' };
exports.Trail_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({}, baseTrail_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({}, baseTrail_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({}, baseTrail_LabelsEntry);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseTrail_Destination = {};
exports.Trail_Destination = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.objectStorage !== undefined) {
            exports.Trail_ObjectStorage.encode(message.objectStorage, writer.uint32(10).fork()).ldelim();
        }
        if (message.cloudLogging !== undefined) {
            exports.Trail_CloudLogging.encode(message.cloudLogging, writer.uint32(26).fork()).ldelim();
        }
        if (message.dataStream !== undefined) {
            exports.Trail_DataStream.encode(message.dataStream, writer.uint32(34).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({}, baseTrail_Destination);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.objectStorage = exports.Trail_ObjectStorage.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.cloudLogging = exports.Trail_CloudLogging.decode(reader, reader.uint32());
                    break;
                case 4:
                    message.dataStream = exports.Trail_DataStream.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTrail_Destination);
        message.objectStorage =
            object.objectStorage !== undefined && object.objectStorage !== null
                ? exports.Trail_ObjectStorage.fromJSON(object.objectStorage)
                : undefined;
        message.cloudLogging =
            object.cloudLogging !== undefined && object.cloudLogging !== null
                ? exports.Trail_CloudLogging.fromJSON(object.cloudLogging)
                : undefined;
        message.dataStream =
            object.dataStream !== undefined && object.dataStream !== null
                ? exports.Trail_DataStream.fromJSON(object.dataStream)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.objectStorage !== undefined &&
            (obj.objectStorage = message.objectStorage
                ? exports.Trail_ObjectStorage.toJSON(message.objectStorage)
                : undefined);
        message.cloudLogging !== undefined &&
            (obj.cloudLogging = message.cloudLogging
                ? exports.Trail_CloudLogging.toJSON(message.cloudLogging)
                : undefined);
        message.dataStream !== undefined &&
            (obj.dataStream = message.dataStream
                ? exports.Trail_DataStream.toJSON(message.dataStream)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseTrail_Destination);
        message.objectStorage =
            object.objectStorage !== undefined && object.objectStorage !== null
                ? exports.Trail_ObjectStorage.fromPartial(object.objectStorage)
                : undefined;
        message.cloudLogging =
            object.cloudLogging !== undefined && object.cloudLogging !== null
                ? exports.Trail_CloudLogging.fromPartial(object.cloudLogging)
                : undefined;
        message.dataStream =
            object.dataStream !== undefined && object.dataStream !== null
                ? exports.Trail_DataStream.fromPartial(object.dataStream)
                : undefined;
        return message;
    },
};
const baseTrail_ObjectStorage = { bucketId: '', objectPrefix: '' };
exports.Trail_ObjectStorage = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.bucketId !== '') {
            writer.uint32(10).string(message.bucketId);
        }
        if (message.objectPrefix !== '') {
            writer.uint32(18).string(message.objectPrefix);
        }
        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({}, baseTrail_ObjectStorage);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.bucketId = reader.string();
                    break;
                case 2:
                    message.objectPrefix = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTrail_ObjectStorage);
        message.bucketId =
            object.bucketId !== undefined && object.bucketId !== null
                ? String(object.bucketId)
                : '';
        message.objectPrefix =
            object.objectPrefix !== undefined && object.objectPrefix !== null
                ? String(object.objectPrefix)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.bucketId !== undefined && (obj.bucketId = message.bucketId);
        message.objectPrefix !== undefined && (obj.objectPrefix = message.objectPrefix);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseTrail_ObjectStorage);
        message.bucketId = (_a = object.bucketId) !== null && _a !== void 0 ? _a : '';
        message.objectPrefix = (_b = object.objectPrefix) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseTrail_CloudLogging = {};
exports.Trail_CloudLogging = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.logGroupId !== undefined) {
            writer.uint32(10).string(message.logGroupId);
        }
        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({}, baseTrail_CloudLogging);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.logGroupId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTrail_CloudLogging);
        message.logGroupId =
            object.logGroupId !== undefined && object.logGroupId !== null
                ? String(object.logGroupId)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.logGroupId !== undefined && (obj.logGroupId = message.logGroupId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseTrail_CloudLogging);
        message.logGroupId = (_a = object.logGroupId) !== null && _a !== void 0 ? _a : undefined;
        return message;
    },
};
const baseTrail_DataStream = { databaseId: '', streamName: '' };
exports.Trail_DataStream = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.databaseId !== '') {
            writer.uint32(10).string(message.databaseId);
        }
        if (message.streamName !== '') {
            writer.uint32(18).string(message.streamName);
        }
        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({}, baseTrail_DataStream);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.databaseId = reader.string();
                    break;
                case 2:
                    message.streamName = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTrail_DataStream);
        message.databaseId =
            object.databaseId !== undefined && object.databaseId !== null
                ? String(object.databaseId)
                : '';
        message.streamName =
            object.streamName !== undefined && object.streamName !== null
                ? String(object.streamName)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.databaseId !== undefined && (obj.databaseId = message.databaseId);
        message.streamName !== undefined && (obj.streamName = message.streamName);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseTrail_DataStream);
        message.databaseId = (_a = object.databaseId) !== null && _a !== void 0 ? _a : '';
        message.streamName = (_b = object.streamName) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseTrail_Filter = {};
exports.Trail_Filter = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.pathFilter !== undefined) {
            exports.Trail_PathFilter.encode(message.pathFilter, writer.uint32(10).fork()).ldelim();
        }
        if (message.eventFilter !== undefined) {
            exports.Trail_EventFilter.encode(message.eventFilter, writer.uint32(18).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({}, baseTrail_Filter);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.pathFilter = exports.Trail_PathFilter.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.eventFilter = exports.Trail_EventFilter.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTrail_Filter);
        message.pathFilter =
            object.pathFilter !== undefined && object.pathFilter !== null
                ? exports.Trail_PathFilter.fromJSON(object.pathFilter)
                : undefined;
        message.eventFilter =
            object.eventFilter !== undefined && object.eventFilter !== null
                ? exports.Trail_EventFilter.fromJSON(object.eventFilter)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.pathFilter !== undefined &&
            (obj.pathFilter = message.pathFilter
                ? exports.Trail_PathFilter.toJSON(message.pathFilter)
                : undefined);
        message.eventFilter !== undefined &&
            (obj.eventFilter = message.eventFilter
                ? exports.Trail_EventFilter.toJSON(message.eventFilter)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseTrail_Filter);
        message.pathFilter =
            object.pathFilter !== undefined && object.pathFilter !== null
                ? exports.Trail_PathFilter.fromPartial(object.pathFilter)
                : undefined;
        message.eventFilter =
            object.eventFilter !== undefined && object.eventFilter !== null
                ? exports.Trail_EventFilter.fromPartial(object.eventFilter)
                : undefined;
        return message;
    },
};
const baseTrail_PathFilter = {};
exports.Trail_PathFilter = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.root !== undefined) {
            exports.Trail_PathFilterElement.encode(message.root, writer.uint32(10).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({}, baseTrail_PathFilter);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.root = exports.Trail_PathFilterElement.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTrail_PathFilter);
        message.root =
            object.root !== undefined && object.root !== null
                ? exports.Trail_PathFilterElement.fromJSON(object.root)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.root !== undefined &&
            (obj.root = message.root ? exports.Trail_PathFilterElement.toJSON(message.root) : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseTrail_PathFilter);
        message.root =
            object.root !== undefined && object.root !== null
                ? exports.Trail_PathFilterElement.fromPartial(object.root)
                : undefined;
        return message;
    },
};
const baseTrail_PathFilterElement = {};
exports.Trail_PathFilterElement = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.anyFilter !== undefined) {
            exports.Trail_PathFilterElementAny.encode(message.anyFilter, writer.uint32(10).fork()).ldelim();
        }
        if (message.someFilter !== undefined) {
            exports.Trail_PathFilterElementSome.encode(message.someFilter, writer.uint32(18).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({}, baseTrail_PathFilterElement);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.anyFilter = exports.Trail_PathFilterElementAny.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.someFilter = exports.Trail_PathFilterElementSome.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTrail_PathFilterElement);
        message.anyFilter =
            object.anyFilter !== undefined && object.anyFilter !== null
                ? exports.Trail_PathFilterElementAny.fromJSON(object.anyFilter)
                : undefined;
        message.someFilter =
            object.someFilter !== undefined && object.someFilter !== null
                ? exports.Trail_PathFilterElementSome.fromJSON(object.someFilter)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.anyFilter !== undefined &&
            (obj.anyFilter = message.anyFilter
                ? exports.Trail_PathFilterElementAny.toJSON(message.anyFilter)
                : undefined);
        message.someFilter !== undefined &&
            (obj.someFilter = message.someFilter
                ? exports.Trail_PathFilterElementSome.toJSON(message.someFilter)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseTrail_PathFilterElement);
        message.anyFilter =
            object.anyFilter !== undefined && object.anyFilter !== null
                ? exports.Trail_PathFilterElementAny.fromPartial(object.anyFilter)
                : undefined;
        message.someFilter =
            object.someFilter !== undefined && object.someFilter !== null
                ? exports.Trail_PathFilterElementSome.fromPartial(object.someFilter)
                : undefined;
        return message;
    },
};
const baseTrail_PathFilterElementAny = {};
exports.Trail_PathFilterElementAny = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.resource !== undefined) {
            exports.Trail_Resource.encode(message.resource, writer.uint32(10).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({}, baseTrail_PathFilterElementAny);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.resource = exports.Trail_Resource.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTrail_PathFilterElementAny);
        message.resource =
            object.resource !== undefined && object.resource !== null
                ? exports.Trail_Resource.fromJSON(object.resource)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.resource !== undefined &&
            (obj.resource = message.resource ? exports.Trail_Resource.toJSON(message.resource) : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseTrail_PathFilterElementAny);
        message.resource =
            object.resource !== undefined && object.resource !== null
                ? exports.Trail_Resource.fromPartial(object.resource)
                : undefined;
        return message;
    },
};
const baseTrail_PathFilterElementSome = {};
exports.Trail_PathFilterElementSome = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.resource !== undefined) {
            exports.Trail_Resource.encode(message.resource, writer.uint32(10).fork()).ldelim();
        }
        for (const v of message.filters) {
            exports.Trail_PathFilterElement.encode(v, writer.uint32(18).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({}, baseTrail_PathFilterElementSome);
        message.filters = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.resource = exports.Trail_Resource.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.filters.push(exports.Trail_PathFilterElement.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseTrail_PathFilterElementSome);
        message.resource =
            object.resource !== undefined && object.resource !== null
                ? exports.Trail_Resource.fromJSON(object.resource)
                : undefined;
        message.filters = ((_a = object.filters) !== null && _a !== void 0 ? _a : []).map((e) => exports.Trail_PathFilterElement.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.resource !== undefined &&
            (obj.resource = message.resource ? exports.Trail_Resource.toJSON(message.resource) : undefined);
        if (message.filters) {
            obj.filters = message.filters.map((e) => e ? exports.Trail_PathFilterElement.toJSON(e) : undefined);
        }
        else {
            obj.filters = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseTrail_PathFilterElementSome);
        message.resource =
            object.resource !== undefined && object.resource !== null
                ? exports.Trail_Resource.fromPartial(object.resource)
                : undefined;
        message.filters = ((_a = object.filters) === null || _a === void 0 ? void 0 : _a.map((e) => exports.Trail_PathFilterElement.fromPartial(e))) || [];
        return message;
    },
};
const baseTrail_Resource = { id: '', type: '' };
exports.Trail_Resource = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.id !== '') {
            writer.uint32(10).string(message.id);
        }
        if (message.type !== '') {
            writer.uint32(18).string(message.type);
        }
        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({}, baseTrail_Resource);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.id = reader.string();
                    break;
                case 2:
                    message.type = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTrail_Resource);
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        message.type = object.type !== undefined && object.type !== null ? String(object.type) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.id !== undefined && (obj.id = message.id);
        message.type !== undefined && (obj.type = message.type);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseTrail_Resource);
        message.id = (_a = object.id) !== null && _a !== void 0 ? _a : '';
        message.type = (_b = object.type) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseTrail_EventFilter = {};
exports.Trail_EventFilter = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.filters) {
            exports.Trail_EventFilterElement.encode(v, writer.uint32(10).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({}, baseTrail_EventFilter);
        message.filters = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.filters.push(exports.Trail_EventFilterElement.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseTrail_EventFilter);
        message.filters = ((_a = object.filters) !== null && _a !== void 0 ? _a : []).map((e) => exports.Trail_EventFilterElement.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.filters) {
            obj.filters = message.filters.map((e) => e ? exports.Trail_EventFilterElement.toJSON(e) : undefined);
        }
        else {
            obj.filters = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseTrail_EventFilter);
        message.filters = ((_a = object.filters) === null || _a === void 0 ? void 0 : _a.map((e) => exports.Trail_EventFilterElement.fromPartial(e))) || [];
        return message;
    },
};
const baseTrail_EventFilterElement = { service: '' };
exports.Trail_EventFilterElement = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.service !== '') {
            writer.uint32(10).string(message.service);
        }
        for (const v of message.categories) {
            exports.Trail_EventFilterElementCategory.encode(v, writer.uint32(18).fork()).ldelim();
        }
        if (message.pathFilter !== undefined) {
            exports.Trail_PathFilter.encode(message.pathFilter, writer.uint32(26).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({}, baseTrail_EventFilterElement);
        message.categories = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.service = reader.string();
                    break;
                case 2:
                    message.categories.push(exports.Trail_EventFilterElementCategory.decode(reader, reader.uint32()));
                    break;
                case 3:
                    message.pathFilter = exports.Trail_PathFilter.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseTrail_EventFilterElement);
        message.service =
            object.service !== undefined && object.service !== null ? String(object.service) : '';
        message.categories = ((_a = object.categories) !== null && _a !== void 0 ? _a : []).map((e) => exports.Trail_EventFilterElementCategory.fromJSON(e));
        message.pathFilter =
            object.pathFilter !== undefined && object.pathFilter !== null
                ? exports.Trail_PathFilter.fromJSON(object.pathFilter)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.service !== undefined && (obj.service = message.service);
        if (message.categories) {
            obj.categories = message.categories.map((e) => e ? exports.Trail_EventFilterElementCategory.toJSON(e) : undefined);
        }
        else {
            obj.categories = [];
        }
        message.pathFilter !== undefined &&
            (obj.pathFilter = message.pathFilter
                ? exports.Trail_PathFilter.toJSON(message.pathFilter)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseTrail_EventFilterElement);
        message.service = (_a = object.service) !== null && _a !== void 0 ? _a : '';
        message.categories =
            ((_b = object.categories) === null || _b === void 0 ? void 0 : _b.map((e) => exports.Trail_EventFilterElementCategory.fromPartial(e))) || [];
        message.pathFilter =
            object.pathFilter !== undefined && object.pathFilter !== null
                ? exports.Trail_PathFilter.fromPartial(object.pathFilter)
                : undefined;
        return message;
    },
};
const baseTrail_EventFilterElementCategory = { plane: 0, type: 0 };
exports.Trail_EventFilterElementCategory = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.plane !== 0) {
            writer.uint32(8).int32(message.plane);
        }
        if (message.type !== 0) {
            writer.uint32(16).int32(message.type);
        }
        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({}, baseTrail_EventFilterElementCategory);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.plane = reader.int32();
                    break;
                case 2:
                    message.type = reader.int32();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTrail_EventFilterElementCategory);
        message.plane =
            object.plane !== undefined && object.plane !== null
                ? trail_EventCategoryFilterFromJSON(object.plane)
                : 0;
        message.type =
            object.type !== undefined && object.type !== null
                ? trail_EventAccessTypeFilterFromJSON(object.type)
                : 0;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.plane !== undefined && (obj.plane = trail_EventCategoryFilterToJSON(message.plane));
        message.type !== undefined && (obj.type = trail_EventAccessTypeFilterToJSON(message.type));
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseTrail_EventFilterElementCategory);
        message.plane = (_a = object.plane) !== null && _a !== void 0 ? _a : 0;
        message.type = (_b = object.type) !== null && _b !== void 0 ? _b : 0;
        return message;
    },
};
const baseTrail_DataEventsFiltering = { service: '' };
exports.Trail_DataEventsFiltering = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.service !== '') {
            writer.uint32(10).string(message.service);
        }
        if (message.includedEvents !== undefined) {
            exports.Trail_EventTypes.encode(message.includedEvents, writer.uint32(18).fork()).ldelim();
        }
        if (message.excludedEvents !== undefined) {
            exports.Trail_EventTypes.encode(message.excludedEvents, writer.uint32(26).fork()).ldelim();
        }
        if (message.dnsFilter !== undefined) {
            exports.Trail_DnsDataEventsFilter.encode(message.dnsFilter, writer.uint32(42).fork()).ldelim();
        }
        for (const v of message.resourceScopes) {
            exports.Trail_Resource.encode(v, writer.uint32(34).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({}, baseTrail_DataEventsFiltering);
        message.resourceScopes = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.service = reader.string();
                    break;
                case 2:
                    message.includedEvents = exports.Trail_EventTypes.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.excludedEvents = exports.Trail_EventTypes.decode(reader, reader.uint32());
                    break;
                case 5:
                    message.dnsFilter = exports.Trail_DnsDataEventsFilter.decode(reader, reader.uint32());
                    break;
                case 4:
                    message.resourceScopes.push(exports.Trail_Resource.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseTrail_DataEventsFiltering);
        message.service =
            object.service !== undefined && object.service !== null ? String(object.service) : '';
        message.includedEvents =
            object.includedEvents !== undefined && object.includedEvents !== null
                ? exports.Trail_EventTypes.fromJSON(object.includedEvents)
                : undefined;
        message.excludedEvents =
            object.excludedEvents !== undefined && object.excludedEvents !== null
                ? exports.Trail_EventTypes.fromJSON(object.excludedEvents)
                : undefined;
        message.dnsFilter =
            object.dnsFilter !== undefined && object.dnsFilter !== null
                ? exports.Trail_DnsDataEventsFilter.fromJSON(object.dnsFilter)
                : undefined;
        message.resourceScopes = ((_a = object.resourceScopes) !== null && _a !== void 0 ? _a : []).map((e) => exports.Trail_Resource.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.service !== undefined && (obj.service = message.service);
        message.includedEvents !== undefined &&
            (obj.includedEvents = message.includedEvents
                ? exports.Trail_EventTypes.toJSON(message.includedEvents)
                : undefined);
        message.excludedEvents !== undefined &&
            (obj.excludedEvents = message.excludedEvents
                ? exports.Trail_EventTypes.toJSON(message.excludedEvents)
                : undefined);
        message.dnsFilter !== undefined &&
            (obj.dnsFilter = message.dnsFilter
                ? exports.Trail_DnsDataEventsFilter.toJSON(message.dnsFilter)
                : undefined);
        if (message.resourceScopes) {
            obj.resourceScopes = message.resourceScopes.map((e) => e ? exports.Trail_Resource.toJSON(e) : undefined);
        }
        else {
            obj.resourceScopes = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseTrail_DataEventsFiltering);
        message.service = (_a = object.service) !== null && _a !== void 0 ? _a : '';
        message.includedEvents =
            object.includedEvents !== undefined && object.includedEvents !== null
                ? exports.Trail_EventTypes.fromPartial(object.includedEvents)
                : undefined;
        message.excludedEvents =
            object.excludedEvents !== undefined && object.excludedEvents !== null
                ? exports.Trail_EventTypes.fromPartial(object.excludedEvents)
                : undefined;
        message.dnsFilter =
            object.dnsFilter !== undefined && object.dnsFilter !== null
                ? exports.Trail_DnsDataEventsFilter.fromPartial(object.dnsFilter)
                : undefined;
        message.resourceScopes =
            ((_b = object.resourceScopes) === null || _b === void 0 ? void 0 : _b.map((e) => exports.Trail_Resource.fromPartial(e))) || [];
        return message;
    },
};
const baseTrail_EventTypes = { eventTypes: '' };
exports.Trail_EventTypes = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.eventTypes) {
            writer.uint32(10).string(v);
        }
        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({}, baseTrail_EventTypes);
        message.eventTypes = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.eventTypes.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseTrail_EventTypes);
        message.eventTypes = ((_a = object.eventTypes) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.eventTypes) {
            obj.eventTypes = message.eventTypes.map((e) => e);
        }
        else {
            obj.eventTypes = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseTrail_EventTypes);
        message.eventTypes = ((_a = object.eventTypes) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
        return message;
    },
};
const baseTrail_ManagementEventsFiltering = {};
exports.Trail_ManagementEventsFiltering = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.resourceScopes) {
            exports.Trail_Resource.encode(v, writer.uint32(10).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({}, baseTrail_ManagementEventsFiltering);
        message.resourceScopes = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.resourceScopes.push(exports.Trail_Resource.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseTrail_ManagementEventsFiltering);
        message.resourceScopes = ((_a = object.resourceScopes) !== null && _a !== void 0 ? _a : []).map((e) => exports.Trail_Resource.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.resourceScopes) {
            obj.resourceScopes = message.resourceScopes.map((e) => e ? exports.Trail_Resource.toJSON(e) : undefined);
        }
        else {
            obj.resourceScopes = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseTrail_ManagementEventsFiltering);
        message.resourceScopes =
            ((_a = object.resourceScopes) === null || _a === void 0 ? void 0 : _a.map((e) => exports.Trail_Resource.fromPartial(e))) || [];
        return message;
    },
};
const baseTrail_FilteringPolicy = {};
exports.Trail_FilteringPolicy = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.managementEventsFilter !== undefined) {
            exports.Trail_ManagementEventsFiltering.encode(message.managementEventsFilter, writer.uint32(10).fork()).ldelim();
        }
        for (const v of message.dataEventsFilters) {
            exports.Trail_DataEventsFiltering.encode(v, writer.uint32(18).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({}, baseTrail_FilteringPolicy);
        message.dataEventsFilters = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.managementEventsFilter = exports.Trail_ManagementEventsFiltering.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.dataEventsFilters.push(exports.Trail_DataEventsFiltering.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseTrail_FilteringPolicy);
        message.managementEventsFilter =
            object.managementEventsFilter !== undefined && object.managementEventsFilter !== null
                ? exports.Trail_ManagementEventsFiltering.fromJSON(object.managementEventsFilter)
                : undefined;
        message.dataEventsFilters = ((_a = object.dataEventsFilters) !== null && _a !== void 0 ? _a : []).map((e) => exports.Trail_DataEventsFiltering.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.managementEventsFilter !== undefined &&
            (obj.managementEventsFilter = message.managementEventsFilter
                ? exports.Trail_ManagementEventsFiltering.toJSON(message.managementEventsFilter)
                : undefined);
        if (message.dataEventsFilters) {
            obj.dataEventsFilters = message.dataEventsFilters.map((e) => e ? exports.Trail_DataEventsFiltering.toJSON(e) : undefined);
        }
        else {
            obj.dataEventsFilters = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseTrail_FilteringPolicy);
        message.managementEventsFilter =
            object.managementEventsFilter !== undefined && object.managementEventsFilter !== null
                ? exports.Trail_ManagementEventsFiltering.fromPartial(object.managementEventsFilter)
                : undefined;
        message.dataEventsFilters =
            ((_a = object.dataEventsFilters) === null || _a === void 0 ? void 0 : _a.map((e) => exports.Trail_DataEventsFiltering.fromPartial(e))) || [];
        return message;
    },
};
const baseTrail_DnsDataEventsFilter = { onlyRecursiveQueries: false };
exports.Trail_DnsDataEventsFilter = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.onlyRecursiveQueries === true) {
            writer.uint32(8).bool(message.onlyRecursiveQueries);
        }
        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({}, baseTrail_DnsDataEventsFilter);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.onlyRecursiveQueries = reader.bool();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseTrail_DnsDataEventsFilter);
        message.onlyRecursiveQueries =
            object.onlyRecursiveQueries !== undefined && object.onlyRecursiveQueries !== null
                ? Boolean(object.onlyRecursiveQueries)
                : false;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.onlyRecursiveQueries !== undefined &&
            (obj.onlyRecursiveQueries = message.onlyRecursiveQueries);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseTrail_DnsDataEventsFilter);
        message.onlyRecursiveQueries = (_a = object.onlyRecursiveQueries) !== null && _a !== void 0 ? _a : false;
        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();
}
