import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';

@Entity('servers')
export class Server {
  @PrimaryGeneratedColumn('uuid')
  id!: string;

  @Column({ type: 'varchar', length: 20 })
  tenantId!: string;

  @Column({ type: 'varchar', length: 100, unique: true })
  name!: string;

  @Column({ type: 'varchar', length: 255 })
  host!: string;

  @Column({ type: 'int', default: 22 })
  port!: number;

  @Column({ type: 'varchar', length: 20 })
  environment!: 'dev' | 'staging' | 'prod';

  @Column({ type: 'varchar', length: 30 })
  role!: 'web' | 'db' | 'cache' | 'worker' | 'gateway';

  @Column({ type: 'uuid', nullable: true })
  clusterId?: string;

  @Column({ type: 'varchar', length: 50 })
  sshUser!: string;

  @Column({ type: 'uuid' })
  credentialId!: string;

  @Column({ type: 'varchar', length: 20, default: 'public' })
  networkType!: 'public' | 'private';

  @Column({ type: 'uuid', nullable: true })
  jumpServerId?: string;

  @Column({ type: 'jsonb', default: {} })
  sshOptions!: Record<string, unknown>;

  @Column({ type: 'jsonb', default: {} })
  tags!: Record<string, string>;

  @Column({ type: 'varchar', length: 20, default: 'active' })
  status!: 'active' | 'inactive' | 'maintenance';

  @Column({ type: 'text', nullable: true })
  description?: string;

  @CreateDateColumn({ type: 'timestamptz' })
  createdAt!: Date;

  @UpdateDateColumn({ type: 'timestamptz' })
  updatedAt!: Date;
}
