mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 10:58:37 -06:00
Clean up typing for GraphQL types
This commit is contained in:
parent
3a7edf3c0a
commit
52b0555940
@ -1,4 +1,4 @@
|
||||
from typing import Annotated, List, Union
|
||||
from typing import Annotated, List, TYPE_CHECKING, Union
|
||||
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
@ -10,11 +10,15 @@ from netbox.graphql.types import BaseObjectType, NetBoxObjectType, ObjectType, O
|
||||
from tenancy.graphql.types import TenantType
|
||||
from .filters import *
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from dcim.graphql.types import InterfaceType, LocationType, RegionType, SiteGroupType, SiteType
|
||||
from ipam.graphql.types import ASNType
|
||||
|
||||
__all__ = (
|
||||
'CircuitTerminationType',
|
||||
'CircuitType',
|
||||
'CircuitGroupAssignmentType',
|
||||
'CircuitGroupType',
|
||||
'CircuitTerminationType',
|
||||
'CircuitType',
|
||||
'CircuitTypeType',
|
||||
'ProviderType',
|
||||
'ProviderAccountType',
|
||||
@ -62,7 +66,7 @@ class ProviderNetworkType(NetBoxObjectType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.CircuitTermination,
|
||||
exclude=('termination_type', 'termination_id', '_location', '_region', '_site', '_site_group', '_provider_network'),
|
||||
exclude=['termination_type', 'termination_id', '_location', '_region', '_site', '_site_group', '_provider_network'],
|
||||
filters=CircuitTerminationFilter
|
||||
)
|
||||
class CircuitTerminationType(CustomFieldsMixin, TagsMixin, CabledObjectMixin, ObjectType):
|
||||
@ -117,7 +121,7 @@ class CircuitGroupType(OrganizationalObjectType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.CircuitGroupAssignment,
|
||||
exclude=('member_type', 'member_id'),
|
||||
exclude=['member_type', 'member_id'],
|
||||
filters=CircuitGroupAssignmentFilter
|
||||
)
|
||||
class CircuitGroupAssignmentType(TagsMixin, BaseObjectType):
|
||||
|
@ -3,15 +3,16 @@ from typing import Annotated, List
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
from django.contrib.contenttypes.models import ContentType as DjangoContentType
|
||||
|
||||
from core import models
|
||||
from netbox.graphql.types import BaseObjectType, NetBoxObjectType
|
||||
from .filters import *
|
||||
|
||||
__all__ = (
|
||||
'ContentType',
|
||||
'DataFileType',
|
||||
'DataSourceType',
|
||||
'ObjectChangeType',
|
||||
'ContentType',
|
||||
)
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from typing import Annotated, List, Union
|
||||
from typing import Annotated, List, TYPE_CHECKING, Union
|
||||
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
@ -6,7 +6,11 @@ import strawberry_django
|
||||
from core.graphql.mixins import ChangelogMixin
|
||||
from dcim import models
|
||||
from extras.graphql.mixins import (
|
||||
ConfigContextMixin, ContactsMixin, CustomFieldsMixin, ImageAttachmentsMixin, TagsMixin,
|
||||
ConfigContextMixin,
|
||||
ContactsMixin,
|
||||
CustomFieldsMixin,
|
||||
ImageAttachmentsMixin,
|
||||
TagsMixin,
|
||||
)
|
||||
from ipam.graphql.mixins import IPAddressesMixin, VLANGroupsMixin
|
||||
from netbox.graphql.scalars import BigInt
|
||||
@ -14,6 +18,23 @@ from netbox.graphql.types import BaseObjectType, NetBoxObjectType, Organizationa
|
||||
from .filters import *
|
||||
from .mixins import CabledObjectMixin, PathEndpointMixin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from circuits.graphql.types import CircuitTerminationType
|
||||
from extras.graphql.types import ConfigTemplateType
|
||||
from ipam.graphql.types import (
|
||||
ASNType,
|
||||
IPAddressType,
|
||||
PrefixType,
|
||||
ServiceType,
|
||||
VLANTranslationPolicyType,
|
||||
VLANType,
|
||||
VRFType,
|
||||
)
|
||||
from tenancy.graphql.types import TenantType
|
||||
from users.graphql.types import UserType
|
||||
from virtualization.graphql.types import ClusterType, VMInterfaceType, VirtualMachineType
|
||||
from wireless.graphql.types import WirelessLANType, WirelessLinkType
|
||||
|
||||
__all__ = (
|
||||
'CableType',
|
||||
'ComponentType',
|
||||
@ -111,7 +132,7 @@ class ModularComponentTemplateType(ComponentTemplateType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.CableTermination,
|
||||
exclude=('termination_type', 'termination_id', '_device', '_rack', '_location', '_site'),
|
||||
exclude=['termination_type', 'termination_id', '_device', '_rack', '_location', '_site'],
|
||||
filters=CableTerminationFilter
|
||||
)
|
||||
class CableTerminationType(NetBoxObjectType):
|
||||
@ -167,7 +188,7 @@ class CableType(NetBoxObjectType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.ConsolePort,
|
||||
exclude=('_path',),
|
||||
exclude=['_path'],
|
||||
filters=ConsolePortFilter
|
||||
)
|
||||
class ConsolePortType(ModularComponentType, CabledObjectMixin, PathEndpointMixin):
|
||||
@ -185,7 +206,7 @@ class ConsolePortTemplateType(ModularComponentTemplateType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.ConsoleServerPort,
|
||||
exclude=('_path',),
|
||||
exclude=['_path'],
|
||||
filters=ConsoleServerPortFilter
|
||||
)
|
||||
class ConsoleServerPortType(ModularComponentType, CabledObjectMixin, PathEndpointMixin):
|
||||
@ -276,7 +297,7 @@ class DeviceBayTemplateType(ComponentTemplateType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.InventoryItemTemplate,
|
||||
exclude=('component_type', 'component_id', 'parent'),
|
||||
exclude=['component_type', 'component_id', 'parent'],
|
||||
filters=InventoryItemTemplateFilter
|
||||
)
|
||||
class InventoryItemTemplateType(ComponentTemplateType):
|
||||
@ -369,7 +390,7 @@ class FrontPortTemplateType(ModularComponentTemplateType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.MACAddress,
|
||||
exclude=('assigned_object_type', 'assigned_object_id'),
|
||||
exclude=['assigned_object_type', 'assigned_object_id'],
|
||||
filters=MACAddressFilter
|
||||
)
|
||||
class MACAddressType(NetBoxObjectType):
|
||||
@ -385,7 +406,7 @@ class MACAddressType(NetBoxObjectType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.Interface,
|
||||
exclude=('_path',),
|
||||
exclude=['_path'],
|
||||
filters=InterfaceFilter
|
||||
)
|
||||
class InterfaceType(IPAddressesMixin, ModularComponentType, CabledObjectMixin, PathEndpointMixin):
|
||||
@ -424,7 +445,7 @@ class InterfaceTemplateType(ModularComponentTemplateType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.InventoryItem,
|
||||
exclude=('component_type', 'component_id', 'parent'),
|
||||
exclude=['component_type', 'component_id', 'parent'],
|
||||
filters=InventoryItemFilter
|
||||
)
|
||||
class InventoryItemType(ComponentType):
|
||||
@ -463,7 +484,7 @@ class InventoryItemRoleType(OrganizationalObjectType):
|
||||
@strawberry_django.type(
|
||||
models.Location,
|
||||
# fields='__all__',
|
||||
exclude=('parent',), # bug - temp
|
||||
exclude=['parent'], # bug - temp
|
||||
filters=LocationFilter
|
||||
)
|
||||
class LocationType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, OrganizationalObjectType):
|
||||
@ -524,7 +545,7 @@ class ModuleType(NetBoxObjectType):
|
||||
@strawberry_django.type(
|
||||
models.ModuleBay,
|
||||
# fields='__all__',
|
||||
exclude=('parent',),
|
||||
exclude=['parent'],
|
||||
filters=ModuleBayFilter
|
||||
)
|
||||
class ModuleBayType(ModularComponentType):
|
||||
@ -579,7 +600,7 @@ class PlatformType(OrganizationalObjectType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.PowerFeed,
|
||||
exclude=('_path',),
|
||||
exclude=['_path'],
|
||||
filters=PowerFeedFilter
|
||||
)
|
||||
class PowerFeedType(NetBoxObjectType, CabledObjectMixin, PathEndpointMixin):
|
||||
@ -590,7 +611,7 @@ class PowerFeedType(NetBoxObjectType, CabledObjectMixin, PathEndpointMixin):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.PowerOutlet,
|
||||
exclude=('_path',),
|
||||
exclude=['_path'],
|
||||
filters=PowerOutletFilter
|
||||
)
|
||||
class PowerOutletType(ModularComponentType, CabledObjectMixin, PathEndpointMixin):
|
||||
@ -621,7 +642,7 @@ class PowerPanelType(NetBoxObjectType, ContactsMixin):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.PowerPort,
|
||||
exclude=('_path',),
|
||||
exclude=['_path'],
|
||||
filters=PowerPortFilter
|
||||
)
|
||||
class PowerPortType(ModularComponentType, CabledObjectMixin, PathEndpointMixin):
|
||||
@ -712,8 +733,7 @@ class RearPortTemplateType(ModularComponentTemplateType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.Region,
|
||||
exclude=('parent',),
|
||||
# fields='__all__',
|
||||
exclude=['parent'],
|
||||
filters=RegionFilter
|
||||
)
|
||||
class RegionType(VLANGroupsMixin, ContactsMixin, OrganizationalObjectType):
|
||||
@ -772,8 +792,7 @@ class SiteType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObje
|
||||
|
||||
@strawberry_django.type(
|
||||
models.SiteGroup,
|
||||
# fields='__all__',
|
||||
exclude=('parent',), # bug - temp
|
||||
exclude=['parent'], # bug - temp
|
||||
filters=SiteGroupFilter
|
||||
)
|
||||
class SiteGroupType(VLANGroupsMixin, ContactsMixin, OrganizationalObjectType):
|
||||
|
@ -1,4 +1,4 @@
|
||||
from typing import Annotated, List
|
||||
from typing import Annotated, List, TYPE_CHECKING
|
||||
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
@ -8,6 +8,22 @@ from extras.graphql.mixins import CustomFieldsMixin, TagsMixin
|
||||
from netbox.graphql.types import BaseObjectType, ContentTypeType, ObjectType, OrganizationalObjectType
|
||||
from .filters import *
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.graphql.types import DataFileType, DataSourceType
|
||||
from dcim.graphql.types import (
|
||||
DeviceRoleType,
|
||||
DeviceType,
|
||||
DeviceTypeType,
|
||||
LocationType,
|
||||
PlatformType,
|
||||
RegionType,
|
||||
SiteGroupType,
|
||||
SiteType,
|
||||
)
|
||||
from tenancy.graphql.types import TenantGroupType, TenantType
|
||||
from users.graphql.types import GroupType, UserType
|
||||
from virtualization.graphql.types import ClusterGroupType, ClusterType, ClusterTypeType, VirtualMachineType
|
||||
|
||||
__all__ = (
|
||||
'ConfigContextType',
|
||||
'ConfigTemplateType',
|
||||
@ -35,7 +51,6 @@ __all__ = (
|
||||
class ConfigContextType(ObjectType):
|
||||
data_source: Annotated["DataSourceType", strawberry.lazy('core.graphql.types')] | None
|
||||
data_file: Annotated["DataFileType", strawberry.lazy('core.graphql.types')] | None
|
||||
|
||||
roles: List[Annotated["DeviceRoleType", strawberry.lazy('dcim.graphql.types')]]
|
||||
device_types: List[Annotated["DeviceTypeType", strawberry.lazy('dcim.graphql.types')]]
|
||||
tags: List[Annotated["TagType", strawberry.lazy('extras.graphql.types')]]
|
||||
@ -78,7 +93,7 @@ class CustomFieldType(ObjectType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.CustomFieldChoiceSet,
|
||||
exclude=('extra_choices', ),
|
||||
exclude=['extra_choices'],
|
||||
filters=CustomFieldChoiceSetFilter
|
||||
)
|
||||
class CustomFieldChoiceSetType(ObjectType):
|
||||
|
@ -1,4 +1,4 @@
|
||||
from typing import Annotated, List, Union
|
||||
from typing import Annotated, List, TYPE_CHECKING, Union
|
||||
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
@ -11,6 +11,21 @@ from netbox.graphql.types import BaseObjectType, NetBoxObjectType, Organizationa
|
||||
from .filters import *
|
||||
from .mixins import IPAddressesMixin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from dcim.graphql.types import (
|
||||
DeviceType,
|
||||
InterfaceType,
|
||||
LocationType,
|
||||
RackType,
|
||||
RegionType,
|
||||
SiteGroupType,
|
||||
SiteType,
|
||||
)
|
||||
from tenancy.graphql.types import TenantType
|
||||
from virtualization.graphql.types import ClusterGroupType, ClusterType, VMInterfaceType, VirtualMachineType
|
||||
from vpn.graphql.types import L2VPNType, TunnelTerminationType
|
||||
from wireless.graphql.types import WirelessLANType
|
||||
|
||||
__all__ = (
|
||||
'ASNType',
|
||||
'ASNRangeType',
|
||||
@ -101,7 +116,7 @@ class FHRPGroupType(NetBoxObjectType, IPAddressesMixin):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.FHRPGroupAssignment,
|
||||
exclude=('interface_type', 'interface_id'),
|
||||
exclude=['interface_type', 'interface_id'],
|
||||
filters=FHRPGroupAssignmentFilter
|
||||
)
|
||||
class FHRPGroupAssignmentType(BaseObjectType):
|
||||
@ -117,7 +132,7 @@ class FHRPGroupAssignmentType(BaseObjectType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.IPAddress,
|
||||
exclude=('assigned_object_type', 'assigned_object_id', 'address'),
|
||||
exclude=['assigned_object_type', 'assigned_object_id', 'address'],
|
||||
filters=IPAddressFilter
|
||||
)
|
||||
class IPAddressType(NetBoxObjectType, BaseIPAddressFamilyType):
|
||||
@ -154,7 +169,7 @@ class IPRangeType(NetBoxObjectType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.Prefix,
|
||||
exclude=('scope_type', 'scope_id', '_location', '_region', '_site', '_site_group'),
|
||||
exclude=['scope_type', 'scope_id', '_location', '_region', '_site', '_site_group'],
|
||||
filters=PrefixFilter
|
||||
)
|
||||
class PrefixType(NetBoxObjectType, BaseIPAddressFamilyType):
|
||||
@ -236,7 +251,7 @@ class ServiceTemplateType(NetBoxObjectType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.VLAN,
|
||||
exclude=('qinq_svlan',),
|
||||
exclude=['qinq_svlan'],
|
||||
filters=VLANFilter
|
||||
)
|
||||
class VLANType(NetBoxObjectType):
|
||||
@ -259,7 +274,7 @@ class VLANType(NetBoxObjectType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.VLANGroup,
|
||||
exclude=('scope_type', 'scope_id'),
|
||||
exclude=['scope_type', 'scope_id'],
|
||||
filters=VLANGroupFilter
|
||||
)
|
||||
class VLANGroupType(OrganizationalObjectType):
|
||||
|
@ -8,6 +8,7 @@ from extras.graphql.mixins import CustomFieldsMixin, JournalEntriesMixin, TagsMi
|
||||
|
||||
__all__ = (
|
||||
'BaseObjectType',
|
||||
'ContentTypeType',
|
||||
'ObjectType',
|
||||
'OrganizationalObjectType',
|
||||
'NetBoxObjectType',
|
||||
|
@ -6,16 +6,36 @@ import strawberry_django
|
||||
from extras.graphql.mixins import CustomFieldsMixin, TagsMixin
|
||||
from netbox.graphql.types import BaseObjectType, OrganizationalObjectType, NetBoxObjectType
|
||||
from tenancy import models
|
||||
from .mixins import ContactAssignmentsMixin
|
||||
from .filters import *
|
||||
from .mixins import ContactAssignmentsMixin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from circuits.graphql.types import *
|
||||
from dcim.graphql.types import *
|
||||
from ipam.graphql.types import *
|
||||
from wireless.graphql.types import *
|
||||
from virtualization.graphql.types import *
|
||||
from vpn.graphql.types import *
|
||||
from circuits.graphql.types import CircuitType
|
||||
from dcim.graphql.types import (
|
||||
CableType,
|
||||
DeviceType,
|
||||
LocationType,
|
||||
PowerFeedType,
|
||||
RackType,
|
||||
RackReservationType,
|
||||
SiteType,
|
||||
VirtualDeviceContextType,
|
||||
)
|
||||
from ipam.graphql.types import (
|
||||
AggregateType,
|
||||
ASNType,
|
||||
ASNRangeType,
|
||||
IPAddressType,
|
||||
IPRangeType,
|
||||
PrefixType,
|
||||
RouteTargetType,
|
||||
VLANType,
|
||||
VRFType,
|
||||
)
|
||||
from netbox.graphql.types import ContentTypeType
|
||||
from wireless.graphql.types import WirelessLANType, WirelessLinkType
|
||||
from virtualization.graphql.types import ClusterType, VirtualMachineType
|
||||
from vpn.graphql.types import L2VPNType, TunnelType
|
||||
|
||||
__all__ = (
|
||||
'ContactAssignmentType',
|
||||
|
@ -1,4 +1,4 @@
|
||||
from typing import Annotated, List, Union
|
||||
from typing import Annotated, List, TYPE_CHECKING, Union
|
||||
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
@ -10,6 +10,21 @@ from netbox.graphql.types import OrganizationalObjectType, NetBoxObjectType
|
||||
from virtualization import models
|
||||
from .filters import *
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from dcim.graphql.types import (
|
||||
DeviceRoleType,
|
||||
DeviceType,
|
||||
LocationType,
|
||||
MACAddressType,
|
||||
PlatformType,
|
||||
RegionType,
|
||||
SiteGroupType,
|
||||
SiteType,
|
||||
)
|
||||
from extras.graphql.types import ConfigTemplateType
|
||||
from ipam.graphql.types import IPAddressType, ServiceType, VLANTranslationPolicyType, VLANType, VRFType
|
||||
from tenancy.graphql.types import TenantType
|
||||
|
||||
__all__ = (
|
||||
'ClusterType',
|
||||
'ClusterGroupType',
|
||||
@ -30,7 +45,7 @@ class ComponentType(NetBoxObjectType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.Cluster,
|
||||
exclude=('scope_type', 'scope_id', '_location', '_region', '_site', '_site_group'),
|
||||
exclude=['scope_type', 'scope_id', '_location', '_region', '_site', '_site_group'],
|
||||
filters=ClusterFilter
|
||||
)
|
||||
class ClusterType(VLANGroupsMixin, NetBoxObjectType):
|
||||
|
@ -1,4 +1,4 @@
|
||||
from typing import Annotated, List, Union
|
||||
from typing import Annotated, List, TYPE_CHECKING, Union
|
||||
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
@ -8,6 +8,13 @@ from netbox.graphql.types import ObjectType, OrganizationalObjectType, NetBoxObj
|
||||
from vpn import models
|
||||
from .filters import *
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from dcim.graphql.types import InterfaceType
|
||||
from ipam.graphql.types import IPAddressType, RouteTargetType, VLANType
|
||||
from netbox.graphql.types import ContentTypeType
|
||||
from tenancy.graphql.types import TenantType
|
||||
from virtualization.graphql.types import VMInterfaceType
|
||||
|
||||
__all__ = (
|
||||
'IKEPolicyType',
|
||||
'IKEProposalType',
|
||||
@ -125,7 +132,7 @@ class L2VPNType(ContactsMixin, NetBoxObjectType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.L2VPNTermination,
|
||||
exclude=('assigned_object_type', 'assigned_object_id'),
|
||||
exclude=['assigned_object_type', 'assigned_object_id'],
|
||||
filters=L2VPNTerminationFilter
|
||||
)
|
||||
class L2VPNTerminationType(NetBoxObjectType):
|
||||
|
@ -1,4 +1,4 @@
|
||||
from typing import Annotated, List, Union
|
||||
from typing import Annotated, List, TYPE_CHECKING, Union
|
||||
|
||||
import strawberry
|
||||
import strawberry_django
|
||||
@ -7,6 +7,11 @@ from netbox.graphql.types import OrganizationalObjectType, NetBoxObjectType
|
||||
from wireless import models
|
||||
from .filters import *
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from dcim.graphql.types import DeviceType, InterfaceType, LocationType, RegionType, SiteGroupType, SiteType
|
||||
from ipam.graphql.types import VLANType
|
||||
from tenancy.graphql.types import TenantType
|
||||
|
||||
__all__ = (
|
||||
'WirelessLANType',
|
||||
'WirelessLANGroupType',
|
||||
@ -28,7 +33,7 @@ class WirelessLANGroupType(OrganizationalObjectType):
|
||||
|
||||
@strawberry_django.type(
|
||||
models.WirelessLAN,
|
||||
exclude=('scope_type', 'scope_id', '_location', '_region', '_site', '_site_group'),
|
||||
exclude=['scope_type', 'scope_id', '_location', '_region', '_site', '_site_group'],
|
||||
filters=WirelessLANFilter
|
||||
)
|
||||
class WirelessLANType(NetBoxObjectType):
|
||||
|
Loading…
Reference in New Issue
Block a user