refactor(access-point): the new shapes beside their declarations, models.py within its ratchet
DhcpLeaseDict lives in dhcp_leases, the AP shapes in access_point_models; models.py stays at its recorded size.
This commit is contained in:
1 parent
0db9c9ba65
commit
2ad1ead2f5
6 files changed
+30
-34
No files matched your search
@@ -86,6 +86,12 @@ Introspection -- :func:`~napalm_device_types.roles.roles_of`,
|
||||
"""
|
||||
|
||||
from napalm_device_types.access_point import AccessPointDriver
|
||||
from napalm_device_types.access_point_models import (
|
||||
ApConfigDict,
|
||||
ApConfigResultDict,
|
||||
ApSsidConfigDict,
|
||||
SsidConfigDict,
|
||||
)
|
||||
from napalm_device_types.ap_config import (
|
||||
AP_CONFIG_PARTS,
|
||||
AP_CONFIG_SSID_ATTRIBUTES,
|
||||
@@ -180,7 +186,7 @@ from napalm_device_types.credential_expiry import (
|
||||
CredentialKind,
|
||||
)
|
||||
from napalm_device_types.dhcp import DhcpApplyError, DhcpServerMixin, normalize_cidr, normalize_mac
|
||||
from napalm_device_types.dhcp_leases import DhcpLeasesMixin
|
||||
from napalm_device_types.dhcp_leases import DhcpLeaseDict, DhcpLeasesMixin
|
||||
from napalm_device_types.dns_forward import DnsForwardMixin
|
||||
from napalm_device_types.firewall import FirewallDriver
|
||||
from napalm_device_types.firewall_rules import FirewallRuleMixin
|
||||
@@ -277,13 +283,9 @@ from napalm_device_types.management_controller import ManagementControllerDriver
|
||||
from napalm_device_types.media import MediaDriver
|
||||
from napalm_device_types.models import (
|
||||
POWER_ACTIONS,
|
||||
ApConfigDict,
|
||||
ApConfigResultDict,
|
||||
ApSsidConfigDict,
|
||||
ConfigSyncDict,
|
||||
DhcpHaDict,
|
||||
DhcpHaPeerDict,
|
||||
DhcpLeaseDict,
|
||||
DnsForwardDict,
|
||||
EventLogEntryDict,
|
||||
FirmwareDict,
|
||||
@@ -299,7 +301,6 @@ from napalm_device_types.models import (
|
||||
PowerAction,
|
||||
PowerStateDict,
|
||||
SnmpAgentSettingsDict,
|
||||
SsidConfigDict,
|
||||
UpdateProgressDict,
|
||||
)
|
||||
from napalm_device_types.nat_vpn import NatVpnMixin
|
||||
|
||||
@@ -17,7 +17,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from napalm_device_types.models import ApConfigDict, ApConfigResultDict
|
||||
from napalm_device_types.access_point_models import ApConfigDict, ApConfigResultDict
|
||||
|
||||
#: The parts without a subject, and the values of ``ApConfigDict`` each writes.
|
||||
AP_CONFIG_PARTS = frozenset(
|
||||
|
||||
@@ -15,7 +15,22 @@ from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from napalm_device_types.models import DhcpLeaseDict
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
class DhcpLeaseDict(TypedDict):
|
||||
"""A lease a DHCP server handed out (``DhcpLeasesMixin.get_dhcp_leases``).
|
||||
|
||||
``mac`` lower-case and colon-separated; ``hostname`` "" when the client sent
|
||||
none; ``lease_end`` the Unix time the lease ends, 0 when it does not end or is
|
||||
not known; ``state`` the server's own word for it ("" when it has none).
|
||||
"""
|
||||
|
||||
mac: str
|
||||
ip: str
|
||||
hostname: str
|
||||
lease_end: int
|
||||
state: str
|
||||
|
||||
|
||||
class DhcpLeasesMixin:
|
||||
|
||||
@@ -8,10 +8,6 @@ from typing import Literal, NotRequired, get_args
|
||||
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
from napalm_device_types.access_point_models import ApConfigDict as ApConfigDict
|
||||
from napalm_device_types.access_point_models import ApConfigResultDict as ApConfigResultDict
|
||||
from napalm_device_types.access_point_models import ApSsidConfigDict as ApSsidConfigDict
|
||||
|
||||
# The SNMP health profile shapes live in snmp_health_profile.py, those of the access
|
||||
# point getters in access_point_models.py; re-exported here, where they were.
|
||||
from napalm_device_types.access_point_models import ChannelScanEntryDict as ChannelScanEntryDict
|
||||
@@ -22,7 +18,6 @@ from napalm_device_types.access_point_models import MeshConfigDict as MeshConfig
|
||||
from napalm_device_types.access_point_models import MeshPeerDict as MeshPeerDict
|
||||
from napalm_device_types.access_point_models import RadioStatusDict as RadioStatusDict
|
||||
from napalm_device_types.access_point_models import SSIDBridgeDict as SSIDBridgeDict
|
||||
from napalm_device_types.access_point_models import SsidConfigDict as SsidConfigDict
|
||||
from napalm_device_types.access_point_models import SSIDDict as SSIDDict
|
||||
from napalm_device_types.access_point_models import WirelessClientDict as WirelessClientDict
|
||||
from napalm_device_types.access_point_models import WirelessConfigDict as WirelessConfigDict
|
||||
@@ -540,21 +535,6 @@ class FirewallRuleDiffDict(TypedDict):
|
||||
update: list[FirewallRuleUpdateDict]
|
||||
|
||||
|
||||
class DhcpLeaseDict(TypedDict):
|
||||
"""A lease a DHCP server handed out (``DhcpLeasesMixin.get_dhcp_leases``).
|
||||
|
||||
``mac`` lower-case and colon-separated; ``hostname`` "" when the client sent
|
||||
none; ``lease_end`` the Unix time the lease ends, 0 when it does not end or is
|
||||
not known; ``state`` the server's own word for it ("" when it has none).
|
||||
"""
|
||||
|
||||
mac: str
|
||||
ip: str
|
||||
hostname: str
|
||||
lease_end: int
|
||||
state: str
|
||||
|
||||
|
||||
class DhcpReservationDict(TypedDict):
|
||||
"""A single static DHCP reservation (MAC -> IP), in vendor-neutral form.
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from napalm_device_types.models import SsidConfigDict
|
||||
from napalm_device_types.access_point_models import SsidConfigDict
|
||||
|
||||
#: The channel that lets a radio choose its own (``set_radio_channels``).
|
||||
AUTO_CHANNEL = 0
|
||||
|
||||
@@ -179,12 +179,12 @@ class TestDeclarations:
|
||||
):
|
||||
assert name in napalm_device_types.__all__, name
|
||||
|
||||
def test_models_re_exports_the_shapes(self):
|
||||
from napalm_device_types import models
|
||||
def test_the_shapes_live_beside_their_declarations(self):
|
||||
from napalm_device_types import access_point_models, dhcp_leases
|
||||
|
||||
assert models.DhcpLeaseDict is DhcpLeaseDict
|
||||
assert models.SsidConfigDict is SsidConfigDict
|
||||
assert models.ApConfigDict is ApConfigDict
|
||||
assert dhcp_leases.DhcpLeaseDict is DhcpLeaseDict
|
||||
assert access_point_models.SsidConfigDict is SsidConfigDict
|
||||
assert access_point_models.ApConfigDict is ApConfigDict
|
||||
|
||||
|
||||
class TestParts:
|
||||
|
||||
Reference in new issue
Block a user