"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RoutingInstance_VpcManualInfo = exports.RoutingInstance_VpcAzInfo = exports.RoutingInstance_VpcInfo = exports.RoutingInstance_CicPrivateConnectionInfo = exports.RoutingInstance_LabelsEntry = exports.RoutingInstance = exports.routingInstance_StatusToJSON = exports.routingInstance_StatusFromJSON = exports.RoutingInstance_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.cloudrouter.v1';
var RoutingInstance_Status;
(function (RoutingInstance_Status) {
    RoutingInstance_Status[RoutingInstance_Status["STATUS_UNSPECIFIED"] = 0] = "STATUS_UNSPECIFIED";
    RoutingInstance_Status[RoutingInstance_Status["CREATING"] = 1] = "CREATING";
    RoutingInstance_Status[RoutingInstance_Status["UPDATING"] = 2] = "UPDATING";
    RoutingInstance_Status[RoutingInstance_Status["DELETING"] = 3] = "DELETING";
    RoutingInstance_Status[RoutingInstance_Status["ACTIVE"] = 4] = "ACTIVE";
    RoutingInstance_Status[RoutingInstance_Status["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(RoutingInstance_Status = exports.RoutingInstance_Status || (exports.RoutingInstance_Status = {}));
function routingInstance_StatusFromJSON(object) {
    switch (object) {
        case 0:
        case 'STATUS_UNSPECIFIED':
            return RoutingInstance_Status.STATUS_UNSPECIFIED;
        case 1:
        case 'CREATING':
            return RoutingInstance_Status.CREATING;
        case 2:
        case 'UPDATING':
            return RoutingInstance_Status.UPDATING;
        case 3:
        case 'DELETING':
            return RoutingInstance_Status.DELETING;
        case 4:
        case 'ACTIVE':
            return RoutingInstance_Status.ACTIVE;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return RoutingInstance_Status.UNRECOGNIZED;
    }
}
exports.routingInstance_StatusFromJSON = routingInstance_StatusFromJSON;
function routingInstance_StatusToJSON(object) {
    switch (object) {
        case RoutingInstance_Status.STATUS_UNSPECIFIED:
            return 'STATUS_UNSPECIFIED';
        case RoutingInstance_Status.CREATING:
            return 'CREATING';
        case RoutingInstance_Status.UPDATING:
            return 'UPDATING';
        case RoutingInstance_Status.DELETING:
            return 'DELETING';
        case RoutingInstance_Status.ACTIVE:
            return 'ACTIVE';
        default:
            return 'UNKNOWN';
    }
}
exports.routingInstance_StatusToJSON = routingInstance_StatusToJSON;
const baseRoutingInstance = {
    id: '',
    name: '',
    description: '',
    folderId: '',
    regionId: '',
    status: 0,
};
exports.RoutingInstance = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.id !== '') {
            writer.uint32(10).string(message.id);
        }
        if (message.name !== '') {
            writer.uint32(18).string(message.name);
        }
        if (message.description !== '') {
            writer.uint32(26).string(message.description);
        }
        if (message.folderId !== '') {
            writer.uint32(42).string(message.folderId);
        }
        if (message.regionId !== '') {
            writer.uint32(50).string(message.regionId);
        }
        for (const v of message.vpcInfo) {
            exports.RoutingInstance_VpcInfo.encode(v, writer.uint32(58).fork()).ldelim();
        }
        for (const v of message.cicPrivateConnectionInfo) {
            exports.RoutingInstance_CicPrivateConnectionInfo.encode(v, writer.uint32(66).fork()).ldelim();
        }
        if (message.status !== 0) {
            writer.uint32(72).int32(message.status);
        }
        if (message.createdAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(90).fork()).ldelim();
        }
        Object.entries(message.labels).forEach(([key, value]) => {
            exports.RoutingInstance_LabelsEntry.encode({ key: key, value }, writer.uint32(194).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({}, baseRoutingInstance);
        message.vpcInfo = [];
        message.cicPrivateConnectionInfo = [];
        message.labels = {};
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.id = reader.string();
                    break;
                case 2:
                    message.name = reader.string();
                    break;
                case 3:
                    message.description = reader.string();
                    break;
                case 5:
                    message.folderId = reader.string();
                    break;
                case 6:
                    message.regionId = reader.string();
                    break;
                case 7:
                    message.vpcInfo.push(exports.RoutingInstance_VpcInfo.decode(reader, reader.uint32()));
                    break;
                case 8:
                    message.cicPrivateConnectionInfo.push(exports.RoutingInstance_CicPrivateConnectionInfo.decode(reader, reader.uint32()));
                    break;
                case 9:
                    message.status = reader.int32();
                    break;
                case 11:
                    message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 24:
                    const entry24 = exports.RoutingInstance_LabelsEntry.decode(reader, reader.uint32());
                    if (entry24.value !== undefined) {
                        message.labels[entry24.key] = entry24.value;
                    }
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a, _b, _c;
        const message = Object.assign({}, baseRoutingInstance);
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        message.regionId =
            object.regionId !== undefined && object.regionId !== null
                ? String(object.regionId)
                : '';
        message.vpcInfo = ((_a = object.vpcInfo) !== null && _a !== void 0 ? _a : []).map((e) => exports.RoutingInstance_VpcInfo.fromJSON(e));
        message.cicPrivateConnectionInfo = ((_b = object.cicPrivateConnectionInfo) !== null && _b !== void 0 ? _b : []).map((e) => exports.RoutingInstance_CicPrivateConnectionInfo.fromJSON(e));
        message.status =
            object.status !== undefined && object.status !== null
                ? routingInstance_StatusFromJSON(object.status)
                : 0;
        message.createdAt =
            object.createdAt !== undefined && object.createdAt !== null
                ? fromJsonTimestamp(object.createdAt)
                : undefined;
        message.labels = Object.entries((_c = object.labels) !== null && _c !== void 0 ? _c : {}).reduce((acc, [key, value]) => {
            acc[key] = String(value);
            return acc;
        }, {});
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.id !== undefined && (obj.id = message.id);
        message.name !== undefined && (obj.name = message.name);
        message.description !== undefined && (obj.description = message.description);
        message.folderId !== undefined && (obj.folderId = message.folderId);
        message.regionId !== undefined && (obj.regionId = message.regionId);
        if (message.vpcInfo) {
            obj.vpcInfo = message.vpcInfo.map((e) => e ? exports.RoutingInstance_VpcInfo.toJSON(e) : undefined);
        }
        else {
            obj.vpcInfo = [];
        }
        if (message.cicPrivateConnectionInfo) {
            obj.cicPrivateConnectionInfo = message.cicPrivateConnectionInfo.map((e) => e ? exports.RoutingInstance_CicPrivateConnectionInfo.toJSON(e) : undefined);
        }
        else {
            obj.cicPrivateConnectionInfo = [];
        }
        message.status !== undefined && (obj.status = routingInstance_StatusToJSON(message.status));
        message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString());
        obj.labels = {};
        if (message.labels) {
            Object.entries(message.labels).forEach(([k, v]) => {
                obj.labels[k] = v;
            });
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
        const message = Object.assign({}, baseRoutingInstance);
        message.id = (_a = object.id) !== null && _a !== void 0 ? _a : '';
        message.name = (_b = object.name) !== null && _b !== void 0 ? _b : '';
        message.description = (_c = object.description) !== null && _c !== void 0 ? _c : '';
        message.folderId = (_d = object.folderId) !== null && _d !== void 0 ? _d : '';
        message.regionId = (_e = object.regionId) !== null && _e !== void 0 ? _e : '';
        message.vpcInfo = ((_f = object.vpcInfo) === null || _f === void 0 ? void 0 : _f.map((e) => exports.RoutingInstance_VpcInfo.fromPartial(e))) || [];
        message.cicPrivateConnectionInfo =
            ((_g = object.cicPrivateConnectionInfo) === null || _g === void 0 ? void 0 : _g.map((e) => exports.RoutingInstance_CicPrivateConnectionInfo.fromPartial(e))) || [];
        message.status = (_h = object.status) !== null && _h !== void 0 ? _h : 0;
        message.createdAt = (_j = object.createdAt) !== null && _j !== void 0 ? _j : undefined;
        message.labels = Object.entries((_k = object.labels) !== null && _k !== void 0 ? _k : {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = String(value);
            }
            return acc;
        }, {});
        return message;
    },
};
const baseRoutingInstance_LabelsEntry = { key: '', value: '' };
exports.RoutingInstance_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({}, baseRoutingInstance_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({}, baseRoutingInstance_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({}, baseRoutingInstance_LabelsEntry);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseRoutingInstance_CicPrivateConnectionInfo = { cicPrivateConnectionId: '' };
exports.RoutingInstance_CicPrivateConnectionInfo = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.cicPrivateConnectionId !== '') {
            writer.uint32(10).string(message.cicPrivateConnectionId);
        }
        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({}, baseRoutingInstance_CicPrivateConnectionInfo);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.cicPrivateConnectionId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseRoutingInstance_CicPrivateConnectionInfo);
        message.cicPrivateConnectionId =
            object.cicPrivateConnectionId !== undefined && object.cicPrivateConnectionId !== null
                ? String(object.cicPrivateConnectionId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.cicPrivateConnectionId !== undefined &&
            (obj.cicPrivateConnectionId = message.cicPrivateConnectionId);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseRoutingInstance_CicPrivateConnectionInfo);
        message.cicPrivateConnectionId = (_a = object.cicPrivateConnectionId) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseRoutingInstance_VpcInfo = { vpcNetworkId: '' };
exports.RoutingInstance_VpcInfo = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.vpcNetworkId !== '') {
            writer.uint32(10).string(message.vpcNetworkId);
        }
        for (const v of message.azInfos) {
            exports.RoutingInstance_VpcAzInfo.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({}, baseRoutingInstance_VpcInfo);
        message.azInfos = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.vpcNetworkId = reader.string();
                    break;
                case 2:
                    message.azInfos.push(exports.RoutingInstance_VpcAzInfo.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseRoutingInstance_VpcInfo);
        message.vpcNetworkId =
            object.vpcNetworkId !== undefined && object.vpcNetworkId !== null
                ? String(object.vpcNetworkId)
                : '';
        message.azInfos = ((_a = object.azInfos) !== null && _a !== void 0 ? _a : []).map((e) => exports.RoutingInstance_VpcAzInfo.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.vpcNetworkId !== undefined && (obj.vpcNetworkId = message.vpcNetworkId);
        if (message.azInfos) {
            obj.azInfos = message.azInfos.map((e) => e ? exports.RoutingInstance_VpcAzInfo.toJSON(e) : undefined);
        }
        else {
            obj.azInfos = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseRoutingInstance_VpcInfo);
        message.vpcNetworkId = (_a = object.vpcNetworkId) !== null && _a !== void 0 ? _a : '';
        message.azInfos =
            ((_b = object.azInfos) === null || _b === void 0 ? void 0 : _b.map((e) => exports.RoutingInstance_VpcAzInfo.fromPartial(e))) || [];
        return message;
    },
};
const baseRoutingInstance_VpcAzInfo = {};
exports.RoutingInstance_VpcAzInfo = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.manualInfo !== undefined) {
            exports.RoutingInstance_VpcManualInfo.encode(message.manualInfo, 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({}, baseRoutingInstance_VpcAzInfo);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 2:
                    message.manualInfo = exports.RoutingInstance_VpcManualInfo.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseRoutingInstance_VpcAzInfo);
        message.manualInfo =
            object.manualInfo !== undefined && object.manualInfo !== null
                ? exports.RoutingInstance_VpcManualInfo.fromJSON(object.manualInfo)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.manualInfo !== undefined &&
            (obj.manualInfo = message.manualInfo
                ? exports.RoutingInstance_VpcManualInfo.toJSON(message.manualInfo)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseRoutingInstance_VpcAzInfo);
        message.manualInfo =
            object.manualInfo !== undefined && object.manualInfo !== null
                ? exports.RoutingInstance_VpcManualInfo.fromPartial(object.manualInfo)
                : undefined;
        return message;
    },
};
const baseRoutingInstance_VpcManualInfo = { azId: '', prefixes: '' };
exports.RoutingInstance_VpcManualInfo = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.azId !== '') {
            writer.uint32(10).string(message.azId);
        }
        for (const v of message.prefixes) {
            writer.uint32(42).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({}, baseRoutingInstance_VpcManualInfo);
        message.prefixes = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.azId = reader.string();
                    break;
                case 5:
                    message.prefixes.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseRoutingInstance_VpcManualInfo);
        message.azId = object.azId !== undefined && object.azId !== null ? String(object.azId) : '';
        message.prefixes = ((_a = object.prefixes) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.azId !== undefined && (obj.azId = message.azId);
        if (message.prefixes) {
            obj.prefixes = message.prefixes.map((e) => e);
        }
        else {
            obj.prefixes = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseRoutingInstance_VpcManualInfo);
        message.azId = (_a = object.azId) !== null && _a !== void 0 ? _a : '';
        message.prefixes = ((_b = object.prefixes) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
        return message;
    },
};
function toTimestamp(date) {
    const seconds = date.getTime() / 1000;
    const nanos = (date.getTime() % 1000) * 1000000;
    return { seconds, nanos };
}
function fromTimestamp(t) {
    let millis = t.seconds * 1000;
    millis += t.nanos / 1000000;
    return new Date(millis);
}
function fromJsonTimestamp(o) {
    if (o instanceof Date) {
        return o;
    }
    else if (typeof o === 'string') {
        return new Date(o);
    }
    else {
        return fromTimestamp(timestamp_1.Timestamp.fromJSON(o));
    }
}
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
