Skip to content

Commit

Permalink
Added /ip/kid-control
Browse files Browse the repository at this point in the history
  • Loading branch information
hexatester committed Jul 15, 2023
1 parent 0180a9a commit 6619f64
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 1 deletion.
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
- [x] firewall
- [x] hotspot
- [ ] ipsec
- [ ] kid-control
- [x] kid-control
- [x] neighbor
- [ ] packing
- [x] pool
Expand Down
11 changes: 11 additions & 0 deletions ros/ip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .dns import DNS
from .firewall import IPFirewallModule
from .hotspot import HotspotModule, HotspotServer
from .kid_control import KidControlModule, KidControl
from .neighbor import IPNeighbor
from .pool import IPPool
from .route import Route
Expand All @@ -26,6 +27,7 @@ class IPModule(BaseModule):
_arp: BaseProps[ARP] = None
_dhcp_client: BaseProps[DHCPClient] = None
_dhcp_relay: BaseProps[DHCPRelay] = None
_kid_control: KidControlModule = None
_pool: BaseProps[IPPool] = None
_neighbor: BaseProps[IPNeighbor] = None
_route: BaseProps[Route] = None
Expand Down Expand Up @@ -86,6 +88,14 @@ def hotspot(self) -> HotspotModule:
self._hotspot = HotspotModule(self.ros, "/ip/hotspot", HotspotServer)
return self._hotspot

@property
def kid_control(self) -> KidControlModule:
if not self._kid_control:
self._kid_control = KidControlModule(
self.ros, "/ip/kid-control", KidControl
)
return self._kid_control

@property
def neighbor(self) -> BaseProps[IPNeighbor]:
if not self._neighbor:
Expand Down Expand Up @@ -136,6 +146,7 @@ def vrf(self) -> BaseProps[Vrf]:
"DHCPRelay",
"DHCPServer",
"DNS",
"KidControl",
"Route",
"Service",
"Setting",
Expand Down
16 changes: 16 additions & 0 deletions ros/ip/kid_control/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from ros._base import BaseProps
from .device import Device
from .kid import KidControl


class KidControlModule(BaseProps[KidControl]):
_device: BaseProps[Device] = None

@property
def device(self) -> BaseProps[Device]:
if not self._device:
self._device = BaseProps(self.ros, "/ip/kid-control/device", Device)
return self._device


__all__ = ["Device", "KidControl", "KidControlModule"]
25 changes: 25 additions & 0 deletions ros/ip/kid_control/device.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from attr import dataclass


@dataclass
class Device:
name: str
mac_address: str
user: str
disabled: bool = None
copy_from: str = None
id: str = None
activity: str = None
blocked: bool = None
bytes_down: int = None
bytes_up: int = None
dynamic: bool = None
idle_time: str = None
inactive: bool = None
ip_address: str = None
limited: bool = None
rate_down: int = None
rate_up: int = None

def __str__(self) -> str:
return self.name
28 changes: 28 additions & 0 deletions ros/ip/kid_control/kid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from attr import dataclass


@dataclass
class KidControl:
name: str
sun: str = None
mon: str = None
tue: str = None
wed: str = None
thu: str = None
fri: str = None
sat: str = None
rate_limit: str = None
tur_sun: str = None
tur_mon: str = None
tur_tue: str = None
tur_wed: str = None
tur_thu: str = None
tur_fri: str = None
tur_sat: str = None
disabled: bool = None
blocked: bool = None
id: str = None
copy_from: str = None

def __str__(self) -> str:
return self.name
14 changes: 14 additions & 0 deletions tests/test_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
HotspotServicePort,
HotspotCookie,
)
from ros.ip.kid_control import Device, KidControlModule, KidControl
from ros.ip.neighbor import IPNeighbor
from ros.ip.pool import IPPool
from ros.ip.service import Service
Expand Down Expand Up @@ -167,6 +168,19 @@ def test_neighbor(self, ros: Ros):
assert isinstance(i, IPNeighbor)


class TestKidControl:
def test_module(self, ros: Ros):
assert isinstance(ros.ip.kid_control, KidControlModule)

def test_kid_control(self, ros: Ros):
for i in ros.ip.kid_control():
assert isinstance(i, KidControl)

def test_device(self, ros: Ros):
for i in ros.ip.kid_control.device():
assert isinstance(i, Device)


class TestService:
def test_service(self, ros: Ros):
for i in ros.ip.service():
Expand Down

0 comments on commit 6619f64

Please sign in to comment.