Coverage for netbox_interface_name_rules / graphql / types.py: 100.00%
10 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-10-16 10:13 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-10-16 10:13 +0000
1# SPDX-License-Identifier: Apache-2.0
2# Copyright (C) 2025 Marcin Zieba <marcinpsk@gmail.com>
4"""GraphQL object type for InterfaceNameRule."""
6from typing import TYPE_CHECKING, Annotated
8import strawberry
9import strawberry_django
10from netbox.graphql.types import NetBoxObjectType
12from netbox_interface_name_rules.models import InterfaceNameRule
14from .filters import InterfaceNameRuleFilter
16if TYPE_CHECKING:
17 from dcim.graphql.types import DeviceTypeType, ModuleTypeType, PlatformType
19# The filter base only exists on NetBox 4.5+; register without one where it doesn't.
20_type_kwargs = {"fields": "__all__", "pagination": True}
21if InterfaceNameRuleFilter is not None: # pragma: no cover — absent only on NetBox 4.3
22 _type_kwargs["filters"] = InterfaceNameRuleFilter
25@strawberry_django.type(InterfaceNameRule, **_type_kwargs)
26class InterfaceNameRuleType(NetBoxObjectType):
27 """An interface rename rule."""
29 # Without these the relations resolve to a bare DjangoModelType with no queryable fields.
30 module_type: Annotated["ModuleTypeType", strawberry.lazy("dcim.graphql.types")] | None
31 parent_module_type: Annotated["ModuleTypeType", strawberry.lazy("dcim.graphql.types")] | None
32 device_type: Annotated["DeviceTypeType", strawberry.lazy("dcim.graphql.types")] | None
33 platform: Annotated["PlatformType", strawberry.lazy("dcim.graphql.types")] | None
36__all__ = ("InterfaceNameRuleType",)