from dataclasses import dataclass
from datetime import datetime
from typing import Optional

@dataclass
class Session:
    id: Optional[int] = None
    name: Optional[str] = None
    created_at: Optional[datetime] = None

@dataclass
class Scan:
    id: Optional[int] = None
    session_id: Optional[int] = None
    tool: Optional[str] = None
    args: Optional[str] = None
    summary: Optional[str] = None
    duration: Optional[int] = None  # in seconds
    created_at: Optional[datetime] = None

@dataclass
class Host:
    id: Optional[int] = None
    scan_id: Optional[int] = None
    ip: Optional[str] = None
    mac: Optional[str] = None
    os: Optional[str] = None

@dataclass
class Port:
    id: Optional[int] = None
    host_id: Optional[int] = None
    protocol: Optional[str] = None
    port_num: Optional[int] = None
    state: Optional[str] = None

@dataclass
class Service:
    id: Optional[int] = None
    port_id: Optional[int] = None
    name: Optional[str] = None
    product: Optional[str] = None
    version: Optional[str] = None  # Added version field
    extrainfo: Optional[str] = None
    ostype: Optional[str] = None

@dataclass
class CPE:
    id: Optional[int] = None
    service_id: Optional[int] = None
    name: Optional[str] = None

@dataclass
class ModbusScanResult:
    id: Optional[int] = None
    scan_id: Optional[int] = None
    active_coils: Optional[str] = None
    active_discrete_inputs: Optional[str] = None
    active_holding_registers: Optional[str] = None
    active_input_registers: Optional[str] = None

@dataclass
class Attack:
    id: Optional[int] = None
    session_id: Optional[int] = None
    tool: Optional[str] = None
    args: Optional[str] = None
    summary: Optional[str] = None
    duration: Optional[int] = None  # in seconds
    created_at: Optional[datetime] = None

@dataclass
class AttackResult:
    id: Optional[int] = None
    attack_id: Optional[int] = None
    summary: Optional[str] = None