import { Type } from "class-transformer";
import { IsArray, IsOptional, IsString, IsUrl, MinLength, ValidateNested } from "class-validator";

export class CreateBreakglassDto {
  @IsString()
  @MinLength(3)
  username!: string;

  @IsString()
  @MinLength(8)
  password!: string;
}

export class ConfigureOidcDto {
  @IsString()
  @IsUrl({ require_tld: false })
  issuerUrl!: string;

  @IsString()
  clientId!: string;

  @IsString()
  clientSecret!: string;
}

export class ProviderModelDto {
  @IsString()
  id!: string;

  @IsOptional()
  @IsString()
  name?: string;
}

export class AddProviderDto {
  @IsString()
  name!: string;

  @IsString()
  displayName!: string;

  @IsString()
  type!: string;

  @IsOptional()
  @IsString()
  baseUrl?: string;

  @IsOptional()
  @IsString()
  apiKey?: string;

  @IsOptional()
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => ProviderModelDto)
  models?: ProviderModelDto[];
}

export class TestProviderDto {
  @IsString()
  type!: string;

  @IsOptional()
  @IsString()
  baseUrl?: string;

  @IsOptional()
  @IsString()
  apiKey?: string;
}
