"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Resources = exports.PostgreSQLSettings = exports.CoordinatorSettings = exports.RouterSettings = exports.BalancerSettings = exports.InfraConfig = exports.PostgreSQLConfig = exports.CoordinatorConfig = exports.RouterConfig = exports.SPQRConfig = exports.MDBPostgreSQL = exports.routerSettings_DefaultRouteBehaviorToJSON = exports.routerSettings_DefaultRouteBehaviorFromJSON = exports.RouterSettings_DefaultRouteBehavior = exports.logLevelToJSON = exports.logLevelFromJSON = exports.LogLevel = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const wrappers_1 = require("../../../../../google/protobuf/wrappers");
exports.protobufPackage = 'yandex.cloud.mdb.spqr.v1';
var LogLevel;
(function (LogLevel) {
    LogLevel[LogLevel["LOG_LEVEL_UNSPECIFIED"] = 0] = "LOG_LEVEL_UNSPECIFIED";
    LogLevel[LogLevel["DEBUG"] = 1] = "DEBUG";
    LogLevel[LogLevel["INFO"] = 2] = "INFO";
    LogLevel[LogLevel["WARNING"] = 3] = "WARNING";
    LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
    LogLevel[LogLevel["FATAL"] = 5] = "FATAL";
    LogLevel[LogLevel["PANIC"] = 6] = "PANIC";
    LogLevel[LogLevel["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
function logLevelFromJSON(object) {
    switch (object) {
        case 0:
        case 'LOG_LEVEL_UNSPECIFIED':
            return LogLevel.LOG_LEVEL_UNSPECIFIED;
        case 1:
        case 'DEBUG':
            return LogLevel.DEBUG;
        case 2:
        case 'INFO':
            return LogLevel.INFO;
        case 3:
        case 'WARNING':
            return LogLevel.WARNING;
        case 4:
        case 'ERROR':
            return LogLevel.ERROR;
        case 5:
        case 'FATAL':
            return LogLevel.FATAL;
        case 6:
        case 'PANIC':
            return LogLevel.PANIC;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return LogLevel.UNRECOGNIZED;
    }
}
exports.logLevelFromJSON = logLevelFromJSON;
function logLevelToJSON(object) {
    switch (object) {
        case LogLevel.LOG_LEVEL_UNSPECIFIED:
            return 'LOG_LEVEL_UNSPECIFIED';
        case LogLevel.DEBUG:
            return 'DEBUG';
        case LogLevel.INFO:
            return 'INFO';
        case LogLevel.WARNING:
            return 'WARNING';
        case LogLevel.ERROR:
            return 'ERROR';
        case LogLevel.FATAL:
            return 'FATAL';
        case LogLevel.PANIC:
            return 'PANIC';
        default:
            return 'UNKNOWN';
    }
}
exports.logLevelToJSON = logLevelToJSON;
var RouterSettings_DefaultRouteBehavior;
(function (RouterSettings_DefaultRouteBehavior) {
    RouterSettings_DefaultRouteBehavior[RouterSettings_DefaultRouteBehavior["DEFAULT_ROUTE_BEHAVIOR_UNSPECIFIED"] = 0] = "DEFAULT_ROUTE_BEHAVIOR_UNSPECIFIED";
    RouterSettings_DefaultRouteBehavior[RouterSettings_DefaultRouteBehavior["BLOCK"] = 1] = "BLOCK";
    RouterSettings_DefaultRouteBehavior[RouterSettings_DefaultRouteBehavior["ALLOW"] = 2] = "ALLOW";
    RouterSettings_DefaultRouteBehavior[RouterSettings_DefaultRouteBehavior["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(RouterSettings_DefaultRouteBehavior = exports.RouterSettings_DefaultRouteBehavior || (exports.RouterSettings_DefaultRouteBehavior = {}));
function routerSettings_DefaultRouteBehaviorFromJSON(object) {
    switch (object) {
        case 0:
        case 'DEFAULT_ROUTE_BEHAVIOR_UNSPECIFIED':
            return RouterSettings_DefaultRouteBehavior.DEFAULT_ROUTE_BEHAVIOR_UNSPECIFIED;
        case 1:
        case 'BLOCK':
            return RouterSettings_DefaultRouteBehavior.BLOCK;
        case 2:
        case 'ALLOW':
            return RouterSettings_DefaultRouteBehavior.ALLOW;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return RouterSettings_DefaultRouteBehavior.UNRECOGNIZED;
    }
}
exports.routerSettings_DefaultRouteBehaviorFromJSON = routerSettings_DefaultRouteBehaviorFromJSON;
function routerSettings_DefaultRouteBehaviorToJSON(object) {
    switch (object) {
        case RouterSettings_DefaultRouteBehavior.DEFAULT_ROUTE_BEHAVIOR_UNSPECIFIED:
            return 'DEFAULT_ROUTE_BEHAVIOR_UNSPECIFIED';
        case RouterSettings_DefaultRouteBehavior.BLOCK:
            return 'BLOCK';
        case RouterSettings_DefaultRouteBehavior.ALLOW:
            return 'ALLOW';
        default:
            return 'UNKNOWN';
    }
}
exports.routerSettings_DefaultRouteBehaviorToJSON = routerSettings_DefaultRouteBehaviorToJSON;
const baseMDBPostgreSQL = { clusterId: '' };
exports.MDBPostgreSQL = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.clusterId !== '') {
            writer.uint32(10).string(message.clusterId);
        }
        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({}, baseMDBPostgreSQL);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.clusterId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseMDBPostgreSQL);
        message.clusterId =
            object.clusterId !== undefined && object.clusterId !== null
                ? String(object.clusterId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.clusterId !== undefined && (obj.clusterId = message.clusterId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseMDBPostgreSQL);
        message.clusterId = (_a = object.clusterId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseSPQRConfig = { logLevel: 0 };
exports.SPQRConfig = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.router !== undefined) {
            exports.RouterConfig.encode(message.router, writer.uint32(10).fork()).ldelim();
        }
        if (message.coordinator !== undefined) {
            exports.CoordinatorConfig.encode(message.coordinator, writer.uint32(18).fork()).ldelim();
        }
        if (message.postgresql !== undefined) {
            exports.PostgreSQLConfig.encode(message.postgresql, writer.uint32(26).fork()).ldelim();
        }
        if (message.infra !== undefined) {
            exports.InfraConfig.encode(message.infra, writer.uint32(42).fork()).ldelim();
        }
        if (message.logLevel !== 0) {
            writer.uint32(48).int32(message.logLevel);
        }
        if (message.balancer !== undefined) {
            exports.BalancerSettings.encode(message.balancer, writer.uint32(58).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({}, baseSPQRConfig);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.router = exports.RouterConfig.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.coordinator = exports.CoordinatorConfig.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.postgresql = exports.PostgreSQLConfig.decode(reader, reader.uint32());
                    break;
                case 5:
                    message.infra = exports.InfraConfig.decode(reader, reader.uint32());
                    break;
                case 6:
                    message.logLevel = reader.int32();
                    break;
                case 7:
                    message.balancer = exports.BalancerSettings.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseSPQRConfig);
        message.router =
            object.router !== undefined && object.router !== null
                ? exports.RouterConfig.fromJSON(object.router)
                : undefined;
        message.coordinator =
            object.coordinator !== undefined && object.coordinator !== null
                ? exports.CoordinatorConfig.fromJSON(object.coordinator)
                : undefined;
        message.postgresql =
            object.postgresql !== undefined && object.postgresql !== null
                ? exports.PostgreSQLConfig.fromJSON(object.postgresql)
                : undefined;
        message.infra =
            object.infra !== undefined && object.infra !== null
                ? exports.InfraConfig.fromJSON(object.infra)
                : undefined;
        message.logLevel =
            object.logLevel !== undefined && object.logLevel !== null
                ? logLevelFromJSON(object.logLevel)
                : 0;
        message.balancer =
            object.balancer !== undefined && object.balancer !== null
                ? exports.BalancerSettings.fromJSON(object.balancer)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.router !== undefined &&
            (obj.router = message.router ? exports.RouterConfig.toJSON(message.router) : undefined);
        message.coordinator !== undefined &&
            (obj.coordinator = message.coordinator
                ? exports.CoordinatorConfig.toJSON(message.coordinator)
                : undefined);
        message.postgresql !== undefined &&
            (obj.postgresql = message.postgresql
                ? exports.PostgreSQLConfig.toJSON(message.postgresql)
                : undefined);
        message.infra !== undefined &&
            (obj.infra = message.infra ? exports.InfraConfig.toJSON(message.infra) : undefined);
        message.logLevel !== undefined && (obj.logLevel = logLevelToJSON(message.logLevel));
        message.balancer !== undefined &&
            (obj.balancer = message.balancer
                ? exports.BalancerSettings.toJSON(message.balancer)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseSPQRConfig);
        message.router =
            object.router !== undefined && object.router !== null
                ? exports.RouterConfig.fromPartial(object.router)
                : undefined;
        message.coordinator =
            object.coordinator !== undefined && object.coordinator !== null
                ? exports.CoordinatorConfig.fromPartial(object.coordinator)
                : undefined;
        message.postgresql =
            object.postgresql !== undefined && object.postgresql !== null
                ? exports.PostgreSQLConfig.fromPartial(object.postgresql)
                : undefined;
        message.infra =
            object.infra !== undefined && object.infra !== null
                ? exports.InfraConfig.fromPartial(object.infra)
                : undefined;
        message.logLevel = (_a = object.logLevel) !== null && _a !== void 0 ? _a : 0;
        message.balancer =
            object.balancer !== undefined && object.balancer !== null
                ? exports.BalancerSettings.fromPartial(object.balancer)
                : undefined;
        return message;
    },
};
const baseRouterConfig = {};
exports.RouterConfig = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.config !== undefined) {
            exports.RouterSettings.encode(message.config, writer.uint32(10).fork()).ldelim();
        }
        if (message.resources !== undefined) {
            exports.Resources.encode(message.resources, 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({}, baseRouterConfig);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.config = exports.RouterSettings.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.resources = exports.Resources.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseRouterConfig);
        message.config =
            object.config !== undefined && object.config !== null
                ? exports.RouterSettings.fromJSON(object.config)
                : undefined;
        message.resources =
            object.resources !== undefined && object.resources !== null
                ? exports.Resources.fromJSON(object.resources)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.config !== undefined &&
            (obj.config = message.config ? exports.RouterSettings.toJSON(message.config) : undefined);
        message.resources !== undefined &&
            (obj.resources = message.resources ? exports.Resources.toJSON(message.resources) : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseRouterConfig);
        message.config =
            object.config !== undefined && object.config !== null
                ? exports.RouterSettings.fromPartial(object.config)
                : undefined;
        message.resources =
            object.resources !== undefined && object.resources !== null
                ? exports.Resources.fromPartial(object.resources)
                : undefined;
        return message;
    },
};
const baseCoordinatorConfig = {};
exports.CoordinatorConfig = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.config !== undefined) {
            exports.CoordinatorSettings.encode(message.config, writer.uint32(10).fork()).ldelim();
        }
        if (message.resources !== undefined) {
            exports.Resources.encode(message.resources, 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({}, baseCoordinatorConfig);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.config = exports.CoordinatorSettings.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.resources = exports.Resources.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseCoordinatorConfig);
        message.config =
            object.config !== undefined && object.config !== null
                ? exports.CoordinatorSettings.fromJSON(object.config)
                : undefined;
        message.resources =
            object.resources !== undefined && object.resources !== null
                ? exports.Resources.fromJSON(object.resources)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.config !== undefined &&
            (obj.config = message.config ? exports.CoordinatorSettings.toJSON(message.config) : undefined);
        message.resources !== undefined &&
            (obj.resources = message.resources ? exports.Resources.toJSON(message.resources) : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseCoordinatorConfig);
        message.config =
            object.config !== undefined && object.config !== null
                ? exports.CoordinatorSettings.fromPartial(object.config)
                : undefined;
        message.resources =
            object.resources !== undefined && object.resources !== null
                ? exports.Resources.fromPartial(object.resources)
                : undefined;
        return message;
    },
};
const basePostgreSQLConfig = {};
exports.PostgreSQLConfig = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.config !== undefined) {
            exports.PostgreSQLSettings.encode(message.config, writer.uint32(10).fork()).ldelim();
        }
        if (message.resources !== undefined) {
            exports.Resources.encode(message.resources, 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({}, basePostgreSQLConfig);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.config = exports.PostgreSQLSettings.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.resources = exports.Resources.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, basePostgreSQLConfig);
        message.config =
            object.config !== undefined && object.config !== null
                ? exports.PostgreSQLSettings.fromJSON(object.config)
                : undefined;
        message.resources =
            object.resources !== undefined && object.resources !== null
                ? exports.Resources.fromJSON(object.resources)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.config !== undefined &&
            (obj.config = message.config ? exports.PostgreSQLSettings.toJSON(message.config) : undefined);
        message.resources !== undefined &&
            (obj.resources = message.resources ? exports.Resources.toJSON(message.resources) : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, basePostgreSQLConfig);
        message.config =
            object.config !== undefined && object.config !== null
                ? exports.PostgreSQLSettings.fromPartial(object.config)
                : undefined;
        message.resources =
            object.resources !== undefined && object.resources !== null
                ? exports.Resources.fromPartial(object.resources)
                : undefined;
        return message;
    },
};
const baseInfraConfig = {};
exports.InfraConfig = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.resources !== undefined) {
            exports.Resources.encode(message.resources, writer.uint32(18).fork()).ldelim();
        }
        if (message.router !== undefined) {
            exports.RouterSettings.encode(message.router, writer.uint32(26).fork()).ldelim();
        }
        if (message.coordinator !== undefined) {
            exports.CoordinatorSettings.encode(message.coordinator, 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({}, baseInfraConfig);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 2:
                    message.resources = exports.Resources.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.router = exports.RouterSettings.decode(reader, reader.uint32());
                    break;
                case 4:
                    message.coordinator = exports.CoordinatorSettings.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseInfraConfig);
        message.resources =
            object.resources !== undefined && object.resources !== null
                ? exports.Resources.fromJSON(object.resources)
                : undefined;
        message.router =
            object.router !== undefined && object.router !== null
                ? exports.RouterSettings.fromJSON(object.router)
                : undefined;
        message.coordinator =
            object.coordinator !== undefined && object.coordinator !== null
                ? exports.CoordinatorSettings.fromJSON(object.coordinator)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.resources !== undefined &&
            (obj.resources = message.resources ? exports.Resources.toJSON(message.resources) : undefined);
        message.router !== undefined &&
            (obj.router = message.router ? exports.RouterSettings.toJSON(message.router) : undefined);
        message.coordinator !== undefined &&
            (obj.coordinator = message.coordinator
                ? exports.CoordinatorSettings.toJSON(message.coordinator)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseInfraConfig);
        message.resources =
            object.resources !== undefined && object.resources !== null
                ? exports.Resources.fromPartial(object.resources)
                : undefined;
        message.router =
            object.router !== undefined && object.router !== null
                ? exports.RouterSettings.fromPartial(object.router)
                : undefined;
        message.coordinator =
            object.coordinator !== undefined && object.coordinator !== null
                ? exports.CoordinatorSettings.fromPartial(object.coordinator)
                : undefined;
        return message;
    },
};
const baseBalancerSettings = {};
exports.BalancerSettings = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.cpuThreshold !== undefined) {
            wrappers_1.DoubleValue.encode({ value: message.cpuThreshold }, writer.uint32(10).fork()).ldelim();
        }
        if (message.spaceThreshold !== undefined) {
            wrappers_1.DoubleValue.encode({ value: message.spaceThreshold }, writer.uint32(18).fork()).ldelim();
        }
        if (message.statIntervalSec !== undefined) {
            wrappers_1.Int64Value.encode({ value: message.statIntervalSec }, writer.uint32(26).fork()).ldelim();
        }
        if (message.maxMoveCount !== undefined) {
            wrappers_1.Int64Value.encode({ value: message.maxMoveCount }, writer.uint32(34).fork()).ldelim();
        }
        if (message.keysPerMove !== undefined) {
            wrappers_1.Int64Value.encode({ value: message.keysPerMove }, writer.uint32(42).fork()).ldelim();
        }
        if (message.timeout !== undefined) {
            wrappers_1.Int64Value.encode({ value: message.timeout }, 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({}, baseBalancerSettings);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.cpuThreshold = wrappers_1.DoubleValue.decode(reader, reader.uint32()).value;
                    break;
                case 2:
                    message.spaceThreshold = wrappers_1.DoubleValue.decode(reader, reader.uint32()).value;
                    break;
                case 3:
                    message.statIntervalSec = wrappers_1.Int64Value.decode(reader, reader.uint32()).value;
                    break;
                case 4:
                    message.maxMoveCount = wrappers_1.Int64Value.decode(reader, reader.uint32()).value;
                    break;
                case 5:
                    message.keysPerMove = wrappers_1.Int64Value.decode(reader, reader.uint32()).value;
                    break;
                case 6:
                    message.timeout = wrappers_1.Int64Value.decode(reader, reader.uint32()).value;
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseBalancerSettings);
        message.cpuThreshold =
            object.cpuThreshold !== undefined && object.cpuThreshold !== null
                ? Number(object.cpuThreshold)
                : undefined;
        message.spaceThreshold =
            object.spaceThreshold !== undefined && object.spaceThreshold !== null
                ? Number(object.spaceThreshold)
                : undefined;
        message.statIntervalSec =
            object.statIntervalSec !== undefined && object.statIntervalSec !== null
                ? Number(object.statIntervalSec)
                : undefined;
        message.maxMoveCount =
            object.maxMoveCount !== undefined && object.maxMoveCount !== null
                ? Number(object.maxMoveCount)
                : undefined;
        message.keysPerMove =
            object.keysPerMove !== undefined && object.keysPerMove !== null
                ? Number(object.keysPerMove)
                : undefined;
        message.timeout =
            object.timeout !== undefined && object.timeout !== null
                ? Number(object.timeout)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.cpuThreshold !== undefined && (obj.cpuThreshold = message.cpuThreshold);
        message.spaceThreshold !== undefined && (obj.spaceThreshold = message.spaceThreshold);
        message.statIntervalSec !== undefined && (obj.statIntervalSec = message.statIntervalSec);
        message.maxMoveCount !== undefined && (obj.maxMoveCount = message.maxMoveCount);
        message.keysPerMove !== undefined && (obj.keysPerMove = message.keysPerMove);
        message.timeout !== undefined && (obj.timeout = message.timeout);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f;
        const message = Object.assign({}, baseBalancerSettings);
        message.cpuThreshold = (_a = object.cpuThreshold) !== null && _a !== void 0 ? _a : undefined;
        message.spaceThreshold = (_b = object.spaceThreshold) !== null && _b !== void 0 ? _b : undefined;
        message.statIntervalSec = (_c = object.statIntervalSec) !== null && _c !== void 0 ? _c : undefined;
        message.maxMoveCount = (_d = object.maxMoveCount) !== null && _d !== void 0 ? _d : undefined;
        message.keysPerMove = (_e = object.keysPerMove) !== null && _e !== void 0 ? _e : undefined;
        message.timeout = (_f = object.timeout) !== null && _f !== void 0 ? _f : undefined;
        return message;
    },
};
const baseRouterSettings = { timeQuantiles: 0, defaultRouteBehavior: 0 };
exports.RouterSettings = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.showNoticeMessages !== undefined) {
            wrappers_1.BoolValue.encode({ value: message.showNoticeMessages }, writer.uint32(10).fork()).ldelim();
        }
        writer.uint32(18).fork();
        for (const v of message.timeQuantiles) {
            writer.double(v);
        }
        writer.ldelim();
        if (message.defaultRouteBehavior !== 0) {
            writer.uint32(32).int32(message.defaultRouteBehavior);
        }
        if (message.preferSameAvailabilityZone !== undefined) {
            wrappers_1.BoolValue.encode({ value: message.preferSameAvailabilityZone }, writer.uint32(42).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({}, baseRouterSettings);
        message.timeQuantiles = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.showNoticeMessages = wrappers_1.BoolValue.decode(reader, reader.uint32()).value;
                    break;
                case 2:
                    if ((tag & 7) === 2) {
                        const end2 = reader.uint32() + reader.pos;
                        while (reader.pos < end2) {
                            message.timeQuantiles.push(reader.double());
                        }
                    }
                    else {
                        message.timeQuantiles.push(reader.double());
                    }
                    break;
                case 4:
                    message.defaultRouteBehavior = reader.int32();
                    break;
                case 5:
                    message.preferSameAvailabilityZone = wrappers_1.BoolValue.decode(reader, reader.uint32()).value;
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseRouterSettings);
        message.showNoticeMessages =
            object.showNoticeMessages !== undefined && object.showNoticeMessages !== null
                ? Boolean(object.showNoticeMessages)
                : undefined;
        message.timeQuantiles = ((_a = object.timeQuantiles) !== null && _a !== void 0 ? _a : []).map((e) => Number(e));
        message.defaultRouteBehavior =
            object.defaultRouteBehavior !== undefined && object.defaultRouteBehavior !== null
                ? routerSettings_DefaultRouteBehaviorFromJSON(object.defaultRouteBehavior)
                : 0;
        message.preferSameAvailabilityZone =
            object.preferSameAvailabilityZone !== undefined &&
                object.preferSameAvailabilityZone !== null
                ? Boolean(object.preferSameAvailabilityZone)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.showNoticeMessages !== undefined &&
            (obj.showNoticeMessages = message.showNoticeMessages);
        if (message.timeQuantiles) {
            obj.timeQuantiles = message.timeQuantiles.map((e) => e);
        }
        else {
            obj.timeQuantiles = [];
        }
        message.defaultRouteBehavior !== undefined &&
            (obj.defaultRouteBehavior = routerSettings_DefaultRouteBehaviorToJSON(message.defaultRouteBehavior));
        message.preferSameAvailabilityZone !== undefined &&
            (obj.preferSameAvailabilityZone = message.preferSameAvailabilityZone);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d;
        const message = Object.assign({}, baseRouterSettings);
        message.showNoticeMessages = (_a = object.showNoticeMessages) !== null && _a !== void 0 ? _a : undefined;
        message.timeQuantiles = ((_b = object.timeQuantiles) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
        message.defaultRouteBehavior = (_c = object.defaultRouteBehavior) !== null && _c !== void 0 ? _c : 0;
        message.preferSameAvailabilityZone = (_d = object.preferSameAvailabilityZone) !== null && _d !== void 0 ? _d : undefined;
        return message;
    },
};
const baseCoordinatorSettings = {};
exports.CoordinatorSettings = {
    encode(_, writer = minimal_1.default.Writer.create()) {
        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({}, baseCoordinatorSettings);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(_) {
        const message = Object.assign({}, baseCoordinatorSettings);
        return message;
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
    fromPartial(_) {
        const message = Object.assign({}, baseCoordinatorSettings);
        return message;
    },
};
const basePostgreSQLSettings = {};
exports.PostgreSQLSettings = {
    encode(_, writer = minimal_1.default.Writer.create()) {
        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({}, basePostgreSQLSettings);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(_) {
        const message = Object.assign({}, basePostgreSQLSettings);
        return message;
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
    fromPartial(_) {
        const message = Object.assign({}, basePostgreSQLSettings);
        return message;
    },
};
const baseResources = { resourcePresetId: '', diskSize: 0, diskTypeId: '' };
exports.Resources = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.resourcePresetId !== '') {
            writer.uint32(10).string(message.resourcePresetId);
        }
        if (message.diskSize !== 0) {
            writer.uint32(16).int64(message.diskSize);
        }
        if (message.diskTypeId !== '') {
            writer.uint32(26).string(message.diskTypeId);
        }
        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({}, baseResources);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.resourcePresetId = reader.string();
                    break;
                case 2:
                    message.diskSize = longToNumber(reader.int64());
                    break;
                case 3:
                    message.diskTypeId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseResources);
        message.resourcePresetId =
            object.resourcePresetId !== undefined && object.resourcePresetId !== null
                ? String(object.resourcePresetId)
                : '';
        message.diskSize =
            object.diskSize !== undefined && object.diskSize !== null ? Number(object.diskSize) : 0;
        message.diskTypeId =
            object.diskTypeId !== undefined && object.diskTypeId !== null
                ? String(object.diskTypeId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.resourcePresetId !== undefined && (obj.resourcePresetId = message.resourcePresetId);
        message.diskSize !== undefined && (obj.diskSize = Math.round(message.diskSize));
        message.diskTypeId !== undefined && (obj.diskTypeId = message.diskTypeId);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseResources);
        message.resourcePresetId = (_a = object.resourcePresetId) !== null && _a !== void 0 ? _a : '';
        message.diskSize = (_b = object.diskSize) !== null && _b !== void 0 ? _b : 0;
        message.diskTypeId = (_c = object.diskTypeId) !== null && _c !== void 0 ? _c : '';
        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();
}
