import { IsString, IsOptional, IsInt, IsIn, ValidateIf } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class SetupServerDto {
  @ApiProperty({ description: 'Connection type', enum: ['amp', 'pterodactyl', 'bare_metal'] })
  @IsString()
  @IsIn(['amp', 'pterodactyl', 'bare_metal'])
  connection_type: 'amp' | 'pterodactyl' | 'bare_metal';

  @ApiPropertyOptional({ description: 'Server IP address' })
  @IsOptional()
  @IsString()
  server_ip?: string;

  @ApiPropertyOptional({ description: 'Server RCON port' })
  @IsOptional()
  @IsInt()
  server_port?: number;

  @ApiPropertyOptional({ description: 'Game port (players connect to)' })
  @IsOptional()
  @IsInt()
  game_port?: number;

  @ApiPropertyOptional({ description: 'Panel API endpoint (for AMP/Pterodactyl)' })
  @ValidateIf(o => o.connection_type === 'amp' || o.connection_type === 'pterodactyl')
  @IsString()
  panel_api_endpoint?: string;

  @ApiPropertyOptional({ description: 'Panel API key (for AMP/Pterodactyl)' })
  @ValidateIf(o => o.connection_type === 'amp' || o.connection_type === 'pterodactyl')
  @IsString()
  panel_api_key?: string;

  @ApiPropertyOptional({ description: 'Panel server identifier (for AMP/Pterodactyl)' })
  @ValidateIf(o => o.connection_type === 'amp' || o.connection_type === 'pterodactyl')
  @IsString()
  panel_server_identifier?: string;
}
