Add type hints and docstrings for VLANs, Interfaces, and System properties in NodeConfig
- Enhanced the `vlans`, `interfaces`, and `system` properties with type hints for better clarity and type checking. - Added detailed docstrings to each property, describing the return types and structure of the associated configurations.
This commit is contained in:
38
oxi/conf.py
38
oxi/conf.py
@@ -10,6 +10,9 @@ from .interfaces import BaseDevice, device_registry
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from requests import Session
|
from requests import Session
|
||||||
|
|
||||||
|
from oxi.interfaces.contract import Interfaces, System, Vlans
|
||||||
|
|
||||||
|
|
||||||
TModel = TypeVar("TModel", bound=BaseModel)
|
TModel = TypeVar("TModel", bound=BaseModel)
|
||||||
|
|
||||||
|
|
||||||
@@ -83,13 +86,42 @@ class NodeConfig:
|
|||||||
return self.text
|
return self.text
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def vlans(self):
|
def vlans(self) -> list["Vlans"]:
|
||||||
|
"""
|
||||||
|
Returns the list of VLAN configurations for the node.
|
||||||
|
|
||||||
|
:return: List of Vlans associated with the device.
|
||||||
|
vlan_id: int
|
||||||
|
name: str | None = Field(default=None, alias="description")
|
||||||
|
:rtype: list[oxi.interfaces.contract.Vlans]
|
||||||
|
"""
|
||||||
|
return ModelView(self._parsed_data.vlans)
|
||||||
return ModelView(self._parsed_data.vlans)
|
return ModelView(self._parsed_data.vlans)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def interfaces(self):
|
def interfaces(self) -> list["Interfaces"]:
|
||||||
|
"""
|
||||||
|
Returns the list of Interfaces configurations for the node.
|
||||||
|
|
||||||
|
:return: List of Interfaces associated with the device.
|
||||||
|
name: str = Field(alias="interface")
|
||||||
|
ip_address: IPv4Address | None = None
|
||||||
|
mask: int | None = None
|
||||||
|
description: str | None = None
|
||||||
|
shutdown: bool = False
|
||||||
|
:rtype: list[oxi.interfaces.contract.Interfaces]
|
||||||
|
"""
|
||||||
return ModelView(self._parsed_data.interfaces)
|
return ModelView(self._parsed_data.interfaces)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def system(self):
|
def system(self) -> "System":
|
||||||
|
"""
|
||||||
|
Returns the Systems configurations for the node.
|
||||||
|
|
||||||
|
:return: System associated with the device.
|
||||||
|
model: str
|
||||||
|
serial_number: str
|
||||||
|
version: str
|
||||||
|
:rtype: oxi.interfaces.contract.System
|
||||||
|
"""
|
||||||
return ModelView(self._parsed_data.system)
|
return ModelView(self._parsed_data.system)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "oxipy"
|
name = "oxipy"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
description = "Python client for Oxidized API with TTP-based config parsing"
|
description = "Python client for Oxidized API with TTP-based config parsing"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user