Coverage for wireless/graphql/types.py: 79%
22 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 18:35 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 18:35 +0000
1from typing import TYPE_CHECKING, Annotated
3import strawberry
4import strawberry_django
6from dcim.models import Location, Region, Site, SiteGroup
7from netbox.graphql.optimization import build_gfk_prefetch
8from netbox.graphql.types import NestedLtreeGroupObjectType, PrimaryObjectType, register_type
9from wireless import models
11from .filters import *
13if TYPE_CHECKING: 13 ↛ 14line 13 didn't jump to line 14 because the condition on line 13 was never true
14 from dcim.graphql.types import DeviceType, InterfaceType, LocationType, RegionType, SiteGroupType, SiteType
15 from ipam.graphql.types import VLANType
16 from tenancy.graphql.types import TenantType
18__all__ = (
19 'WirelessLANGroupType',
20 'WirelessLANType',
21 'WirelessLinkType',
22)
25@register_type(
26 models.WirelessLANGroup,
27 exclude=['path', 'sort_path'],
28 filters=WirelessLANGroupFilter,
29 pagination=True
30)
31class WirelessLANGroupType(NestedLtreeGroupObjectType):
32 parent: Annotated["WirelessLANGroupType", strawberry.lazy('wireless.graphql.types')] | None
34 wireless_lans: list[Annotated["WirelessLANType", strawberry.lazy('wireless.graphql.types')]]
35 children: list[Annotated["WirelessLANGroupType", strawberry.lazy('wireless.graphql.types')]]
38@register_type(
39 models.WirelessLAN,
40 exclude=['scope_type', 'scope_id', '_location', '_region', '_site', '_site_group'],
41 filters=WirelessLANFilter,
42 pagination=True
43)
44class WirelessLANType(PrimaryObjectType):
45 group: Annotated["WirelessLANGroupType", strawberry.lazy('wireless.graphql.types')] | None
46 vlan: Annotated["VLANType", strawberry.lazy('ipam.graphql.types')] | None
47 tenant: Annotated["TenantType", strawberry.lazy('tenancy.graphql.types')] | None
49 interfaces: list[Annotated["InterfaceType", strawberry.lazy('dcim.graphql.types')]]
51 @strawberry_django.field(
52 prefetch_related=build_gfk_prefetch(
53 'scope',
54 [
55 Region,
56 SiteGroup,
57 Site,
58 Location,
59 ],
60 ),
61 only=['scope_type', 'scope_id'],
62 )
63 def scope(self) -> Annotated[
64 Annotated['LocationType', strawberry.lazy('dcim.graphql.types')]
65 | Annotated['RegionType', strawberry.lazy('dcim.graphql.types')]
66 | Annotated['SiteGroupType', strawberry.lazy('dcim.graphql.types')]
67 | Annotated['SiteType', strawberry.lazy('dcim.graphql.types')],
68 strawberry.union('WirelessLANScopeType'),
69 ] | None:
70 return self.scope
73@register_type(
74 models.WirelessLink,
75 fields='__all__',
76 filters=WirelessLinkFilter,
77 pagination=True
78)
79class WirelessLinkType(PrimaryObjectType):
80 interface_a: Annotated["InterfaceType", strawberry.lazy('dcim.graphql.types')]
81 interface_b: Annotated["InterfaceType", strawberry.lazy('dcim.graphql.types')]
82 tenant: Annotated["TenantType", strawberry.lazy('tenancy.graphql.types')] | None
83 _interface_a_device: Annotated["DeviceType", strawberry.lazy('dcim.graphql.types')] | None
84 _interface_b_device: Annotated["DeviceType", strawberry.lazy('dcim.graphql.types')] | None