"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MongoTarget = exports.MongoSource = exports.MongoCollection = exports.MongoConnection = exports.MongoConnectionOptions = exports.OnPremiseMongo = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const common_1 = require("../../../../../yandex/cloud/datatransfer/v1/endpoint/common");
exports.protobufPackage = 'yandex.cloud.datatransfer.v1.endpoint';
const baseOnPremiseMongo = { hosts: '', port: 0, replicaSet: '' };
exports.OnPremiseMongo = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.hosts) {
            writer.uint32(10).string(v);
        }
        if (message.port !== 0) {
            writer.uint32(16).int64(message.port);
        }
        if (message.replicaSet !== '') {
            writer.uint32(42).string(message.replicaSet);
        }
        if (message.tlsMode !== undefined) {
            common_1.TLSMode.encode(message.tlsMode, writer.uint32(50).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({}, baseOnPremiseMongo);
        message.hosts = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.hosts.push(reader.string());
                    break;
                case 2:
                    message.port = longToNumber(reader.int64());
                    break;
                case 5:
                    message.replicaSet = reader.string();
                    break;
                case 6:
                    message.tlsMode = common_1.TLSMode.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseOnPremiseMongo);
        message.hosts = ((_a = object.hosts) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        message.port = object.port !== undefined && object.port !== null ? Number(object.port) : 0;
        message.replicaSet =
            object.replicaSet !== undefined && object.replicaSet !== null
                ? String(object.replicaSet)
                : '';
        message.tlsMode =
            object.tlsMode !== undefined && object.tlsMode !== null
                ? common_1.TLSMode.fromJSON(object.tlsMode)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.hosts) {
            obj.hosts = message.hosts.map((e) => e);
        }
        else {
            obj.hosts = [];
        }
        message.port !== undefined && (obj.port = Math.round(message.port));
        message.replicaSet !== undefined && (obj.replicaSet = message.replicaSet);
        message.tlsMode !== undefined &&
            (obj.tlsMode = message.tlsMode ? common_1.TLSMode.toJSON(message.tlsMode) : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseOnPremiseMongo);
        message.hosts = ((_a = object.hosts) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
        message.port = (_b = object.port) !== null && _b !== void 0 ? _b : 0;
        message.replicaSet = (_c = object.replicaSet) !== null && _c !== void 0 ? _c : '';
        message.tlsMode =
            object.tlsMode !== undefined && object.tlsMode !== null
                ? common_1.TLSMode.fromPartial(object.tlsMode)
                : undefined;
        return message;
    },
};
const baseMongoConnectionOptions = { user: '', authSource: '' };
exports.MongoConnectionOptions = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.mdbClusterId !== undefined) {
            writer.uint32(10).string(message.mdbClusterId);
        }
        if (message.onPremise !== undefined) {
            exports.OnPremiseMongo.encode(message.onPremise, writer.uint32(18).fork()).ldelim();
        }
        if (message.user !== '') {
            writer.uint32(26).string(message.user);
        }
        if (message.password !== undefined) {
            common_1.Secret.encode(message.password, writer.uint32(34).fork()).ldelim();
        }
        if (message.authSource !== '') {
            writer.uint32(42).string(message.authSource);
        }
        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({}, baseMongoConnectionOptions);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.mdbClusterId = reader.string();
                    break;
                case 2:
                    message.onPremise = exports.OnPremiseMongo.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.user = reader.string();
                    break;
                case 4:
                    message.password = common_1.Secret.decode(reader, reader.uint32());
                    break;
                case 5:
                    message.authSource = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseMongoConnectionOptions);
        message.mdbClusterId =
            object.mdbClusterId !== undefined && object.mdbClusterId !== null
                ? String(object.mdbClusterId)
                : undefined;
        message.onPremise =
            object.onPremise !== undefined && object.onPremise !== null
                ? exports.OnPremiseMongo.fromJSON(object.onPremise)
                : undefined;
        message.user = object.user !== undefined && object.user !== null ? String(object.user) : '';
        message.password =
            object.password !== undefined && object.password !== null
                ? common_1.Secret.fromJSON(object.password)
                : undefined;
        message.authSource =
            object.authSource !== undefined && object.authSource !== null
                ? String(object.authSource)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.mdbClusterId !== undefined && (obj.mdbClusterId = message.mdbClusterId);
        message.onPremise !== undefined &&
            (obj.onPremise = message.onPremise
                ? exports.OnPremiseMongo.toJSON(message.onPremise)
                : undefined);
        message.user !== undefined && (obj.user = message.user);
        message.password !== undefined &&
            (obj.password = message.password ? common_1.Secret.toJSON(message.password) : undefined);
        message.authSource !== undefined && (obj.authSource = message.authSource);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseMongoConnectionOptions);
        message.mdbClusterId = (_a = object.mdbClusterId) !== null && _a !== void 0 ? _a : undefined;
        message.onPremise =
            object.onPremise !== undefined && object.onPremise !== null
                ? exports.OnPremiseMongo.fromPartial(object.onPremise)
                : undefined;
        message.user = (_b = object.user) !== null && _b !== void 0 ? _b : '';
        message.password =
            object.password !== undefined && object.password !== null
                ? common_1.Secret.fromPartial(object.password)
                : undefined;
        message.authSource = (_c = object.authSource) !== null && _c !== void 0 ? _c : '';
        return message;
    },
};
const baseMongoConnection = {};
exports.MongoConnection = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.connectionOptions !== undefined) {
            exports.MongoConnectionOptions.encode(message.connectionOptions, 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({}, baseMongoConnection);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 3:
                    message.connectionOptions = exports.MongoConnectionOptions.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseMongoConnection);
        message.connectionOptions =
            object.connectionOptions !== undefined && object.connectionOptions !== null
                ? exports.MongoConnectionOptions.fromJSON(object.connectionOptions)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.connectionOptions !== undefined &&
            (obj.connectionOptions = message.connectionOptions
                ? exports.MongoConnectionOptions.toJSON(message.connectionOptions)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseMongoConnection);
        message.connectionOptions =
            object.connectionOptions !== undefined && object.connectionOptions !== null
                ? exports.MongoConnectionOptions.fromPartial(object.connectionOptions)
                : undefined;
        return message;
    },
};
const baseMongoCollection = { databaseName: '', collectionName: '' };
exports.MongoCollection = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.databaseName !== '') {
            writer.uint32(10).string(message.databaseName);
        }
        if (message.collectionName !== '') {
            writer.uint32(18).string(message.collectionName);
        }
        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({}, baseMongoCollection);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.databaseName = reader.string();
                    break;
                case 2:
                    message.collectionName = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseMongoCollection);
        message.databaseName =
            object.databaseName !== undefined && object.databaseName !== null
                ? String(object.databaseName)
                : '';
        message.collectionName =
            object.collectionName !== undefined && object.collectionName !== null
                ? String(object.collectionName)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.databaseName !== undefined && (obj.databaseName = message.databaseName);
        message.collectionName !== undefined && (obj.collectionName = message.collectionName);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseMongoCollection);
        message.databaseName = (_a = object.databaseName) !== null && _a !== void 0 ? _a : '';
        message.collectionName = (_b = object.collectionName) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseMongoSource = { subnetId: '', secondaryPreferredMode: false, securityGroups: '' };
