""" Connection factory — creates connection wrappers based on server type. Uses lazy imports so missing optional dependencies don't crash the app. """ from core.ssh_client import SSHClientWrapper def create_connection(server: dict, key_path: str = ""): """Create a connection wrapper based on server type.""" server_type = server.get("type", "ssh") if server_type == "ssh": return SSHClientWrapper(server, key_path) if server_type == "telnet": from core.telnet_client import TelnetSession return TelnetSession(server) if server_type in ("mariadb", "mssql", "postgresql"): from core.sql_client import SQLClient return SQLClient(server) if server_type == "redis": from core.redis_client import RedisClient return RedisClient(server) if server_type == "grafana": from core.grafana_client import GrafanaClient return GrafanaClient(server) if server_type == "prometheus": from core.prometheus_client import PrometheusClient return PrometheusClient(server) if server_type == "winrm": from core.winrm_client import WinRMClient return WinRMClient(server) if server_type in ("rdp", "vnc"): from core.remote_desktop import RemoteDesktopLauncher return RemoteDesktopLauncher() raise ValueError(f"Unknown server type: {server_type}")