"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserSshKey = 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.organizationmanager.v1';
const baseUserSshKey = {
    id: '',
    subjectId: '',
    data: '',
    name: '',
    fingerprint: '',
    organizationId: '',
};
exports.UserSshKey = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.id !== '') {
            writer.uint32(10).string(message.id);
        }
        if (message.subjectId !== '') {
            writer.uint32(18).string(message.subjectId);
        }
        if (message.data !== '') {
            writer.uint32(26).string(message.data);
        }
        if (message.name !== '') {
            writer.uint32(34).string(message.name);
        }
        if (message.fingerprint !== '') {
            writer.uint32(42).string(message.fingerprint);
        }
        if (message.organizationId !== '') {
            writer.uint32(50).string(message.organizationId);
        }
        if (message.createdAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(58).fork()).ldelim();
        }
        if (message.expiresAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.expiresAt), writer.uint32(66).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({}, baseUserSshKey);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.id = reader.string();
                    break;
                case 2:
                    message.subjectId = reader.string();
                    break;
                case 3:
                    message.data = reader.string();
                    break;
                case 4:
                    message.name = reader.string();
                    break;
                case 5:
                    message.fingerprint = reader.string();
                    break;
                case 6:
                    message.organizationId = reader.string();
                    break;
                case 7:
                    message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 8:
                    message.expiresAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseUserSshKey);
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        message.subjectId =
            object.subjectId !== undefined && object.subjectId !== null
                ? String(object.subjectId)
                : '';
        message.data = object.data !== undefined && object.data !== null ? String(object.data) : '';
        message.name = object.name !== undefined && object.name !== null ? String(object.name) : '';
        message.fingerprint =
            object.fingerprint !== undefined && object.fingerprint !== null
                ? String(object.fingerprint)
                : '';
        message.organizationId =
            object.organizationId !== undefined && object.organizationId !== null
                ? String(object.organizationId)
                : '';
        message.createdAt =
            object.createdAt !== undefined && object.createdAt !== null
                ? fromJsonTimestamp(object.createdAt)
                : undefined;
        message.expiresAt =
            object.expiresAt !== undefined && object.expiresAt !== null
                ? fromJsonTimestamp(object.expiresAt)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.id !== undefined && (obj.id = message.id);
        message.subjectId !== undefined && (obj.subjectId = message.subjectId);
        message.data !== undefined && (obj.data = message.data);
        message.name !== undefined && (obj.name = message.name);
        message.fingerprint !== undefined && (obj.fingerprint = message.fingerprint);
        message.organizationId !== undefined && (obj.organizationId = message.organizationId);
        message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString());
        message.expiresAt !== undefined && (obj.expiresAt = message.expiresAt.toISOString());
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g, _h;
        const message = Object.assign({}, baseUserSshKey);
        message.id = (_a = object.id) !== null && _a !== void 0 ? _a : '';
        message.subjectId = (_b = object.subjectId) !== null && _b !== void 0 ? _b : '';
        message.data = (_c = object.data) !== null && _c !== void 0 ? _c : '';
        message.name = (_d = object.name) !== null && _d !== void 0 ? _d : '';
        message.fingerprint = (_e = object.fingerprint) !== null && _e !== void 0 ? _e : '';
        message.organizationId = (_f = object.organizationId) !== null && _f !== void 0 ? _f : '';
        message.createdAt = (_g = object.createdAt) !== null && _g !== void 0 ? _g : undefined;
        message.expiresAt = (_h = object.expiresAt) !== null && _h !== void 0 ? _h : undefined;
        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();
}