exports.MongoSource = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.connection !== undefined) {
            exports.MongoConnection.encode(message.connection, writer.uint32(10).fork()).ldelim();
        }
        if (message.subnetId !== '') {
            writer.uint32(18).string(message.subnetId);
        }
        for (const v of message.collections) {
            exports.MongoCollection.encode(v, writer.uint32(50).fork()).ldelim();
        }
        for (const v of message.excludedCollections) {
            exports.MongoCollection.encode(v, writer.uint32(58).fork()).ldelim();
        }
        if (message.secondaryPreferredMode === true) {
            writer.uint32(64).bool(message.secondaryPreferredMode);
        }
        for (const v of message.securityGroups) {
            writer.uint32(90).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({}, baseMongoSource);
        message.collections = [];
        message.excludedCollections = [];
        message.securityGroups = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.connection = exports.MongoConnection.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.subnetId = reader.string();
                    break;
                case 6:
                    message.collections.push(exports.MongoCollection.decode(reader, reader.uint32()));
                    break;
                case 7:
                    message.excludedCollections.push(exports.MongoCollection.decode(reader, reader.uint32()));
                    break;
                case 8:
                    message.secondaryPreferredMode = reader.bool();
                    break;
                case 11:
                    message.securityGroups.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseMongoSource);
        message.connection =
            object.connection !== undefined && object.connection !== null
                ? exports.MongoConnection.fromJSON(object.connection)
                : undefined;
        message.subnetId =
            object.subnetId !== undefined && object.subnetId !== null
                ? String(object.subnetId)
                : '';
        message.collections = ((_a = object.collections) !== null && _a !== void 0 ? _a : []).map((e) => exports.MongoCollection.fromJSON(e));
        message.excludedCollections = ((_b = object.excludedCollections) !== null && _b !== void 0 ? _b : []).map((e) => exports.MongoCollection.fromJSON(e));
        message.secondaryPreferredMode =
            object.secondaryPreferredMode !== undefined && object.secondaryPreferredMode !== null
                ? Boolean(object.secondaryPreferredMode)
                : false;
        message.securityGroups = ((_c = object.securityGroups) !== null && _c !== void 0 ? _c : []).map((e) => String(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.connection !== undefined &&
            (obj.connection = message.connection
                ? exports.MongoConnection.toJSON(message.connection)
                : undefined);
        message.subnetId !== undefined && (obj.subnetId = message.subnetId);
        if (message.collections) {
            obj.collections = message.collections.map((e) => e ? exports.MongoCollection.toJSON(e) : undefined);
        }
        else {
            obj.collections = [];
        }
        if (message.excludedCollections) {
            obj.excludedCollections = message.excludedCollections.map((e) => e ? exports.MongoCollection.toJSON(e) : undefined);
        }
        else {
            obj.excludedCollections = [];
        }
        message.secondaryPreferredMode !== undefined &&
            (obj.secondaryPreferredMode = message.secondaryPreferredMode);
        if (message.securityGroups) {
            obj.securityGroups = message.securityGroups.map((e) => e);
        }
        else {
            obj.securityGroups = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e;
        const message = Object.assign({}, baseMongoSource);
        message.connection =
            object.connection !== undefined && object.connection !== null
                ? exports.MongoConnection.fromPartial(object.connection)
                : undefined;
        message.subnetId = (_a = object.subnetId) !== null && _a !== void 0 ? _a : '';
        message.collections = ((_b = object.collections) === null || _b === void 0 ? void 0 : _b.map((e) => exports.MongoCollection.fromPartial(e))) || [];
        message.excludedCollections =
            ((_c = object.excludedCollections) === null || _c === void 0 ? void 0 : _c.map((e) => exports.MongoCollection.fromPartial(e))) || [];
        message.secondaryPreferredMode = (_d = object.secondaryPreferredMode) !== null && _d !== void 0 ? _d : false;
        message.securityGroups = ((_e = object.securityGroups) === null || _e === void 0 ? void 0 : _e.map((e) => e)) || [];
        return message;
    },
};
const baseMongoTarget = {
    database: '',
    cleanupPolicy: 0,
    subnetId: '',
    securityGroups: '',
};
exports.MongoTarget = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.connection !== undefined) {
            exports.MongoConnection.encode(message.connection, writer.uint32(10).fork()).ldelim();
        }
        if (message.database !== '') {
            writer.uint32(18).string(message.database);
        }
        if (message.cleanupPolicy !== 0) {
            writer.uint32(48).int32(message.cleanupPolicy);
        }
        if (message.subnetId !== '') {
            writer.uint32(58).string(message.subnetId);
        }
        for (const v of message.securityGroups) {
            writer.uint32(66).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({}, baseMongoTarget);
        message.securityGroups = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.connection = exports.MongoConnection.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.database = reader.string();
                    break;
                case 6:
                    message.cleanupPolicy = reader.int32();
                    break;
                case 7:
                    message.subnetId = reader.string();
                    break;
                case 8:
                    message.securityGroups.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseMongoTarget);
        message.connection =
            object.connection !== undefined && object.connection !== null
                ? exports.MongoConnection.fromJSON(object.connection)
                : undefined;
        message.database =
            object.database !== undefined && object.database !== null
                ? String(object.database)
                : '';
        message.cleanupPolicy =
            object.cleanupPolicy !== undefined && object.cleanupPolicy !== null
                ? (0, common_1.cleanupPolicyFromJSON)(object.cleanupPolicy)
                : 0;
        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.connection !== undefined &&
            (obj.connection = message.connection
                ? exports.MongoConnection.toJSON(message.connection)
                : undefined);
        message.database !== undefined && (obj.database = message.database);
        message.cleanupPolicy !== undefined &&
            (obj.cleanupPolicy = (0, common_1.cleanupPolicyToJSON)(message.cleanupPolicy));
        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;
        const message = Object.assign({}, baseMongoTarget);
        message.connection =
            object.connection !== undefined && object.connection !== null
                ? exports.MongoConnection.fromPartial(object.connection)
                : undefined;
        message.database = (_a = object.database) !== null && _a !== void 0 ? _a : '';
        message.cleanupPolicy = (_b = object.cleanupPolicy) !== null && _b !== void 0 ? _b : 0;
        message.subnetId = (_c = object.subnetId) !== null && _c !== void 0 ? _c : '';
        message.securityGroups = ((_d = object.securityGroups) === null || _d === void 0 ? void 0 : _d.map((e) => e)) || [];
        return message;
    },
};
var globalThis = (() => {
    if (typeof globalThis !== 'undefined')
        return globalThis;
    if (typeof self !== 'undefined')
        return self;
    if (typeof window !== 'undefined')
        return window;
    if (typeof global !== 'undefined')
        return global;
    throw 'Unable to locate global object';
})();
function longToNumber(long) {
    if (long.gt(Number.MAX_SAFE_INTEGER)) {
        throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER');
    }
    return long.toNumber();
}
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
