"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.YDSTarget = exports.YDSSource = exports.ydsCompressionCodecToJSON = exports.ydsCompressionCodecFromJSON = exports.YdsCompressionCodec = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const parsers_1 = require("../../../../../yandex/cloud/datatransfer/v1/endpoint/parsers");
const serializers_1 = require("../../../../../yandex/cloud/datatransfer/v1/endpoint/serializers");
exports.protobufPackage = 'yandex.cloud.datatransfer.v1.endpoint';
var YdsCompressionCodec;
(function (YdsCompressionCodec) {
    YdsCompressionCodec[YdsCompressionCodec["YDS_COMPRESSION_CODEC_UNSPECIFIED"] = 0] = "YDS_COMPRESSION_CODEC_UNSPECIFIED";
    YdsCompressionCodec[YdsCompressionCodec["YDS_COMPRESSION_CODEC_RAW"] = 1] = "YDS_COMPRESSION_CODEC_RAW";
    YdsCompressionCodec[YdsCompressionCodec["YDS_COMPRESSION_CODEC_GZIP"] = 2] = "YDS_COMPRESSION_CODEC_GZIP";
    YdsCompressionCodec[YdsCompressionCodec["YDS_COMPRESSION_CODEC_ZSTD"] = 4] = "YDS_COMPRESSION_CODEC_ZSTD";
    YdsCompressionCodec[YdsCompressionCodec["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(YdsCompressionCodec = exports.YdsCompressionCodec || (exports.YdsCompressionCodec = {}));
function ydsCompressionCodecFromJSON(object) {
    switch (object) {
        case 0:
        case 'YDS_COMPRESSION_CODEC_UNSPECIFIED':
            return YdsCompressionCodec.YDS_COMPRESSION_CODEC_UNSPECIFIED;
        case 1:
        case 'YDS_COMPRESSION_CODEC_RAW':
            return YdsCompressionCodec.YDS_COMPRESSION_CODEC_RAW;
        case 2:
        case 'YDS_COMPRESSION_CODEC_GZIP':
            return YdsCompressionCodec.YDS_COMPRESSION_CODEC_GZIP;
        case 4:
        case 'YDS_COMPRESSION_CODEC_ZSTD':
            return YdsCompressionCodec.YDS_COMPRESSION_CODEC_ZSTD;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return YdsCompressionCodec.UNRECOGNIZED;
    }
}
exports.ydsCompressionCodecFromJSON = ydsCompressionCodecFromJSON;
function ydsCompressionCodecToJSON(object) {
    switch (object) {
        case YdsCompressionCodec.YDS_COMPRESSION_CODEC_UNSPECIFIED:
            return 'YDS_COMPRESSION_CODEC_UNSPECIFIED';
        case YdsCompressionCodec.YDS_COMPRESSION_CODEC_RAW:
            return 'YDS_COMPRESSION_CODEC_RAW';
        case YdsCompressionCodec.YDS_COMPRESSION_CODEC_GZIP:
            return 'YDS_COMPRESSION_CODEC_GZIP';
        case YdsCompressionCodec.YDS_COMPRESSION_CODEC_ZSTD:
            return 'YDS_COMPRESSION_CODEC_ZSTD';
        default:
            return 'UNKNOWN';
    }
}
exports.ydsCompressionCodecToJSON = ydsCompressionCodecToJSON;
const baseYDSSource = {
    database: '',
    stream: '',
    serviceAccountId: '',
    supportedCodecs: 0,
    allowTtlRewind: false,
    endpoint: '',
    subnetId: '',
    securityGroups: '',
    consumer: '',
};
exports.YDSSource = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.database !== '') {
            writer.uint32(10).string(message.database);
        }
        if (message.stream !== '') {
            writer.uint32(18).string(message.stream);
        }
        if (message.serviceAccountId !== '') {
            writer.uint32(66).string(message.serviceAccountId);
        }
        writer.uint32(74).fork();
        for (const v of message.supportedCodecs) {
            writer.int32(v);
        }
        writer.ldelim();
        if (message.parser !== undefined) {
            parsers_1.Parser.encode(message.parser, writer.uint32(82).fork()).ldelim();
        }
        if (message.allowTtlRewind === true) {
            writer.uint32(88).bool(message.allowTtlRewind);
        }
        if (message.endpoint !== '') {
            writer.uint32(162).string(message.endpoint);
        }
        if (message.subnetId !== '') {
            writer.uint32(242).string(message.subnetId);
        }
        for (const v of message.securityGroups) {
            writer.uint32(274).string(v);
        }
        if (message.consumer !== '') {
            writer.uint32(282).string(message.consumer);
        }
        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({}, baseYDSSource);
        message.supportedCodecs = [];
        message.securityGroups = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.database = reader.string();
                    break;
                case 2:
                    message.stream = reader.string();
                    break;
                case 8:
                    message.serviceAccountId = reader.string();
                    break;
                case 9:
                    if ((tag & 7) === 2) {
                        const end2 = reader.uint32() + reader.pos;
                        while (reader.pos < end2) {
                            message.supportedCodecs.push(reader.int32());
                        }
                    }
                    else {
                        message.supportedCodecs.push(reader.int32());
                    }
                    break;
                case 10:
                    message.parser = parsers_1.Parser.decode(reader, reader.uint32());
                    break;
                case 11:
                    message.allowTtlRewind = reader.bool();
                    break;
                case 20:
                    message.endpoint = reader.string();
                    break;
                case 30:
                    message.subnetId = reader.string();
                    break;
                case 34:
                    message.securityGroups.push(reader.string());
                    break;
                case 35:
                    message.consumer = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a, _b;
        const message = Object.assign({}, baseYDSSource);
        message.database =
            object.database !== undefined && object.database !== null
                ? String(object.database)
                : '';
        message.stream =
            object.stream !== undefined && object.stream !== null ? String(object.stream) : '';
        message.serviceAccountId =
            object.serviceAccountId !== undefined && object.serviceAccountId !== null
                ? String(object.serviceAccountId)
                : '';
        message.supportedCodecs = ((_a = object.supportedCodecs) !== null && _a !== void 0 ? _a : []).map((e) => ydsCompressionCodecFromJSON(e));
        message.parser =
            object.parser !== undefined && object.parser !== null
                ? parsers_1.Parser.fromJSON(object.parser)
                : undefined;
        message.allowTtlRewind =
            object.allowTtlRewind !== undefined && object.allowTtlRewind !== null
                ? Boolean(object.allowTtlRewind)
                : false;
        message.endpoint =
            object.endpoint !== undefined && object.endpoint !== null
                ? String(object.endpoint)
                : '';
        message.subnetId =
            object.subnetId !== undefined && object.subnetId !== null
                ? String(object.subnetId)
                : '';
        message.securityGroups = ((_b = object.securityGroups) !== null && _b !== void 0 ? _b : []).map((e) => String(e));
        message.consumer =
            object.consumer !== undefined && object.consumer !== null
                ? String(object.consumer)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.database !== undefined && (obj.database = message.database);
        message.stream !== undefined && (obj.stream = message.stream);
        message.serviceAccountId !== undefined && (obj.serviceAccountId = message.serviceAccountId);
        if (message.supportedCodecs) {
            obj.supportedCodecs = message.supportedCodecs.map((e) => ydsCompressionCodecToJSON(e));
        }
        else {
            obj.supportedCodecs = [];
        }
        message.parser !== undefined &&
            (obj.parser = message.parser ? parsers_1.Parser.toJSON(message.parser) : undefined);
        message.allowTtlRewind !== undefined && (obj.allowTtlRewind = message.allowTtlRewind);
        message.endpoint !== undefined && (obj.endpoint = message.endpoint);
        message.subnetId !== undefined && (obj.subnetId = message.subnetId);
        if (message.securityGroups) {
            obj.securityGroups = message.securityGroups.map((e) => e);
        }
        else {
            obj.securityGroups = [];
        }
        message.consumer !== undefined && (obj.consumer = message.consumer);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j;
        const message = Object.assign({}, baseYDSSource);
        message.database = (_a = object.database) !== null && _a !== void 0 ? _a : '';
        message.stream = (_b = object.stream) !== null && _b !== void 0 ? _b : '';
        message.serviceAccountId = (_c = object.serviceAccountId) !== null && _c !== void 0 ? _c : '';
        message.supportedCodecs = ((_d = object.supportedCodecs) === null || _d === void 0 ? void 0 : _d.map((e) => e)) || [];
        message.parser =
            object.parser !== undefined && object.parser !== null
                ? parsers_1.Parser.fromPartial(object.parser)
                : undefined;
        message.allowTtlRewind = (_e = object.allowTtlRewind) !== null && _e !== void 0 ? _e : false;
        message.endpoint = (_f = object.endpoint) !== null && _f !== void 0 ? _f : '';
        message.subnetId = (_g = object.subnetId) !== null && _g !== void 0 ? _g : '';
        message.securityGroups = ((_h = object.securityGroups) === null || _h === void 0 ? void 0 : _h.map((e) => e)) || [];
        message.consumer = (_j = object.consumer) !== null && _j !== void 0 ? _j : '';
        return message;
    },
};
const baseYDSTarget = {
    database: '',
    stream: '',
    serviceAccountId: '',
    saveTxOrder: false,
    compressionCodec: 0,
    endpoint: '',
    subnetId: '',
    securityGroups: '',
};
exports.YDSTarget = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.database !== '') {
            writer.uint32(10).string(message.database);
        }
        if (message.stream !== '') {
            writer.uint32(18).string(message.stream);
        }
        if (message.serviceAccountId !== '') {
            writer.uint32(26).string(message.serviceAccountId);
        }
        if (message.saveTxOrder === true) {
            writer.uint32(32).bool(message.saveTxOrder);
        }
        if (message.compressionCodec !== 0) {
            writer.uint32(40).int32(message.compressionCodec);
        }
        if (message.serializer !== undefined) {
            serializers_1.Serializer.encode(message.serializer, writer.uint32(66).fork()).ldelim();
        }
        if (message.endpoint !== '') {
            writer.uint32(162).string(message.endpoint);
        }
        if (message.subnetId !== '') {
            writer.uint32(242).string(message.subnetId);
        }
        for (const v of message.securityGroups) {
            writer.uint32(274).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({}, baseYDSTarget);
        message.securityGroups = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.database = reader.string();
                    break;
                case 2:
                    message.stream = reader.string();
                    break;
                case 3:
                    message.serviceAccountId = reader.string();
                    break;
                case 4:
                    message.saveTxOrder = reader.bool();
                    break;
                case 5:
                    message.compressionCodec = reader.int32();
                    break;
                case 8:
                    message.serializer = serializers_1.Serializer.decode(reader, reader.uint32());
                    break;
                case 20:
                    message.endpoint = reader.string();
                    break;
                case 30:
                    message.subnetId = reader.string();
                    break;
                case 34:
                    message.securityGroups.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseYDSTarget);
        message.database =
            object.database !== undefined && object.database !== null
                ? String(object.database)
                : '';
        message.stream =
            object.stream !== undefined && object.stream !== null ? String(object.stream) : '';
        message.serviceAccountId =
            object.serviceAccountId !== undefined && object.serviceAccountId !== null
                ? String(object.serviceAccountId)
                : '';
        message.saveTxOrder =
            object.saveTxOrder !== undefined && object.saveTxOrder !== null
                ? Boolean(object.saveTxOrder)
                : false;
        message.compressionCodec =
            object.compressionCodec !== undefined && object.compressionCodec !== null
                ? ydsCompressionCodecFromJSON(object.compressionCodec)
                : 0;
        message.serializer =
            object.serializer !== undefined && object.serializer !== null
                ? serializers_1.Serializer.fromJSON(object.serializer)
                : undefined;
        message.endpoint =
            object.endpoint !== undefined && object.endpoint !== null
                ? String(object.endpoint)
                : '';
        message.subnetId =
            object.subnetId !== undefined && object.subnetId !== null
                ? String(object.subnetId)
                : '';
        message.securityGroups = ((_a = object.securityGroups) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.database !== undefined && (obj.database = message.database);
        message.stream !== undefined && (obj.stream = message.stream);
        message.serviceAccountId !== undefined && (obj.serviceAccountId = message.serviceAccountId);
        message.saveTxOrder !== undefined && (obj.saveTxOrder = message.saveTxOrder);
        message.compressionCodec !== undefined &&
            (obj.compressionCodec = ydsCompressionCodecToJSON(message.compressionCodec));
        message.serializer !== undefined &&
            (obj.serializer = message.serializer
                ? serializers_1.Serializer.toJSON(message.serializer)
                : undefined);
        message.endpoint !== undefined && (obj.endpoint = message.endpoint);
        message.subnetId !== undefined && (obj.subnetId = message.subnetId);
        if (message.securityGroups) {
            obj.securityGroups = message.securityGroups.map((e) => e);
        }
        else {
            obj.securityGroups = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g, _h;
        const message = Object.assign({}, baseYDSTarget);
        message.database = (_a = object.database) !== null && _a !== void 0 ? _a : '';
        message.stream = (_b = object.stream) !== null && _b !== void 0 ? _b : '';
        message.serviceAccountId = (_c = object.serviceAccountId) !== null && _c !== void 0 ? _c : '';
        message.saveTxOrder = (_d = object.saveTxOrder) !== null && _d !== void 0 ? _d : false;
        message.compressionCodec = (_e = object.compressionCodec) !== null && _e !== void 0 ? _e : 0;
        message.serializer =
            object.serializer !== undefined && object.serializer !== null
                ? serializers_1.Serializer.fromPartial(object.serializer)
                : undefined;
        message.endpoint = (_f = object.endpoint) !== null && _f !== void 0 ? _f : '';
        message.subnetId = (_g = object.subnetId) !== null && _g !== void 0 ? _g : '';
        message.securityGroups = ((_h = object.securityGroups) === null || _h === void 0 ? void 0 : _h.map((e) => e)) || [];
        return message;
    },
};
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
