"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PublicConnection_LabelsEntry = exports.PublicConnection = exports.publicConnection_StatusToJSON = exports.publicConnection_StatusFromJSON = exports.PublicConnection_Status = exports.publicConnection_CloudServiceTypeToJSON = exports.publicConnection_CloudServiceTypeFromJSON = exports.PublicConnection_CloudServiceType = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const peering_1 = require("../../../../yandex/cloud/cic/v1/peering");
const timestamp_1 = require("../../../../google/protobuf/timestamp");
const wrappers_1 = require("../../../../google/protobuf/wrappers");
exports.protobufPackage = 'yandex.cloud.cic.v1';
var PublicConnection_CloudServiceType;
(function (PublicConnection_CloudServiceType) {
    PublicConnection_CloudServiceType[PublicConnection_CloudServiceType["CLOUD_SERVICE_TYPE_UNSPECIFIED"] = 0] = "CLOUD_SERVICE_TYPE_UNSPECIFIED";
    /** @deprecated */
    PublicConnection_CloudServiceType[PublicConnection_CloudServiceType["CLOUD_SERVICE_YANDEX"] = 1] = "CLOUD_SERVICE_YANDEX";
    PublicConnection_CloudServiceType[PublicConnection_CloudServiceType["CLOUD_SERVICE_ALL_PUBLIC"] = 2] = "CLOUD_SERVICE_ALL_PUBLIC";
    PublicConnection_CloudServiceType[PublicConnection_CloudServiceType["CLOUD_SERVICE_S3"] = 3] = "CLOUD_SERVICE_S3";
    PublicConnection_CloudServiceType[PublicConnection_CloudServiceType["CLOUD_SERVICE_ML"] = 4] = "CLOUD_SERVICE_ML";
    PublicConnection_CloudServiceType[PublicConnection_CloudServiceType["CLOUD_SERVICE_APIGW"] = 5] = "CLOUD_SERVICE_APIGW";
    PublicConnection_CloudServiceType[PublicConnection_CloudServiceType["CLOUD_SERVICE_CONTAINER_REGISTRY"] = 6] = "CLOUD_SERVICE_CONTAINER_REGISTRY";
    PublicConnection_CloudServiceType[PublicConnection_CloudServiceType["CLOUD_SERVICE_CONSOLE"] = 7] = "CLOUD_SERVICE_CONSOLE";
    PublicConnection_CloudServiceType[PublicConnection_CloudServiceType["CLOUD_SERVICE_MONITORING"] = 8] = "CLOUD_SERVICE_MONITORING";
    PublicConnection_CloudServiceType[PublicConnection_CloudServiceType["CLOUD_SERVICE_YANDEX_GPT"] = 9] = "CLOUD_SERVICE_YANDEX_GPT";
    PublicConnection_CloudServiceType[PublicConnection_CloudServiceType["CLOUD_SERVICES_ALL_API_ENDPOINT"] = 10] = "CLOUD_SERVICES_ALL_API_ENDPOINT";
    PublicConnection_CloudServiceType[PublicConnection_CloudServiceType["CLOUD_SERVICE_YMQ"] = 11] = "CLOUD_SERVICE_YMQ";
    PublicConnection_CloudServiceType[PublicConnection_CloudServiceType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(PublicConnection_CloudServiceType = exports.PublicConnection_CloudServiceType || (exports.PublicConnection_CloudServiceType = {}));
function publicConnection_CloudServiceTypeFromJSON(object) {
    switch (object) {
        case 0:
        case 'CLOUD_SERVICE_TYPE_UNSPECIFIED':
            return PublicConnection_CloudServiceType.CLOUD_SERVICE_TYPE_UNSPECIFIED;
        case 1:
        case 'CLOUD_SERVICE_YANDEX':
            return PublicConnection_CloudServiceType.CLOUD_SERVICE_YANDEX;
        case 2:
        case 'CLOUD_SERVICE_ALL_PUBLIC':
            return PublicConnection_CloudServiceType.CLOUD_SERVICE_ALL_PUBLIC;
        case 3:
        case 'CLOUD_SERVICE_S3':
            return PublicConnection_CloudServiceType.CLOUD_SERVICE_S3;
        case 4:
        case 'CLOUD_SERVICE_ML':
            return PublicConnection_CloudServiceType.CLOUD_SERVICE_ML;
        case 5:
        case 'CLOUD_SERVICE_APIGW':
            return PublicConnection_CloudServiceType.CLOUD_SERVICE_APIGW;
        case 6:
        case 'CLOUD_SERVICE_CONTAINER_REGISTRY':
            return PublicConnection_CloudServiceType.CLOUD_SERVICE_CONTAINER_REGISTRY;
        case 7:
        case 'CLOUD_SERVICE_CONSOLE':
            return PublicConnection_CloudServiceType.CLOUD_SERVICE_CONSOLE;
        case 8:
        case 'CLOUD_SERVICE_MONITORING':
            return PublicConnection_CloudServiceType.CLOUD_SERVICE_MONITORING;
        case 9:
        case 'CLOUD_SERVICE_YANDEX_GPT':
            return PublicConnection_CloudServiceType.CLOUD_SERVICE_YANDEX_GPT;
        case 10:
        case 'CLOUD_SERVICES_ALL_API_ENDPOINT':
            return PublicConnection_CloudServiceType.CLOUD_SERVICES_ALL_API_ENDPOINT;
        case 11:
        case 'CLOUD_SERVICE_YMQ':
            return PublicConnection_CloudServiceType.CLOUD_SERVICE_YMQ;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return PublicConnection_CloudServiceType.UNRECOGNIZED;
    }
}
exports.publicConnection_CloudServiceTypeFromJSON = publicConnection_CloudServiceTypeFromJSON;
function publicConnection_CloudServiceTypeToJSON(object) {
    switch (object) {
        case PublicConnection_CloudServiceType.CLOUD_SERVICE_TYPE_UNSPECIFIED:
            return 'CLOUD_SERVICE_TYPE_UNSPECIFIED';
        case PublicConnection_CloudServiceType.CLOUD_SERVICE_YANDEX:
            return 'CLOUD_SERVICE_YANDEX';
        case PublicConnection_CloudServiceType.CLOUD_SERVICE_ALL_PUBLIC:
            return 'CLOUD_SERVICE_ALL_PUBLIC';
        case PublicConnection_CloudServiceType.CLOUD_SERVICE_S3:
            return 'CLOUD_SERVICE_S3';
        case PublicConnection_CloudServiceType.CLOUD_SERVICE_ML:
            return 'CLOUD_SERVICE_ML';
        case PublicConnection_CloudServiceType.CLOUD_SERVICE_APIGW:
            return 'CLOUD_SERVICE_APIGW';
        case PublicConnection_CloudServiceType.CLOUD_SERVICE_CONTAINER_REGISTRY:
            return 'CLOUD_SERVICE_CONTAINER_REGISTRY';
        case PublicConnection_CloudServiceType.CLOUD_SERVICE_CONSOLE:
            return 'CLOUD_SERVICE_CONSOLE';
        case PublicConnection_CloudServiceType.CLOUD_SERVICE_MONITORING:
            return 'CLOUD_SERVICE_MONITORING';
        case PublicConnection_CloudServiceType.CLOUD_SERVICE_YANDEX_GPT:
            return 'CLOUD_SERVICE_YANDEX_GPT';
        case PublicConnection_CloudServiceType.CLOUD_SERVICES_ALL_API_ENDPOINT:
            return 'CLOUD_SERVICES_ALL_API_ENDPOINT';
        case PublicConnection_CloudServiceType.CLOUD_SERVICE_YMQ:
            return 'CLOUD_SERVICE_YMQ';
        default:
            return 'UNKNOWN';
    }
}
exports.publicConnection_CloudServiceTypeToJSON = publicConnection_CloudServiceTypeToJSON;
var PublicConnection_Status;
(function (PublicConnection_Status) {
    PublicConnection_Status[PublicConnection_Status["STATUS_UNSPECIFIED"] = 0] = "STATUS_UNSPECIFIED";
    PublicConnection_Status[PublicConnection_Status["CREATING"] = 1] = "CREATING";
    PublicConnection_Status[PublicConnection_Status["UPDATING"] = 2] = "UPDATING";
    PublicConnection_Status[PublicConnection_Status["DELETING"] = 3] = "DELETING";
    PublicConnection_Status[PublicConnection_Status["ACTIVE"] = 4] = "ACTIVE";
    PublicConnection_Status[PublicConnection_Status["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(PublicConnection_Status = exports.PublicConnection_Status || (exports.PublicConnection_Status = {}));
function publicConnection_StatusFromJSON(object) {
    switch (object) {
        case 0:
        case 'STATUS_UNSPECIFIED':
            return PublicConnection_Status.STATUS_UNSPECIFIED;
        case 1:
        case 'CREATING':
            return PublicConnection_Status.CREATING;
        case 2:
        case 'UPDATING':
            return PublicConnection_Status.UPDATING;
        case 3:
        case 'DELETING':
            return PublicConnection_Status.DELETING;
        case 4:
        case 'ACTIVE':
            return PublicConnection_Status.ACTIVE;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return PublicConnection_Status.UNRECOGNIZED;
    }
}
exports.publicConnection_StatusFromJSON = publicConnection_StatusFromJSON;
function publicConnection_StatusToJSON(object) {
    switch (object) {
        case PublicConnection_Status.STATUS_UNSPECIFIED:
            return 'STATUS_UNSPECIFIED';
        case PublicConnection_Status.CREATING:
            return 'CREATING';
        case PublicConnection_Status.UPDATING:
            return 'UPDATING';
        case PublicConnection_Status.DELETING:
            return 'DELETING';
        case PublicConnection_Status.ACTIVE:
            return 'ACTIVE';
        default:
            return 'UNKNOWN';
    }
}
exports.publicConnection_StatusToJSON = publicConnection_StatusToJSON;
const basePublicConnection = {
    id: '',
    name: '',
    description: '',
    folderId: '',
    regionId: '',
    trunkConnectionId: '',
    ipv4AllowedServiceTypes: 0,
    ipv4PeerAnnouncedPrefixes: '',
    status: 0,
};
exports.PublicConnection = {
    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);
        }
        if (message.trunkConnectionId !== '') {
            writer.uint32(58).string(message.trunkConnectionId);
        }
        if (message.vlanId !== undefined) {
            wrappers_1.Int64Value.encode({ value: message.vlanId }, writer.uint32(66).fork()).ldelim();
        }
        if (message.ipv4Peering !== undefined) {
            peering_1.Peering.encode(message.ipv4Peering, writer.uint32(74).fork()).ldelim();
        }
        writer.uint32(90).fork();
        for (const v of message.ipv4AllowedServiceTypes) {
            writer.int32(v);
        }
        writer.ldelim();
        for (const v of message.ipv4PeerAnnouncedPrefixes) {
            writer.uint32(106).string(v);
        }
        Object.entries(message.labels).forEach(([key, value]) => {
            exports.PublicConnection_LabelsEntry.encode({ key: key, value }, writer.uint32(146).fork()).ldelim();
        });
        if (message.status !== 0) {
            writer.uint32(152).int32(message.status);
        }
        if (message.createdAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(170).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({}, basePublicConnection);
        message.ipv4AllowedServiceTypes = [];
        message.ipv4PeerAnnouncedPrefixes = [];
        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.trunkConnectionId = reader.string();
                    break;
                case 8:
                    message.vlanId = wrappers_1.Int64Value.decode(reader, reader.uint32()).value;
                    break;
                case 9:
                    message.ipv4Peering = peering_1.Peering.decode(reader, reader.uint32());
                    break;
                case 11:
                    if ((tag & 7) === 2) {
                        const end2 = reader.uint32() + reader.pos;
                        while (reader.pos < end2) {
                            message.ipv4AllowedServiceTypes.push(reader.int32());
                        }
                    }
                    else {
                        message.ipv4AllowedServiceTypes.push(reader.int32());
                    }
                    break;
                case 13:
                    message.ipv4PeerAnnouncedPrefixes.push(reader.string());
                    break;
                case 18:
                    const entry18 = exports.PublicConnection_LabelsEntry.decode(reader, reader.uint32());
                    if (entry18.value !== undefined) {
                        message.labels[entry18.key] = entry18.value;
                    }
                    break;
                case 19:
                    message.status = reader.int32();
                    break;
                case 21:
                    message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a, _b, _c;
        const message = Object.assign({}, basePublicConnection);
        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.trunkConnectionId =
            object.trunkConnectionId !== undefined && object.trunkConnectionId !== null
                ? String(object.trunkConnectionId)
                : '';
        message.vlanId =
            object.vlanId !== undefined && object.vlanId !== null
                ? Number(object.vlanId)
                : undefined;
        message.ipv4Peering =
            object.ipv4Peering !== undefined && object.ipv4Peering !== null
                ? peering_1.Peering.fromJSON(object.ipv4Peering)
                : undefined;
        message.ipv4AllowedServiceTypes = ((_a = object.ipv4AllowedServiceTypes) !== null && _a !== void 0 ? _a : []).map((e) => publicConnection_CloudServiceTypeFromJSON(e));
        message.ipv4PeerAnnouncedPrefixes = ((_b = object.ipv4PeerAnnouncedPrefixes) !== null && _b !== void 0 ? _b : []).map((e) => String(e));
        message.labels = Object.entries((_c = object.labels) !== null && _c !== void 0 ? _c : {}).reduce((acc, [key, value]) => {
            acc[key] = String(value);
            return acc;
        }, {});
        message.status =
            object.status !== undefined && object.status !== null
                ? publicConnection_StatusFromJSON(object.status)
                : 0;
        message.createdAt =
            object.createdAt !== undefined && object.createdAt !== null
                ? fromJsonTimestamp(object.createdAt)
                : undefined;
        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);
        message.trunkConnectionId !== undefined &&
            (obj.trunkConnectionId = message.trunkConnectionId);
        message.vlanId !== undefined && (obj.vlanId = message.vlanId);
        message.ipv4Peering !== undefined &&
            (obj.ipv4Peering = message.ipv4Peering
                ? peering_1.Peering.toJSON(message.ipv4Peering)
                : undefined);
        if (message.ipv4AllowedServiceTypes) {
            obj.ipv4AllowedServiceTypes = message.ipv4AllowedServiceTypes.map((e) => publicConnection_CloudServiceTypeToJSON(e));
        }
        else {
            obj.ipv4AllowedServiceTypes = [];
        }
        if (message.ipv4PeerAnnouncedPrefixes) {
            obj.ipv4PeerAnnouncedPrefixes = message.ipv4PeerAnnouncedPrefixes.map((e) => e);
        }
        else {
            obj.ipv4PeerAnnouncedPrefixes = [];
        }
        obj.labels = {};
        if (message.labels) {
            Object.entries(message.labels).forEach(([k, v]) => {
                obj.labels[k] = v;
            });
        }
        message.status !== undefined &&
            (obj.status = publicConnection_StatusToJSON(message.status));
        message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString());
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
        const message = Object.assign({}, basePublicConnection);
        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.trunkConnectionId = (_f = object.trunkConnectionId) !== null && _f !== void 0 ? _f : '';
        message.vlanId = (_g = object.vlanId) !== null && _g !== void 0 ? _g : undefined;
        message.ipv4Peering =
            object.ipv4Peering !== undefined && object.ipv4Peering !== null
                ? peering_1.Peering.fromPartial(object.ipv4Peering)
                : undefined;
        message.ipv4AllowedServiceTypes = ((_h = object.ipv4AllowedServiceTypes) === null || _h === void 0 ? void 0 : _h.map((e) => e)) || [];
        message.ipv4PeerAnnouncedPrefixes = ((_j = object.ipv4PeerAnnouncedPrefixes) === null || _j === void 0 ? void 0 : _j.map((e) => e)) || [];
        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;
        }, {});
        message.status = (_l = object.status) !== null && _l !== void 0 ? _l : 0;
        message.createdAt = (_m = object.createdAt) !== null && _m !== void 0 ? _m : undefined;
        return message;
    },
};
const basePublicConnection_LabelsEntry = { key: '', value: '' };
exports.PublicConnection_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({}, basePublicConnection_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({}, basePublicConnection_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({}, basePublicConnection_LabelsEntry);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
        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();
}
