"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PrivateEndpoint_EndpointAddress = exports.PrivateEndpoint_DnsOptions = exports.PrivateEndpoint_ObjectStorage = exports.PrivateEndpoint_LabelsEntry = exports.PrivateEndpoint = exports.privateEndpoint_StatusToJSON = exports.privateEndpoint_StatusFromJSON = exports.PrivateEndpoint_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.vpc.v1.privatelink';
/** Status of the private endpoint. */
var PrivateEndpoint_Status;
(function (PrivateEndpoint_Status) {
    PrivateEndpoint_Status[PrivateEndpoint_Status["STATUS_UNSPECIFIED"] = 0] = "STATUS_UNSPECIFIED";
    /** PENDING - Private endpoint is still creating / updating. */
    PrivateEndpoint_Status[PrivateEndpoint_Status["PENDING"] = 1] = "PENDING";
    /** AVAILABLE - Private endpoint is available. */
    PrivateEndpoint_Status[PrivateEndpoint_Status["AVAILABLE"] = 2] = "AVAILABLE";
    /** DELETING - Private endpoint is deleting. */
    PrivateEndpoint_Status[PrivateEndpoint_Status["DELETING"] = 3] = "DELETING";
    PrivateEndpoint_Status[PrivateEndpoint_Status["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(PrivateEndpoint_Status = exports.PrivateEndpoint_Status || (exports.PrivateEndpoint_Status = {}));
function privateEndpoint_StatusFromJSON(object) {
    switch (object) {
        case 0:
        case 'STATUS_UNSPECIFIED':
            return PrivateEndpoint_Status.STATUS_UNSPECIFIED;
        case 1:
        case 'PENDING':
            return PrivateEndpoint_Status.PENDING;
        case 2:
        case 'AVAILABLE':
            return PrivateEndpoint_Status.AVAILABLE;
        case 3:
        case 'DELETING':
            return PrivateEndpoint_Status.DELETING;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return PrivateEndpoint_Status.UNRECOGNIZED;
    }
}
exports.privateEndpoint_StatusFromJSON = privateEndpoint_StatusFromJSON;
function privateEndpoint_StatusToJSON(object) {
    switch (object) {
        case PrivateEndpoint_Status.STATUS_UNSPECIFIED:
            return 'STATUS_UNSPECIFIED';
        case PrivateEndpoint_Status.PENDING:
            return 'PENDING';
        case PrivateEndpoint_Status.AVAILABLE:
            return 'AVAILABLE';
        case PrivateEndpoint_Status.DELETING:
            return 'DELETING';
        default:
            return 'UNKNOWN';
    }
}
exports.privateEndpoint_StatusToJSON = privateEndpoint_StatusToJSON;
const basePrivateEndpoint = {
    id: '',
    folderId: '',
    name: '',
    description: '',
    networkId: '',
    status: 0,
};
exports.PrivateEndpoint = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.id !== '') {
            writer.uint32(10).string(message.id);
        }
        if (message.folderId !== '') {
            writer.uint32(18).string(message.folderId);
        }
        if (message.createdAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(26).fork()).ldelim();
        }
        if (message.name !== '') {
            writer.uint32(34).string(message.name);
        }
        if (message.description !== '') {
            writer.uint32(42).string(message.description);
        }
        Object.entries(message.labels).forEach(([key, value]) => {
            exports.PrivateEndpoint_LabelsEntry.encode({ key: key, value }, writer.uint32(50).fork()).ldelim();
        });
        if (message.networkId !== '') {
            writer.uint32(58).string(message.networkId);
        }
        if (message.status !== 0) {
            writer.uint32(64).int32(message.status);
        }
        if (message.address !== undefined) {
            exports.PrivateEndpoint_EndpointAddress.encode(message.address, writer.uint32(74).fork()).ldelim();
        }
        if (message.dnsOptions !== undefined) {
            exports.PrivateEndpoint_DnsOptions.encode(message.dnsOptions, writer.uint32(82).fork()).ldelim();
        }
        if (message.objectStorage !== undefined) {
            exports.PrivateEndpoint_ObjectStorage.encode(message.objectStorage, writer.uint32(90).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({}, basePrivateEndpoint);
        message.labels = {};
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.id = reader.string();
                    break;
                case 2:
                    message.folderId = reader.string();
                    break;
                case 3:
                    message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 4:
                    message.name = reader.string();
                    break;
                case 5:
                    message.description = reader.string();
                    break;
                case 6:
                    const entry6 = exports.PrivateEndpoint_LabelsEntry.decode(reader, reader.uint32());
                    if (entry6.value !== undefined) {
                        message.labels[entry6.key] = entry6.value;
                    }
                    break;
                case 7:
                    message.networkId = reader.string();
                    break;
                case 8:
                    message.status = reader.int32();
                    break;
                case 9:
                    message.address = exports.PrivateEndpoint_EndpointAddress.decode(reader, reader.uint32());
                    break;
                case 10:
                    message.dnsOptions = exports.PrivateEndpoint_DnsOptions.decode(reader, reader.uint32());
                    break;
                case 11:
                    message.objectStorage = exports.PrivateEndpoint_ObjectStorage.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, basePrivateEndpoint);
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        message.createdAt =
            object.createdAt !== undefined && object.createdAt !== null
                ? fromJsonTimestamp(object.createdAt)
                : undefined;
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.description =
            object.description !== undefined && object.description !== null
                ? String(object.description)
                : '';
        message.labels = Object.entries((_a = object.labels) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
            acc[key] = String(value);
            return acc;
        }, {});
        message.networkId =
            object.networkId !== undefined && object.networkId !== null
                ? String(object.networkId)
                : '';
        message.status =
            object.status !== undefined && object.status !== null
                ? privateEndpoint_StatusFromJSON(object.status)
                : 0;
        message.address =
            object.address !== undefined && object.address !== null
                ? exports.PrivateEndpoint_EndpointAddress.fromJSON(object.address)
                : undefined;
        message.dnsOptions =
            object.dnsOptions !== undefined && object.dnsOptions !== null
                ? exports.PrivateEndpoint_DnsOptions.fromJSON(object.dnsOptions)
                : undefined;
        message.objectStorage =
            object.objectStorage !== undefined && object.objectStorage !== null
                ? exports.PrivateEndpoint_ObjectStorage.fromJSON(object.objectStorage)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.id !== undefined && (obj.id = message.id);
        message.folderId !== undefined && (obj.folderId = message.folderId);
        message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString());
        message.name !== undefined && (obj.name = message.name);
        message.description !== undefined && (obj.description = message.description);
        obj.labels = {};
        if (message.labels) {
            Object.entries(message.labels).forEach(([k, v]) => {
                obj.labels[k] = v;
            });
        }
        message.networkId !== undefined && (obj.networkId = message.networkId);
        message.status !== undefined && (obj.status = privateEndpoint_StatusToJSON(message.status));
        message.address !== undefined &&
            (obj.address = message.address
                ? exports.PrivateEndpoint_EndpointAddress.toJSON(message.address)
                : undefined);
        message.dnsOptions !== undefined &&
            (obj.dnsOptions = message.dnsOptions
                ? exports.PrivateEndpoint_DnsOptions.toJSON(message.dnsOptions)
                : undefined);
        message.objectStorage !== undefined &&
            (obj.objectStorage = message.objectStorage
                ? exports.PrivateEndpoint_ObjectStorage.toJSON(message.objectStorage)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g, _h;
        const message = Object.assign({}, basePrivateEndpoint);
        message.id = (_a = object.id) !== null && _a !== void 0 ? _a : '';
        message.folderId = (_b = object.folderId) !== null && _b !== void 0 ? _b : '';
        message.createdAt = (_c = object.createdAt) !== null && _c !== void 0 ? _c : undefined;
        message.name = (_d = object.name) !== null && _d !== void 0 ? _d : '';
        message.description = (_e = object.description) !== null && _e !== void 0 ? _e : '';
        message.labels = Object.entries((_f = object.labels) !== null && _f !== void 0 ? _f : {}).reduce((acc, [key, value]) => {
            if (value !== undefined) {
                acc[key] = String(value);
            }
            return acc;
        }, {});
        message.networkId = (_g = object.networkId) !== null && _g !== void 0 ? _g : '';
        message.status = (_h = object.status) !== null && _h !== void 0 ? _h : 0;
        message.address =
            object.address !== undefined && object.address !== null
                ? exports.PrivateEndpoint_EndpointAddress.fromPartial(object.address)
                : undefined;
        message.dnsOptions =
            object.dnsOptions !== undefined && object.dnsOptions !== null
                ? exports.PrivateEndpoint_DnsOptions.fromPartial(object.dnsOptions)
                : undefined;
        message.objectStorage =
            object.objectStorage !== undefined && object.objectStorage !== null
                ? exports.PrivateEndpoint_ObjectStorage.fromPartial(object.objectStorage)
                : undefined;
        return message;
    },
};
const basePrivateEndpoint_LabelsEntry = { key: '', value: '' };
exports.PrivateEndpoint_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({}, basePrivateEndpoint_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({}, basePrivateEndpoint_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({}, basePrivateEndpoint_LabelsEntry);
        message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
        message.value = (_b = object.value) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const basePrivateEndpoint_ObjectStorage = {};
exports.PrivateEndpoint_ObjectStorage = {
    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({}, basePrivateEndpoint_ObjectStorage);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(_) {
        const message = Object.assign({}, basePrivateEndpoint_ObjectStorage);
        return message;
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
    fromPartial(_) {
        const message = Object.assign({}, basePrivateEndpoint_ObjectStorage);
        return message;
    },
};
const basePrivateEndpoint_DnsOptions = { privateDnsRecordsEnabled: false };
exports.PrivateEndpoint_DnsOptions = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.privateDnsRecordsEnabled === true) {
            writer.uint32(8).bool(message.privateDnsRecordsEnabled);
        }
        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({}, basePrivateEndpoint_DnsOptions);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.privateDnsRecordsEnabled = reader.bool();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, basePrivateEndpoint_DnsOptions);
        message.privateDnsRecordsEnabled =
            object.privateDnsRecordsEnabled !== undefined &&
                object.privateDnsRecordsEnabled !== null
                ? Boolean(object.privateDnsRecordsEnabled)
                : false;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.privateDnsRecordsEnabled !== undefined &&
            (obj.privateDnsRecordsEnabled = message.privateDnsRecordsEnabled);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, basePrivateEndpoint_DnsOptions);
        message.privateDnsRecordsEnabled = (_a = object.privateDnsRecordsEnabled) !== null && _a !== void 0 ? _a : false;
        return message;
    },
};
const basePrivateEndpoint_EndpointAddress = { subnetId: '', address: '', addressId: '' };
exports.PrivateEndpoint_EndpointAddress = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.subnetId !== '') {
            writer.uint32(10).string(message.subnetId);
        }
        if (message.address !== '') {
            writer.uint32(18).string(message.address);
        }
        if (message.addressId !== '') {
            writer.uint32(26).string(message.addressId);
        }
        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({}, basePrivateEndpoint_EndpointAddress);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.subnetId = reader.string();
                    break;
                case 2:
                    message.address = reader.string();
                    break;
                case 3:
                    message.addressId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, basePrivateEndpoint_EndpointAddress);
        message.subnetId =
            object.subnetId !== undefined && object.subnetId !== null
                ? String(object.subnetId)
                : '';
        message.address =
            object.address !== undefined && object.address !== null ? String(object.address) : '';
        message.addressId =
            object.addressId !== undefined && object.addressId !== null
                ? String(object.addressId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.subnetId !== undefined && (obj.subnetId = message.subnetId);
        message.address !== undefined && (obj.address = message.address);
        message.addressId !== undefined && (obj.addressId = message.addressId);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c;
        const message = Object.assign({}, basePrivateEndpoint_EndpointAddress);
        message.subnetId = (_a = object.subnetId) !== null && _a !== void 0 ? _a : '';
        message.address = (_b = object.address) !== null && _b !== void 0 ? _b : '';
        message.addressId = (_c = object.addressId) !== null && _c !== void 0 ? _c : '';
        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();
}
