from dataclasses import dataclass from typing import List, Optional @dataclass class Host: """Represents a host/service within a location.""" name: str address: str type: str # e.g., "SSH", "Web", "SMB", "PostgreSQL", "Redis" @dataclass class Location: """Represents a location within a customer (e.g., headquarters, branch office).""" name: str vpn_type: str # e.g., "OpenVPN", "WireGuard", "IPSec" connected: bool = False active: bool = False hosts: List[Host] = None def __post_init__(self): if self.hosts is None: self.hosts = [] @dataclass class Customer: """Represents a customer with multiple locations.""" name: str locations: List[Location] = None def __post_init__(self): if self.locations is None: self.locations = [] def get_active_locations(self) -> List[Location]: """Get all active locations for this customer.""" return [loc for loc in self.locations if loc.active] def get_inactive_locations(self) -> List[Location]: """Get all inactive locations for this customer.""" return [loc for loc in self.locations if not loc.active] def has_active_locations(self) -> bool: """Check if customer has any active locations.""" return any(loc.active for loc in self.locations) def get_location_by_name(self, location_name: str) -> Optional[Location]: """Get a location by its name.""" for location in self.locations: if location.name == location_name: return location return None