- Updated the `vlans`, `interfaces`, and `system` methods in the `BaseDevice` class to include comprehensive docstrings outlining expected raw data structures and error handling. - Modified the `Interfaces` model in `contract.py` to allow optional fields for `ip_address` and `mask`, improving flexibility in interface definitions.
27 lines
504 B
Python
27 lines
504 B
Python
from ipaddress import IPv4Address
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class Interfaces(BaseModel):
|
|
name: str
|
|
ip_address: IPv4Address | None = None
|
|
mask: int | None = None
|
|
description: str
|
|
|
|
|
|
class System(BaseModel):
|
|
model: str
|
|
serial_number: str
|
|
version: str
|
|
|
|
|
|
class Vlans(BaseModel):
|
|
id: int
|
|
name: str | None = Field(default=None, alias="description")
|
|
|
|
|
|
class Device(BaseModel):
|
|
system: System
|
|
interfaces: list[Interfaces] = []
|
|
vlans: list[Vlans] = []
|