Add complete NexaFabric project structure including: - FastAPI backend with SQLAlchemy models, JWT auth, RBAC, audit logging, and provider interfaces - React + TypeScript frontend with Vite, Tailwind CSS, TanStack Query, and Zustand - Docker Compose configuration for PostgreSQL, Redis, API, worker, frontend, and nginx - GitHub Actions and GitLab CI workflows for testing, linting, building, and security scanning - Environment
51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
from abc import ABC, abstractmethod
|
|
from dataclasses import dataclass
|
|
from typing import Any
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class ProviderConnection:
|
|
api_url: str
|
|
token: str
|
|
verify_tls: bool = True
|
|
read_only: bool = True
|
|
|
|
|
|
class HypervisorProvider(ABC):
|
|
@abstractmethod
|
|
async def test_connection(self, connection: ProviderConnection) -> dict[str, Any]:
|
|
raise NotImplementedError
|
|
|
|
|
|
class InventoryProvider(ABC):
|
|
@abstractmethod
|
|
async def sync_inventory(self, connection: ProviderConnection) -> dict[str, list[dict[str, Any]]]:
|
|
raise NotImplementedError
|
|
|
|
|
|
class NetworkProvider(ABC):
|
|
@abstractmethod
|
|
async def list_networks(self, connection: ProviderConnection) -> list[dict[str, Any]]:
|
|
raise NotImplementedError
|
|
|
|
|
|
class FirewallProvider(ABC):
|
|
@abstractmethod
|
|
async def preview_rules(self, connection: ProviderConnection, rules: list[dict[str, Any]]) -> dict[str, Any]:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
async def apply_rules(self, connection: ProviderConnection, rules: list[dict[str, Any]]) -> dict[str, Any]:
|
|
raise NotImplementedError
|
|
|
|
|
|
class Provider(
|
|
HypervisorProvider,
|
|
InventoryProvider,
|
|
NetworkProvider,
|
|
FirewallProvider,
|
|
ABC,
|
|
):
|
|
name: str
|
|
|