import { IsString, IsOptional, IsBoolean, IsArray, IsDateString } from 'class-validator';
import { ApiPropertyOptional } from '@nestjs/swagger';

export class UpdateApiKeyDto {
	@ApiPropertyOptional({
		description: 'Update the display name',
		example: 'Updated API Key Name',
	})
	@IsString()
	@IsOptional()
	name?: string;

	@ApiPropertyOptional({
		description: 'Update the description',
		example: 'Updated description for this key',
	})
	@IsString()
	@IsOptional()
	description?: string;

	@ApiPropertyOptional({
		description: 'Update allowed endpoints',
		example: ['search', 'stt', 'tts'],
		type: [String],
	})
	@IsArray()
	@IsString({ each: true })
	@IsOptional()
	allowedEndpoints?: string[];

	@ApiPropertyOptional({
		description: 'Update IP whitelist',
		example: ['192.168.1.0/24'],
		type: [String],
	})
	@IsArray()
	@IsString({ each: true })
	@IsOptional()
	allowedIps?: string[];

	@ApiPropertyOptional({
		description: 'Enable or disable the API key',
		example: true,
	})
	@IsBoolean()
	@IsOptional()
	active?: boolean;

	@ApiPropertyOptional({
		description: 'Update expiration date (ISO 8601)',
		example: '2025-12-31T23:59:59Z',
	})
	@IsDateString()
	@IsOptional()
	expiresAt?: string;
}
