"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.CreateClusterResponseDto = exports.CreateClusterDto = exports.VNetConfigDto = void 0;
const class_validator_1 = require("class-validator");
const class_transformer_1 = require("class-transformer");
const swagger_1 = require("@nestjs/swagger");
const cloud_provider_enum_1 = require("../../../../modules/providers/enums/cloud-provider.enum");
const dto_1 = require("../../../../modules/common/dto");
const firewall_dto_1 = require("../../../../modules/providers/dto/firewall.dto");
const hostname_mode_enum_1 = require("../../../../modules/dns/enums/hostname-mode.enum");
/**
 * DTO for VNet configuration during cluster creation
 */
class VNetConfigDto {
}
exports.VNetConfigDto = VNetConfigDto;
__decorate([
    (0, swagger_1.ApiProperty)({
        description: 'VNet UUID to attach cluster nodes to',
        example: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
    }),
    (0, class_validator_1.IsUUID)(),
    __metadata("design:type", String)
], VNetConfigDto.prototype, "vnetId", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Specific subnet UUID within the VNet. If not provided, subnet will be auto-selected.',
        example: 'b2c3d4e5-f6a7-8901-bcde-f12345678901',
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsUUID)(),
    __metadata("design:type", String)
], VNetConfigDto.prototype, "subnetId", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Whether to auto-assign private IPs to nodes. Default: true',
        example: true,
        default: true,
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsBoolean)(),
    __metadata("design:type", Boolean)
], VNetConfigDto.prototype, "autoAssignIp", void 0);
class CreateClusterDto {
}
exports.CreateClusterDto = CreateClusterDto;
__decorate([
    (0, swagger_1.ApiProperty)({
        example: 'production-cluster',
        minLength: 3,
        maxLength: 63,
        description: 'Cluster name (must be unique)',
    }),
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.MinLength)(3),
    (0, class_validator_1.MaxLength)(63),
    __metadata("design:type", String)
], CreateClusterDto.prototype, "name", void 0);
__decorate([
    (0, swagger_1.ApiProperty)({
        enum: cloud_provider_enum_1.CloudProvider,
        example: cloud_provider_enum_1.CloudProvider.HETZNER,
        description: 'Cloud provider',
    }),
    (0, class_validator_1.IsEnum)(cloud_provider_enum_1.CloudProvider),
    __metadata("design:type", String)
], CreateClusterDto.prototype, "provider", void 0);
__decorate([
    (0, swagger_1.ApiProperty)({
        example: 'fsn1',
        description: 'Region/location code',
    }),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateClusterDto.prototype, "region", void 0);
__decorate([
    (0, swagger_1.ApiProperty)({
        example: 'cx22',
        description: 'Node size/type (applies to all nodes)',
    }),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateClusterDto.prototype, "nodeSize", void 0);
__decorate([
    (0, swagger_1.ApiProperty)({
        example: 2,
        minimum: 0,
        maximum: 19,
        description: 'Number of worker nodes (0 = master-only, max 19 workers)',
    }),
    (0, class_validator_1.IsInt)(),
    (0, class_validator_1.Min)(0),
    (0, class_validator_1.Max)(19),
    __metadata("design:type", Number)
], CreateClusterDto.prototype, "workerCount", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        example: false,
        description: 'Enable autoscaling',
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsBoolean)(),
    __metadata("design:type", Boolean)
], CreateClusterDto.prototype, "autoscalingEnabled", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        example: 2,
        minimum: 1,
        description: 'Minimum number of nodes (for autoscaling)',
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsInt)(),
    (0, class_validator_1.Min)(1),
    __metadata("design:type", Number)
], CreateClusterDto.prototype, "minNodes", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        example: 5,
        maximum: 20,
        description: 'Maximum number of nodes (for autoscaling)',
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsInt)(),
    (0, class_validator_1.Max)(20),
    __metadata("design:type", Number)
], CreateClusterDto.prototype, "maxNodes", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        example: 80,
        minimum: 50,
        maximum: 95,
        description: 'Memory utilization percentage that triggers a scale-up. Overrides global default.',
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsInt)(),
    (0, class_validator_1.Min)(50),
    (0, class_validator_1.Max)(95),
    __metadata("design:type", Number)
], CreateClusterDto.prototype, "scaleUpMemoryPct", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        example: 75,
        minimum: 50,
        maximum: 95,
        description: 'CPU utilization percentage that triggers a scale-up. Overrides global default.',
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsInt)(),
    (0, class_validator_1.Min)(50),
    (0, class_validator_1.Max)(95),
    __metadata("design:type", Number)
], CreateClusterDto.prototype, "scaleUpCpuPct", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        example: 300,
        minimum: 60,
        maximum: 3600,
        description: 'Cooldown period (seconds) between consecutive scale events. Overrides global default.',
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsInt)(),
    (0, class_validator_1.Min)(60),
    (0, class_validator_1.Max)(3600),
    __metadata("design:type", Number)
], CreateClusterDto.prototype, "cooldownSeconds", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        example: 'v1.35.4+k3s1',
        description: 'K3s version (default: v1.35.4+k3s1)',
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateClusterDto.prototype, "k3sVersion", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        example: ['ssh-key-id-1', 'ssh-key-id-2'],
        description: 'SSH key IDs for node access',
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsArray)(),
    (0, class_validator_1.IsString)({ each: true }),
    __metadata("design:type", Array)
], CreateClusterDto.prototype, "sshKeys", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        example: 'ubuntu-24.04',
        description: 'OS image (default: ubuntu-24.04)',
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsString)(),
    __metadata("design:type", String)
], CreateClusterDto.prototype, "image", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        example: { environment: 'production', team: 'platform' },
        description: 'Additional metadata',
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsObject)(),
    __metadata("design:type", Object)
], CreateClusterDto.prototype, "metadata", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Firewall rules for the cluster (desired state). ' +
            'If not provided, cluster will be created with empty firewall (deny-all). ' +
            'Provide an array of firewall rules to define the cluster firewall protection.',
        type: [firewall_dto_1.FirewallRuleDto],
        example: [
            {
                description: 'SSH access',
                direction: 'in',
                protocol: 'tcp',
                port: '22',
                sourceIps: ['0.0.0.0/0', '::/0'],
            },
            {
                description: 'K3s API server',
                direction: 'in',
                protocol: 'tcp',
                port: '6443',
                sourceIps: ['0.0.0.0/0', '::/0'],
            },
        ],
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsArray)(),
    (0, class_validator_1.ValidateNested)({ each: true }),
    (0, class_transformer_1.Type)(() => firewall_dto_1.FirewallRuleDto),
    __metadata("design:type", Array)
], CreateClusterDto.prototype, "firewallRules", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'Disk size in GB for each node. Required for node types with network storage (storageType=network, e.g. Scaleway PRO2, ENT1). ' +
            'For local SSD types the value is ignored. Minimum recommended: 20 GB.',
        example: 50,
        minimum: 1,
        maximum: 10000,
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsInt)(),
    (0, class_validator_1.IsPositive)(),
    (0, class_validator_1.Max)(10000),
    __metadata("design:type", Number)
], CreateClusterDto.prototype, "diskSizeGb", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        description: 'VNet configuration for cluster nodes. ' +
            'If provided, all cluster nodes (master and workers) will be attached to the specified VNet. ' +
            'The VNet must exist in the same provider and region as the cluster.',
        type: VNetConfigDto,
        example: {
            vnetId: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
            subnetId: 'b2c3d4e5-f6a7-8901-bcde-f12345678901',
            autoAssignIp: true,
        },
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.ValidateNested)(),
    (0, class_transformer_1.Type)(() => VNetConfigDto),
    __metadata("design:type", VNetConfigDto)
], CreateClusterDto.prototype, "vnetConfig", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        enum: hostname_mode_enum_1.HostnameMode,
        default: hostname_mode_enum_1.HostnameMode.IP,
        description: 'Default hostname source for endpoints (system services and user apps). ' +
            'IP uses nip.io against the master public IP — zero external DNS required, ideal for testing. ' +
            'DOMAIN requires a DNS zone to be assigned to the cluster afterwards. Defaults to IP.',
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsEnum)(hostname_mode_enum_1.HostnameMode),
    __metadata("design:type", String)
], CreateClusterDto.prototype, "endpointHostnameMode", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        example: 'clever-otter-7k',
        maxLength: 30,
        description: 'Optional token injected into nip.io system hostnames (auth/app/api). ' +
            'When omitted, a random token is generated server-side. ' +
            'Ensures each cluster has a unique LE domain set, avoiding rate limits during repeated test cycles.',
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsString)(),
    (0, class_validator_1.MaxLength)(30),
    __metadata("design:type", String)
], CreateClusterDto.prototype, "nipHostnameToken", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        type: Boolean,
        default: true,
        description: 'Enable Flui shared storage (NFS+fscache, see scaling doc §14). ' +
            'When true (default), the master gets an attached Volume that hosts the NFS export, ' +
            'and workers mount it via NFSv4 with cachefilesd. Disable to fall back to local-path on each node bundled disk.',
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsBoolean)(),
    __metadata("design:type", Boolean)
], CreateClusterDto.prototype, "sharedStorageEnabled", void 0);
__decorate([
    (0, swagger_1.ApiPropertyOptional)({
        type: Number,
        default: 20,
        minimum: 10,
        description: 'Size in GB of the master backing Volume hosting the NFS export. ' +
            'Hetzner minimum is 10 GB.',
    }),
    (0, class_validator_1.IsOptional)(),
    (0, class_validator_1.IsInt)(),
    (0, class_validator_1.Min)(10),
    __metadata("design:type", Number)
], CreateClusterDto.prototype, "sharedStorageVolumeSizeGb", void 0);
/**
 * Response DTO for cluster creation request
 * Extends base async operation response with cluster-specific alias
 */
class CreateClusterResponseDto extends dto_1.AsyncOperationResponseDto {
}
exports.CreateClusterResponseDto = CreateClusterResponseDto;
__decorate([
    (0, swagger_1.ApiProperty)({
        description: 'Cluster ID (alias for resource_id)',
    }),
    __metadata("design:type", String)
], CreateClusterResponseDto.prototype, "cluster_id", void 0);
