Files
zima-apps/Apps/docker-ip-addr-manager/backend/app/models.py
T
Joachim Friberg 95cd7d9ba8 Add Snacks app: automated video library encoder with hardware acceleration
- Apps/snacks/: docker-compose.yaml (2.3.1, host networking, privileged, /dev/dri)
  and README.md with full security exception documentation for:
  network_mode:host, privileged:true, device mount /dev/dri
- apps.md: converted to agent-readable table backlog with instructions for future apps
- Jellyfin-ffmpeg paths as defaults, 1G memory reservation, amd64 only (single-arch image)
- Validation: ./scripts/validate-appstore.sh passes
2026-04-19 20:50:06 +02:00

67 lines
1.5 KiB
Python

from __future__ import annotations
from dataclasses import dataclass
@dataclass
class IpEntry:
id: str
name: str
ip: str
cidr: int
device: str
enabled: bool
@classmethod
def from_dict(cls, data: dict) -> "IpEntry":
return cls(
id=str(data["id"]),
name=str(data["name"]),
ip=str(data["ip"]),
cidr=int(data["cidr"]),
device=str(data["device"]),
enabled=bool(data.get("enabled", False)),
)
def to_dict(self) -> dict:
return {
"id": self.id,
"name": self.name,
"ip": self.ip,
"cidr": self.cidr,
"device": self.device,
"enabled": self.enabled,
}
@dataclass
class EntryView:
id: str
name: str
ip: str
cidr: int
device: str
enabled: bool
effective_enabled: bool
used: bool
containers: list[str]
usage_known: bool
dns_desired: bool = False
dns_last_error: str | None = None
def to_dict(self) -> dict:
return {
"id": self.id,
"name": self.name,
"ip": self.ip,
"cidr": self.cidr,
"device": self.device,
"enabled": self.enabled,
"effective_enabled": self.effective_enabled,
"used": self.used,
"containers": self.containers,
"usage_known": self.usage_known,
"dns_desired": self.dns_desired,
"dns_last_error": self.dns_last_error,
}