Update: Major code refactor for modular extensibility
CI/CD Pipeline / Unit Tests (Python 3.11) (push) Successful in 29s
CI/CD Pipeline / Unit Tests (Python 3.12) (push) Successful in 30s
CI/CD Pipeline / Code Quality & Linting (push) Successful in 23s
CI/CD Pipeline / Unit Tests (Python 3.13) (push) Successful in 27s
CI/CD Pipeline / Integration Tests (push) Successful in 21s
CI/CD Pipeline / Security Scanning (push) Successful in 2m16s
CI/CD Pipeline / Generate Test Report (push) Successful in 4s
CI/CD Pipeline / Build Docker Image (push) Successful in 44s
CI/CD Pipeline / CI/CD Pipeline Status (push) Successful in 2s
CI/CD Pipeline / Unit Tests (Python 3.11) (push) Successful in 29s
CI/CD Pipeline / Unit Tests (Python 3.12) (push) Successful in 30s
CI/CD Pipeline / Code Quality & Linting (push) Successful in 23s
CI/CD Pipeline / Unit Tests (Python 3.13) (push) Successful in 27s
CI/CD Pipeline / Integration Tests (push) Successful in 21s
CI/CD Pipeline / Security Scanning (push) Successful in 2m16s
CI/CD Pipeline / Generate Test Report (push) Successful in 4s
CI/CD Pipeline / Build Docker Image (push) Successful in 44s
CI/CD Pipeline / CI/CD Pipeline Status (push) Successful in 2s
This commit is contained in:
1 parent
d891b21ffd
commit
346e6d9604
13 files changed
+3266
-443
No files matched your search
@@ -0,0 +1,112 @@
|
||||
"""
|
||||
Data Models Module
|
||||
|
||||
Pydantic models for type-safe data handling throughout the application.
|
||||
Provides validation and serialization for API responses and internal data.
|
||||
"""
|
||||
|
||||
from typing import Any, Dict, List, Optional
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class ResourceAttributes(BaseModel):
|
||||
"""Current resource usage attributes from panel API."""
|
||||
|
||||
current_state: str
|
||||
resources: "ResourceUsage"
|
||||
|
||||
|
||||
class ResourceUsage(BaseModel):
|
||||
"""Individual resource metrics."""
|
||||
|
||||
cpu_absolute: float = 0.0
|
||||
memory_bytes: int = 0
|
||||
disk_bytes: int = 0
|
||||
network_rx_bytes: int = 0
|
||||
network_tx_bytes: int = 0
|
||||
uptime: int = 0
|
||||
|
||||
|
||||
class ServerAttributes(BaseModel):
|
||||
"""Server attributes from panel API."""
|
||||
|
||||
identifier: str
|
||||
name: str
|
||||
description: Optional[str] = None
|
||||
suspended: bool = False
|
||||
limits: "ServerLimits" = Field(default_factory=lambda: ServerLimits())
|
||||
|
||||
|
||||
class ServerLimits(BaseModel):
|
||||
"""Server resource limits."""
|
||||
|
||||
cpu: int = 0
|
||||
memory: int = 0
|
||||
disk: int = 0
|
||||
|
||||
|
||||
class ServerRelationships(BaseModel):
|
||||
"""Server relationships data."""
|
||||
|
||||
allocations: Optional["AllocationsData"] = None
|
||||
|
||||
|
||||
class AllocationsData(BaseModel):
|
||||
"""Allocations data container."""
|
||||
|
||||
data: List["Allocation"] = Field(default_factory=list)
|
||||
|
||||
|
||||
class Allocation(BaseModel):
|
||||
"""Individual allocation (IP/port)."""
|
||||
|
||||
attributes: "AllocationAttributes"
|
||||
|
||||
|
||||
class AllocationAttributes(BaseModel):
|
||||
"""Allocation attributes."""
|
||||
|
||||
ip_alias: str = "Unknown"
|
||||
port: int = 0
|
||||
is_default: bool = False
|
||||
|
||||
|
||||
class ServerData(BaseModel):
|
||||
"""Complete server data from panel API."""
|
||||
|
||||
attributes: ServerAttributes
|
||||
relationships: Optional[ServerRelationships] = None
|
||||
|
||||
|
||||
class ServerResources(BaseModel):
|
||||
"""Server resources response from panel API."""
|
||||
|
||||
attributes: ResourceAttributes
|
||||
|
||||
|
||||
class APIResponse(BaseModel):
|
||||
"""Generic API response wrapper."""
|
||||
|
||||
status: str = "success"
|
||||
data: Any = None
|
||||
message: Optional[str] = None
|
||||
errors: Optional[List[Dict[str, Any]]] = None
|
||||
|
||||
|
||||
class ServerListResponse(BaseModel):
|
||||
"""Server list response from panel API."""
|
||||
|
||||
data: List[Dict[str, Any]] = Field(default_factory=list)
|
||||
meta: Optional[Dict[str, Any]] = None
|
||||
|
||||
|
||||
class EmbedLocation(BaseModel):
|
||||
"""Embed location tracking data."""
|
||||
|
||||
channel_id: str
|
||||
message_id: str
|
||||
|
||||
|
||||
# Rebuild models to resolve forward references
|
||||
ResourceAttributes.model_rebuild()
|
||||
ServerAttributes.model_rebuild()
|
||||
Reference in new issue
Block a user