"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClusterEntity = exports.ClusterType = exports.ClusterStatus = void 0;
const typeorm_1 = require("typeorm");
const uuid_1 = require("uuid");
const cluster_node_entity_1 = require("./cluster-node.entity");
const hostname_mode_enum_1 = require("../../../dns/enums/hostname-mode.enum");
var ClusterStatus;
(function (ClusterStatus) {
    ClusterStatus["CREATING"] = "creating";
    ClusterStatus["READY"] = "ready";
    ClusterStatus["SCALING"] = "scaling";
    ClusterStatus["STOPPED"] = "stopped";
    ClusterStatus["ERROR"] = "error";
    ClusterStatus["DELETING"] = "deleting";
    ClusterStatus["DELETION_FAILED"] = "deletion_failed";
    ClusterStatus["DELETED"] = "deleted";
})(ClusterStatus || (exports.ClusterStatus = ClusterStatus = {}));
var ClusterType;
(function (ClusterType) {
    ClusterType["OBSERVABILITY"] = "observability";
    ClusterType["WORKLOAD"] = "workload";
})(ClusterType || (exports.ClusterType = ClusterType = {}));
let ClusterEntity = class ClusterEntity {
    generateId() {
        if (!this.id) {
            this.id = (0, uuid_1.v4)();
        }
    }
};
exports.ClusterEntity = ClusterEntity;
__decorate([
    (0, typeorm_1.PrimaryColumn)('uuid'),
    __metadata("design:type", String)
], ClusterEntity.prototype, "id", void 0);
__decorate([
    (0, typeorm_1.BeforeInsert)(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], ClusterEntity.prototype, "generateId", null);
__decorate([
    (0, typeorm_1.Column)(),
    __metadata("design:type", String)
], ClusterEntity.prototype, "name", void 0);
__decorate([
    (0, typeorm_1.Column)(),
    __metadata("design:type", String)
], ClusterEntity.prototype, "provider", void 0);
__decorate([
    (0, typeorm_1.Column)(),
    __metadata("design:type", String)
], ClusterEntity.prototype, "region", void 0);
__decorate([
    (0, typeorm_1.Column)(),
    __metadata("design:type", String)
], ClusterEntity.prototype, "nodeSize", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'int', default: 0 }),
    __metadata("design:type", Number)
], ClusterEntity.prototype, "nodeCount", void 0);
__decorate([
    (0, typeorm_1.Column)({ default: false }),
    __metadata("design:type", Boolean)
], ClusterEntity.prototype, "autoscalingEnabled", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'int', nullable: true }),
    __metadata("design:type", Number)
], ClusterEntity.prototype, "minNodes", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'int', nullable: true }),
    __metadata("design:type", Number)
], ClusterEntity.prototype, "maxNodes", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'int', nullable: true }),
    __metadata("design:type", Number)
], ClusterEntity.prototype, "scaleUpMemoryPct", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'int', nullable: true }),
    __metadata("design:type", Number)
], ClusterEntity.prototype, "scaleUpCpuPct", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'int', nullable: true }),
    __metadata("design:type", Number)
], ClusterEntity.prototype, "cooldownSeconds", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'text' }),
    __metadata("design:type", String)
], ClusterEntity.prototype, "k3sTokenEncrypted", void 0);
__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    __metadata("design:type", String)
], ClusterEntity.prototype, "k3sVersion", void 0);
__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    __metadata("design:type", String)
], ClusterEntity.prototype, "masterNodeId", void 0);
__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    __metadata("design:type", String)
], ClusterEntity.prototype, "masterIpAddress", void 0);
__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    __metadata("design:type", String)
], ClusterEntity.prototype, "masterPrivateIp", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'boolean', default: true }),
    __metadata("design:type", Boolean)
], ClusterEntity.prototype, "sharedStorageEnabled", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
    __metadata("design:type", String)
], ClusterEntity.prototype, "sharedStorageVolumeId", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'int', nullable: true }),
    __metadata("design:type", Number)
], ClusterEntity.prototype, "sharedStorageVolumeSizeGb", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'text', nullable: true }),
    __metadata("design:type", String)
], ClusterEntity.prototype, "kubeconfigEncrypted", void 0);
__decorate([
    (0, typeorm_1.Column)({
        type: 'enum',
        enum: ClusterStatus,
        default: ClusterStatus.CREATING,
    }),
    __metadata("design:type", String)
], ClusterEntity.prototype, "status", void 0);
__decorate([
    (0, typeorm_1.Column)({
        type: 'enum',
        enum: ClusterType,
        default: ClusterType.WORKLOAD,
    }),
    __metadata("design:type", String)
], ClusterEntity.prototype, "clusterType", void 0);
__decorate([
    (0, typeorm_1.Column)({
        type: 'enum',
        enum: hostname_mode_enum_1.HostnameMode,
        default: hostname_mode_enum_1.HostnameMode.IP,
    }),
    __metadata("design:type", String)
], ClusterEntity.prototype, "endpointHostnameMode", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'varchar', length: 30, nullable: true }),
    __metadata("design:type", String)
], ClusterEntity.prototype, "nipHostnameToken", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'json', default: '{}' }),
    __metadata("design:type", Object)
], ClusterEntity.prototype, "metadata", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'json', nullable: true }),
    __metadata("design:type", Array)
], ClusterEntity.prototype, "sshKeyIds", void 0);
__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    __metadata("design:type", String)
], ClusterEntity.prototype, "image", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'int', nullable: true }),
    __metadata("design:type", Number)
], ClusterEntity.prototype, "diskSizeGb", void 0);
__decorate([
    (0, typeorm_1.Column)({ nullable: true }),
    __metadata("design:type", String)
], ClusterEntity.prototype, "bootstrapKeyId", void 0);
__decorate([
    (0, typeorm_1.CreateDateColumn)({ type: 'timestamptz' }),
    __metadata("design:type", Date)
], ClusterEntity.prototype, "createdAt", void 0);
__decorate([
    (0, typeorm_1.UpdateDateColumn)({ type: 'timestamptz' }),
    __metadata("design:type", Date)
], ClusterEntity.prototype, "updatedAt", void 0);
__decorate([
    (0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }),
    __metadata("design:type", Date)
], ClusterEntity.prototype, "deletedAt", void 0);
__decorate([
    (0, typeorm_1.OneToMany)(() => cluster_node_entity_1.ClusterNodeEntity, (node) => node.cluster, {
        cascade: true,
    }),
    __metadata("design:type", Array)
], ClusterEntity.prototype, "nodes", void 0);
exports.ClusterEntity = ClusterEntity = __decorate([
    (0, typeorm_1.Entity)('infrastructure_clusters')
], ClusterEntity);
