Added Pydantic for configurations info

This commit is contained in:
Donald Zou
2025-08-14 22:36:14 +08:00
parent ebbb681dd8
commit c757cee988
3 changed files with 45 additions and 2 deletions

View File

@@ -0,0 +1,24 @@
from pydantic import BaseModel, PositiveInt
class OverridePeerSettingsClass(BaseModel):
DNS: str = ''
EndpointAllowedIPs: str = ''
MTU: str | int = ''
PersistentKeepalive: int | str = ''
PeerRemoteEndpoint: str = ''
ListenPort: int | str = ''
class PeerGroupsClass(BaseModel):
Description: str = ''
BackgroundColor: str = ''
Peers: list[str] = []
class WireguardConfigurationInfo(BaseModel):
Description: str = ''
OverridePeerSettings: OverridePeerSettingsClass = OverridePeerSettingsClass(**{})
PeerGroups: dict[str, PeerGroupsClass] = {}
if __name__ == '__main__':
d = WireguardConfigurationInfo.model_validate_json("{\"Description\": \"Hi!\"}")
print(d.model_dump())