16244 add pagination

This commit is contained in:
Arthur 2025-03-13 14:47:40 -07:00
parent 26e02ada30
commit 03a0b1749c
6 changed files with 319 additions and 177 deletions

View File

@ -8,35 +8,35 @@ from .types import *
@strawberry.type(name="Query")
class CircuitsQuery:
circuit: CircuitType = strawberry_django.field()
circuit_list: List[CircuitType] = strawberry_django.field()
circuit: CircuitType = strawberry_django.field(pagination=True)
circuit_list: List[CircuitType] = strawberry_django.field(pagination=True)
circuit_termination: CircuitTerminationType = strawberry_django.field()
circuit_termination_list: List[CircuitTerminationType] = strawberry_django.field()
circuit_termination: CircuitTerminationType = strawberry_django.field(pagination=True)
circuit_termination_list: List[CircuitTerminationType] = strawberry_django.field(pagination=True)
circuit_type: CircuitTypeType = strawberry_django.field()
circuit_type_list: List[CircuitTypeType] = strawberry_django.field()
circuit_type: CircuitTypeType = strawberry_django.field(pagination=True)
circuit_type_list: List[CircuitTypeType] = strawberry_django.field(pagination=True)
circuit_group: CircuitGroupType = strawberry_django.field()
circuit_group_list: List[CircuitGroupType] = strawberry_django.field()
circuit_group: CircuitGroupType = strawberry_django.field(pagination=True)
circuit_group_list: List[CircuitGroupType] = strawberry_django.field(pagination=True)
circuit_group_assignment: CircuitGroupAssignmentType = strawberry_django.field()
circuit_group_assignment_list: List[CircuitGroupAssignmentType] = strawberry_django.field()
circuit_group_assignment: CircuitGroupAssignmentType = strawberry_django.field(pagination=True)
circuit_group_assignment_list: List[CircuitGroupAssignmentType] = strawberry_django.field(pagination=True)
provider: ProviderType = strawberry_django.field()
provider_list: List[ProviderType] = strawberry_django.field()
provider: ProviderType = strawberry_django.field(pagination=True)
provider_list: List[ProviderType] = strawberry_django.field(pagination=True)
provider_account: ProviderAccountType = strawberry_django.field()
provider_account_list: List[ProviderAccountType] = strawberry_django.field()
provider_account: ProviderAccountType = strawberry_django.field(pagination=True)
provider_account_list: List[ProviderAccountType] = strawberry_django.field(pagination=True)
provider_network: ProviderNetworkType = strawberry_django.field()
provider_network_list: List[ProviderNetworkType] = strawberry_django.field()
provider_network: ProviderNetworkType = strawberry_django.field(pagination=True)
provider_network_list: List[ProviderNetworkType] = strawberry_django.field(pagination=True)
virtual_circuit: VirtualCircuitType = strawberry_django.field()
virtual_circuit_list: List[VirtualCircuitType] = strawberry_django.field()
virtual_circuit: VirtualCircuitType = strawberry_django.field(pagination=True)
virtual_circuit_list: List[VirtualCircuitType] = strawberry_django.field(pagination=True)
virtual_circuit_termination: VirtualCircuitTerminationType = strawberry_django.field()
virtual_circuit_termination_list: List[VirtualCircuitTerminationType] = strawberry_django.field()
virtual_circuit_termination: VirtualCircuitTerminationType = strawberry_django.field(pagination=True)
virtual_circuit_termination_list: List[VirtualCircuitTerminationType] = strawberry_django.field(pagination=True)
virtual_circuit_type: VirtualCircuitTypeType = strawberry_django.field()
virtual_circuit_type_list: List[VirtualCircuitTypeType] = strawberry_django.field()
virtual_circuit_type: VirtualCircuitTypeType = strawberry_django.field(pagination=True)
virtual_circuit_type_list: List[VirtualCircuitTypeType] = strawberry_django.field(pagination=True)

View File

@ -32,7 +32,8 @@ __all__ = (
@strawberry_django.type(
models.Provider,
fields='__all__',
filters=ProviderFilter
filters=ProviderFilter,
pagination=True
)
class ProviderType(NetBoxObjectType, ContactsMixin):
@ -45,7 +46,9 @@ class ProviderType(NetBoxObjectType, ContactsMixin):
@strawberry_django.type(
models.ProviderAccount,
fields='__all__',
filters=ProviderAccountFilter
filters=ProviderAccountFilter,
pagination=True
)
class ProviderAccountType(NetBoxObjectType):
provider: Annotated["ProviderType", strawberry.lazy('circuits.graphql.types')]
@ -56,7 +59,9 @@ class ProviderAccountType(NetBoxObjectType):
@strawberry_django.type(
models.ProviderNetwork,
fields='__all__',
filters=ProviderNetworkFilter
filters=ProviderNetworkFilter,
pagination=True
)
class ProviderNetworkType(NetBoxObjectType):
provider: Annotated["ProviderType", strawberry.lazy('circuits.graphql.types')]
@ -67,7 +72,9 @@ class ProviderNetworkType(NetBoxObjectType):
@strawberry_django.type(
models.CircuitTermination,
exclude=['termination_type', 'termination_id', '_location', '_region', '_site', '_site_group', '_provider_network'],
filters=CircuitTerminationFilter
filters=CircuitTerminationFilter,
pagination=True
)
class CircuitTerminationType(CustomFieldsMixin, TagsMixin, CabledObjectMixin, ObjectType):
circuit: Annotated["CircuitType", strawberry.lazy('circuits.graphql.types')]
@ -86,7 +93,9 @@ class CircuitTerminationType(CustomFieldsMixin, TagsMixin, CabledObjectMixin, Ob
@strawberry_django.type(
models.CircuitType,
fields='__all__',
filters=CircuitTypeFilter
filters=CircuitTypeFilter,
pagination=True
)
class CircuitTypeType(OrganizationalObjectType):
color: str
@ -97,7 +106,9 @@ class CircuitTypeType(OrganizationalObjectType):
@strawberry_django.type(
models.Circuit,
fields='__all__',
filters=CircuitFilter
filters=CircuitFilter,
pagination=True
)
class CircuitType(NetBoxObjectType, ContactsMixin):
provider: ProviderType
@ -113,7 +124,9 @@ class CircuitType(NetBoxObjectType, ContactsMixin):
@strawberry_django.type(
models.CircuitGroup,
fields='__all__',
filters=CircuitGroupFilter
filters=CircuitGroupFilter,
pagination=True
)
class CircuitGroupType(OrganizationalObjectType):
tenant: TenantType | None
@ -122,7 +135,9 @@ class CircuitGroupType(OrganizationalObjectType):
@strawberry_django.type(
models.CircuitGroupAssignment,
exclude=['member_type', 'member_id'],
filters=CircuitGroupAssignmentFilter
filters=CircuitGroupAssignmentFilter,
pagination=True
)
class CircuitGroupAssignmentType(TagsMixin, BaseObjectType):
group: Annotated["CircuitGroupType", strawberry.lazy('circuits.graphql.types')]
@ -138,7 +153,9 @@ class CircuitGroupAssignmentType(TagsMixin, BaseObjectType):
@strawberry_django.type(
models.VirtualCircuitType,
fields='__all__',
filters=VirtualCircuitTypeFilter
filters=VirtualCircuitTypeFilter,
pagination=True
)
class VirtualCircuitTypeType(OrganizationalObjectType):
color: str
@ -149,7 +166,9 @@ class VirtualCircuitTypeType(OrganizationalObjectType):
@strawberry_django.type(
models.VirtualCircuitTermination,
fields='__all__',
filters=VirtualCircuitTerminationFilter
filters=VirtualCircuitTerminationFilter,
pagination=True
)
class VirtualCircuitTerminationType(CustomFieldsMixin, TagsMixin, ObjectType):
virtual_circuit: Annotated[
@ -165,7 +184,9 @@ class VirtualCircuitTerminationType(CustomFieldsMixin, TagsMixin, ObjectType):
@strawberry_django.type(
models.VirtualCircuit,
fields='__all__',
filters=VirtualCircuitFilter
filters=VirtualCircuitFilter,
pagination=True
)
class VirtualCircuitType(NetBoxObjectType):
provider_network: ProviderNetworkType = strawberry_django.field(select_related=["provider_network"])

View File

@ -8,128 +8,128 @@ from .types import *
@strawberry.type(name="Query")
class DCIMQuery:
cable: CableType = strawberry_django.field()
cable_list: List[CableType] = strawberry_django.field()
cable: CableType = strawberry_django.field(pagination=True)
cable_list: List[CableType] = strawberry_django.field(pagination=True)
console_port: ConsolePortType = strawberry_django.field()
console_port_list: List[ConsolePortType] = strawberry_django.field()
console_port: ConsolePortType = strawberry_django.field(pagination=True)
console_port_list: List[ConsolePortType] = strawberry_django.field(pagination=True)
console_port_template: ConsolePortTemplateType = strawberry_django.field()
console_port_template_list: List[ConsolePortTemplateType] = strawberry_django.field()
console_port_template: ConsolePortTemplateType = strawberry_django.field(pagination=True)
console_port_template_list: List[ConsolePortTemplateType] = strawberry_django.field(pagination=True)
console_server_port: ConsoleServerPortType = strawberry_django.field()
console_server_port_list: List[ConsoleServerPortType] = strawberry_django.field()
console_server_port: ConsoleServerPortType = strawberry_django.field(pagination=True)
console_server_port_list: List[ConsoleServerPortType] = strawberry_django.field(pagination=True)
console_server_port_template: ConsoleServerPortTemplateType = strawberry_django.field()
console_server_port_template_list: List[ConsoleServerPortTemplateType] = strawberry_django.field()
console_server_port_template: ConsoleServerPortTemplateType = strawberry_django.field(pagination=True)
console_server_port_template_list: List[ConsoleServerPortTemplateType] = strawberry_django.field(pagination=True)
device: DeviceType = strawberry_django.field()
device_list: List[DeviceType] = strawberry_django.field()
device: DeviceType = strawberry_django.field(pagination=True)
device_list: List[DeviceType] = strawberry_django.field(pagination=True)
device_bay: DeviceBayType = strawberry_django.field()
device_bay_list: List[DeviceBayType] = strawberry_django.field()
device_bay: DeviceBayType = strawberry_django.field(pagination=True)
device_bay_list: List[DeviceBayType] = strawberry_django.field(pagination=True)
device_bay_template: DeviceBayTemplateType = strawberry_django.field()
device_bay_template_list: List[DeviceBayTemplateType] = strawberry_django.field()
device_bay_template: DeviceBayTemplateType = strawberry_django.field(pagination=True)
device_bay_template_list: List[DeviceBayTemplateType] = strawberry_django.field(pagination=True)
device_role: DeviceRoleType = strawberry_django.field()
device_role_list: List[DeviceRoleType] = strawberry_django.field()
device_role: DeviceRoleType = strawberry_django.field(pagination=True)
device_role_list: List[DeviceRoleType] = strawberry_django.field(pagination=True)
device_type: DeviceTypeType = strawberry_django.field()
device_type_list: List[DeviceTypeType] = strawberry_django.field()
device_type: DeviceTypeType = strawberry_django.field(pagination=True)
device_type_list: List[DeviceTypeType] = strawberry_django.field(pagination=True)
front_port: FrontPortType = strawberry_django.field()
front_port_list: List[FrontPortType] = strawberry_django.field()
front_port: FrontPortType = strawberry_django.field(pagination=True)
front_port_list: List[FrontPortType] = strawberry_django.field(pagination=True)
front_port_template: FrontPortTemplateType = strawberry_django.field()
front_port_template_list: List[FrontPortTemplateType] = strawberry_django.field()
front_port_template: FrontPortTemplateType = strawberry_django.field(pagination=True)
front_port_template_list: List[FrontPortTemplateType] = strawberry_django.field(pagination=True)
mac_address: MACAddressType = strawberry_django.field()
mac_address_list: List[MACAddressType] = strawberry_django.field()
mac_address: MACAddressType = strawberry_django.field(pagination=True)
mac_address_list: List[MACAddressType] = strawberry_django.field(pagination=True)
interface: InterfaceType = strawberry_django.field()
interface_list: List[InterfaceType] = strawberry_django.field()
interface: InterfaceType = strawberry_django.field(pagination=True)
interface_list: List[InterfaceType] = strawberry_django.field(pagination=True)
interface_template: InterfaceTemplateType = strawberry_django.field()
interface_template_list: List[InterfaceTemplateType] = strawberry_django.field()
interface_template: InterfaceTemplateType = strawberry_django.field(pagination=True)
interface_template_list: List[InterfaceTemplateType] = strawberry_django.field(pagination=True)
inventory_item: InventoryItemType = strawberry_django.field()
inventory_item_list: List[InventoryItemType] = strawberry_django.field()
inventory_item: InventoryItemType = strawberry_django.field(pagination=True)
inventory_item_list: List[InventoryItemType] = strawberry_django.field(pagination=True)
inventory_item_role: InventoryItemRoleType = strawberry_django.field()
inventory_item_role_list: List[InventoryItemRoleType] = strawberry_django.field()
inventory_item_role: InventoryItemRoleType = strawberry_django.field(pagination=True)
inventory_item_role_list: List[InventoryItemRoleType] = strawberry_django.field(pagination=True)
inventory_item_template: InventoryItemTemplateType = strawberry_django.field()
inventory_item_template_list: List[InventoryItemTemplateType] = strawberry_django.field()
inventory_item_template: InventoryItemTemplateType = strawberry_django.field(pagination=True)
inventory_item_template_list: List[InventoryItemTemplateType] = strawberry_django.field(pagination=True)
location: LocationType = strawberry_django.field()
location_list: List[LocationType] = strawberry_django.field()
location: LocationType = strawberry_django.field(pagination=True)
location_list: List[LocationType] = strawberry_django.field(pagination=True)
manufacturer: ManufacturerType = strawberry_django.field()
manufacturer_list: List[ManufacturerType] = strawberry_django.field()
manufacturer: ManufacturerType = strawberry_django.field(pagination=True)
manufacturer_list: List[ManufacturerType] = strawberry_django.field(pagination=True)
module: ModuleType = strawberry_django.field()
module_list: List[ModuleType] = strawberry_django.field()
module: ModuleType = strawberry_django.field(pagination=True)
module_list: List[ModuleType] = strawberry_django.field(pagination=True)
module_bay: ModuleBayType = strawberry_django.field()
module_bay_list: List[ModuleBayType] = strawberry_django.field()
module_bay: ModuleBayType = strawberry_django.field(pagination=True)
module_bay_list: List[ModuleBayType] = strawberry_django.field(pagination=True)
module_bay_template: ModuleBayTemplateType = strawberry_django.field()
module_bay_template_list: List[ModuleBayTemplateType] = strawberry_django.field()
module_bay_template: ModuleBayTemplateType = strawberry_django.field(pagination=True)
module_bay_template_list: List[ModuleBayTemplateType] = strawberry_django.field(pagination=True)
module_type: ModuleTypeType = strawberry_django.field()
module_type_list: List[ModuleTypeType] = strawberry_django.field()
module_type: ModuleTypeType = strawberry_django.field(pagination=True)
module_type_list: List[ModuleTypeType] = strawberry_django.field(pagination=True)
platform: PlatformType = strawberry_django.field()
platform_list: List[PlatformType] = strawberry_django.field()
platform: PlatformType = strawberry_django.field(pagination=True)
platform_list: List[PlatformType] = strawberry_django.field(pagination=True)
power_feed: PowerFeedType = strawberry_django.field()
power_feed_list: List[PowerFeedType] = strawberry_django.field()
power_feed: PowerFeedType = strawberry_django.field(pagination=True)
power_feed_list: List[PowerFeedType] = strawberry_django.field(pagination=True)
power_outlet: PowerOutletType = strawberry_django.field()
power_outlet_list: List[PowerOutletType] = strawberry_django.field()
power_outlet: PowerOutletType = strawberry_django.field(pagination=True)
power_outlet_list: List[PowerOutletType] = strawberry_django.field(pagination=True)
power_outlet_template: PowerOutletTemplateType = strawberry_django.field()
power_outlet_template_list: List[PowerOutletTemplateType] = strawberry_django.field()
power_outlet_template: PowerOutletTemplateType = strawberry_django.field(pagination=True)
power_outlet_template_list: List[PowerOutletTemplateType] = strawberry_django.field(pagination=True)
power_panel: PowerPanelType = strawberry_django.field()
power_panel_list: List[PowerPanelType] = strawberry_django.field()
power_panel: PowerPanelType = strawberry_django.field(pagination=True)
power_panel_list: List[PowerPanelType] = strawberry_django.field(pagination=True)
power_port: PowerPortType = strawberry_django.field()
power_port_list: List[PowerPortType] = strawberry_django.field()
power_port: PowerPortType = strawberry_django.field(pagination=True)
power_port_list: List[PowerPortType] = strawberry_django.field(pagination=True)
power_port_template: PowerPortTemplateType = strawberry_django.field()
power_port_template_list: List[PowerPortTemplateType] = strawberry_django.field()
power_port_template: PowerPortTemplateType = strawberry_django.field(pagination=True)
power_port_template_list: List[PowerPortTemplateType] = strawberry_django.field(pagination=True)
rack_type: RackTypeType = strawberry_django.field()
rack_type_list: List[RackTypeType] = strawberry_django.field()
rack_type: RackTypeType = strawberry_django.field(pagination=True)
rack_type_list: List[RackTypeType] = strawberry_django.field(pagination=True)
rack: RackType = strawberry_django.field()
rack_list: List[RackType] = strawberry_django.field()
rack: RackType = strawberry_django.field(pagination=True)
rack_list: List[RackType] = strawberry_django.field(pagination=True)
rack_reservation: RackReservationType = strawberry_django.field()
rack_reservation_list: List[RackReservationType] = strawberry_django.field()
rack_reservation: RackReservationType = strawberry_django.field(pagination=True)
rack_reservation_list: List[RackReservationType] = strawberry_django.field(pagination=True)
rack_role: RackRoleType = strawberry_django.field()
rack_role_list: List[RackRoleType] = strawberry_django.field()
rack_role: RackRoleType = strawberry_django.field(pagination=True)
rack_role_list: List[RackRoleType] = strawberry_django.field(pagination=True)
rear_port: RearPortType = strawberry_django.field()
rear_port_list: List[RearPortType] = strawberry_django.field()
rear_port: RearPortType = strawberry_django.field(pagination=True)
rear_port_list: List[RearPortType] = strawberry_django.field(pagination=True)
rear_port_template: RearPortTemplateType = strawberry_django.field()
rear_port_template_list: List[RearPortTemplateType] = strawberry_django.field()
rear_port_template: RearPortTemplateType = strawberry_django.field(pagination=True)
rear_port_template_list: List[RearPortTemplateType] = strawberry_django.field(pagination=True)
region: RegionType = strawberry_django.field()
region_list: List[RegionType] = strawberry_django.field()
region: RegionType = strawberry_django.field(pagination=True)
region_list: List[RegionType] = strawberry_django.field(pagination=True)
site: SiteType = strawberry_django.field()
site_list: List[SiteType] = strawberry_django.field()
site: SiteType = strawberry_django.field(pagination=True)
site_list: List[SiteType] = strawberry_django.field(pagination=True)
site_group: SiteGroupType = strawberry_django.field()
site_group_list: List[SiteGroupType] = strawberry_django.field()
site_group: SiteGroupType = strawberry_django.field(pagination=True)
site_group_list: List[SiteGroupType] = strawberry_django.field(pagination=True)
virtual_chassis: VirtualChassisType = strawberry_django.field()
virtual_chassis_list: List[VirtualChassisType] = strawberry_django.field()
virtual_chassis: VirtualChassisType = strawberry_django.field(pagination=True)
virtual_chassis_list: List[VirtualChassisType] = strawberry_django.field(pagination=True)
virtual_device_context: VirtualDeviceContextType = strawberry_django.field()
virtual_device_context_list: List[VirtualDeviceContextType] = strawberry_django.field()
virtual_device_context: VirtualDeviceContextType = strawberry_django.field(pagination=True)
virtual_device_context_list: List[VirtualDeviceContextType] = strawberry_django.field(pagination=True)

View File

@ -133,7 +133,9 @@ class ModularComponentTemplateType(ComponentTemplateType):
@strawberry_django.type(
models.CableTermination,
exclude=['termination_type', 'termination_id', '_device', '_rack', '_location', '_site'],
filters=CableTerminationFilter
filters=CableTerminationFilter,
pagination=True
)
class CableTerminationType(NetBoxObjectType):
cable: Annotated["CableType", strawberry.lazy('dcim.graphql.types')] | None
@ -153,7 +155,9 @@ class CableTerminationType(NetBoxObjectType):
@strawberry_django.type(
models.Cable,
fields='__all__',
filters=CableFilter
filters=CableFilter,
pagination=True
)
class CableType(NetBoxObjectType):
color: str
@ -189,7 +193,9 @@ class CableType(NetBoxObjectType):
@strawberry_django.type(
models.ConsolePort,
exclude=['_path'],
filters=ConsolePortFilter
filters=ConsolePortFilter,
pagination=True
)
class ConsolePortType(ModularComponentType, CabledObjectMixin, PathEndpointMixin):
pass
@ -198,7 +204,9 @@ class ConsolePortType(ModularComponentType, CabledObjectMixin, PathEndpointMixin
@strawberry_django.type(
models.ConsolePortTemplate,
fields='__all__',
filters=ConsolePortTemplateFilter
filters=ConsolePortTemplateFilter,
pagination=True
)
class ConsolePortTemplateType(ModularComponentTemplateType):
pass
@ -207,7 +215,9 @@ class ConsolePortTemplateType(ModularComponentTemplateType):
@strawberry_django.type(
models.ConsoleServerPort,
exclude=['_path'],
filters=ConsoleServerPortFilter
filters=ConsoleServerPortFilter,
pagination=True
)
class ConsoleServerPortType(ModularComponentType, CabledObjectMixin, PathEndpointMixin):
pass
@ -216,7 +226,9 @@ class ConsoleServerPortType(ModularComponentType, CabledObjectMixin, PathEndpoin
@strawberry_django.type(
models.ConsoleServerPortTemplate,
fields='__all__',
filters=ConsoleServerPortTemplateFilter
filters=ConsoleServerPortTemplateFilter,
pagination=True
)
class ConsoleServerPortTemplateType(ModularComponentTemplateType):
pass
@ -225,7 +237,9 @@ class ConsoleServerPortTemplateType(ModularComponentTemplateType):
@strawberry_django.type(
models.Device,
fields='__all__',
filters=DeviceFilter
filters=DeviceFilter,
pagination=True
)
class DeviceType(ConfigContextMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
console_port_count: BigInt
@ -280,7 +294,9 @@ class DeviceType(ConfigContextMixin, ImageAttachmentsMixin, ContactsMixin, NetBo
@strawberry_django.type(
models.DeviceBay,
fields='__all__',
filters=DeviceBayFilter
filters=DeviceBayFilter,
pagination=True
)
class DeviceBayType(ComponentType):
installed_device: Annotated["DeviceType", strawberry.lazy('dcim.graphql.types')] | None
@ -289,7 +305,9 @@ class DeviceBayType(ComponentType):
@strawberry_django.type(
models.DeviceBayTemplate,
fields='__all__',
filters=DeviceBayTemplateFilter
filters=DeviceBayTemplateFilter,
pagination=True
)
class DeviceBayTemplateType(ComponentTemplateType):
pass
@ -298,7 +316,9 @@ class DeviceBayTemplateType(ComponentTemplateType):
@strawberry_django.type(
models.InventoryItemTemplate,
exclude=['component_type', 'component_id', 'parent'],
filters=InventoryItemTemplateFilter
filters=InventoryItemTemplateFilter,
pagination=True
)
class InventoryItemTemplateType(ComponentTemplateType):
role: Annotated["InventoryItemRoleType", strawberry.lazy('dcim.graphql.types')] | None
@ -324,7 +344,9 @@ class InventoryItemTemplateType(ComponentTemplateType):
@strawberry_django.type(
models.DeviceRole,
fields='__all__',
filters=DeviceRoleFilter
filters=DeviceRoleFilter,
pagination=True
)
class DeviceRoleType(OrganizationalObjectType):
color: str
@ -337,7 +359,9 @@ class DeviceRoleType(OrganizationalObjectType):
@strawberry_django.type(
models.DeviceType,
fields='__all__',
filters=DeviceTypeFilter
filters=DeviceTypeFilter,
pagination=True
)
class DeviceTypeType(NetBoxObjectType):
console_port_template_count: BigInt
@ -371,7 +395,9 @@ class DeviceTypeType(NetBoxObjectType):
@strawberry_django.type(
models.FrontPort,
fields='__all__',
filters=FrontPortFilter
filters=FrontPortFilter,
pagination=True
)
class FrontPortType(ModularComponentType, CabledObjectMixin):
color: str
@ -381,7 +407,9 @@ class FrontPortType(ModularComponentType, CabledObjectMixin):
@strawberry_django.type(
models.FrontPortTemplate,
fields='__all__',
filters=FrontPortTemplateFilter
filters=FrontPortTemplateFilter,
pagination=True
)
class FrontPortTemplateType(ModularComponentTemplateType):
color: str
@ -391,7 +419,9 @@ class FrontPortTemplateType(ModularComponentTemplateType):
@strawberry_django.type(
models.MACAddress,
exclude=['assigned_object_type', 'assigned_object_id'],
filters=MACAddressFilter
filters=MACAddressFilter,
pagination=True
)
class MACAddressType(NetBoxObjectType):
mac_address: str
@ -407,7 +437,9 @@ class MACAddressType(NetBoxObjectType):
@strawberry_django.type(
models.Interface,
exclude=['_path'],
filters=InterfaceFilter
filters=InterfaceFilter,
pagination=True
)
class InterfaceType(IPAddressesMixin, ModularComponentType, CabledObjectMixin, PathEndpointMixin):
_name: str
@ -434,7 +466,9 @@ class InterfaceType(IPAddressesMixin, ModularComponentType, CabledObjectMixin, P
@strawberry_django.type(
models.InterfaceTemplate,
fields='__all__',
filters=InterfaceTemplateFilter
filters=InterfaceTemplateFilter,
pagination=True
)
class InterfaceTemplateType(ModularComponentTemplateType):
_name: str
@ -446,7 +480,9 @@ class InterfaceTemplateType(ModularComponentTemplateType):
@strawberry_django.type(
models.InventoryItem,
exclude=['component_type', 'component_id', 'parent'],
filters=InventoryItemFilter
filters=InventoryItemFilter,
pagination=True
)
class InventoryItemType(ComponentType):
role: Annotated["InventoryItemRoleType", strawberry.lazy('dcim.graphql.types')] | None
@ -472,7 +508,9 @@ class InventoryItemType(ComponentType):
@strawberry_django.type(
models.InventoryItemRole,
fields='__all__',
filters=InventoryItemRoleFilter
filters=InventoryItemRoleFilter,
pagination=True
)
class InventoryItemRoleType(OrganizationalObjectType):
color: str
@ -485,7 +523,9 @@ class InventoryItemRoleType(OrganizationalObjectType):
models.Location,
# fields='__all__',
exclude=['parent'], # bug - temp
filters=LocationFilter
filters=LocationFilter,
pagination=True
)
class LocationType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, OrganizationalObjectType):
site: Annotated["SiteType", strawberry.lazy('dcim.graphql.types')]
@ -512,7 +552,9 @@ class LocationType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, Organi
@strawberry_django.type(
models.Manufacturer,
fields='__all__',
filters=ManufacturerFilter
filters=ManufacturerFilter,
pagination=True
)
class ManufacturerType(OrganizationalObjectType, ContactsMixin):
@ -526,7 +568,9 @@ class ManufacturerType(OrganizationalObjectType, ContactsMixin):
@strawberry_django.type(
models.Module,
fields='__all__',
filters=ModuleFilter
filters=ModuleFilter,
pagination=True
)
class ModuleType(NetBoxObjectType):
device: Annotated["DeviceType", strawberry.lazy('dcim.graphql.types')]
@ -546,7 +590,9 @@ class ModuleType(NetBoxObjectType):
models.ModuleBay,
# fields='__all__',
exclude=['parent'],
filters=ModuleBayFilter
filters=ModuleBayFilter,
pagination=True
)
class ModuleBayType(ModularComponentType):
@ -561,7 +607,9 @@ class ModuleBayType(ModularComponentType):
@strawberry_django.type(
models.ModuleBayTemplate,
fields='__all__',
filters=ModuleBayTemplateFilter
filters=ModuleBayTemplateFilter,
pagination=True
)
class ModuleBayTemplateType(ModularComponentTemplateType):
pass
@ -570,7 +618,9 @@ class ModuleBayTemplateType(ModularComponentTemplateType):
@strawberry_django.type(
models.ModuleType,
fields='__all__',
filters=ModuleTypeFilter
filters=ModuleTypeFilter,
pagination=True
)
class ModuleTypeType(NetBoxObjectType):
manufacturer: Annotated["ManufacturerType", strawberry.lazy('dcim.graphql.types')]
@ -588,7 +638,9 @@ class ModuleTypeType(NetBoxObjectType):
@strawberry_django.type(
models.Platform,
fields='__all__',
filters=PlatformFilter
filters=PlatformFilter,
pagination=True
)
class PlatformType(OrganizationalObjectType):
manufacturer: Annotated["ManufacturerType", strawberry.lazy('dcim.graphql.types')] | None
@ -601,7 +653,9 @@ class PlatformType(OrganizationalObjectType):
@strawberry_django.type(
models.PowerFeed,
exclude=['_path'],
filters=PowerFeedFilter
filters=PowerFeedFilter,
pagination=True
)
class PowerFeedType(NetBoxObjectType, CabledObjectMixin, PathEndpointMixin):
power_panel: Annotated["PowerPanelType", strawberry.lazy('dcim.graphql.types')]
@ -612,7 +666,9 @@ class PowerFeedType(NetBoxObjectType, CabledObjectMixin, PathEndpointMixin):
@strawberry_django.type(
models.PowerOutlet,
exclude=['_path'],
filters=PowerOutletFilter
filters=PowerOutletFilter,
pagination=True
)
class PowerOutletType(ModularComponentType, CabledObjectMixin, PathEndpointMixin):
power_port: Annotated["PowerPortType", strawberry.lazy('dcim.graphql.types')] | None
@ -622,7 +678,9 @@ class PowerOutletType(ModularComponentType, CabledObjectMixin, PathEndpointMixin
@strawberry_django.type(
models.PowerOutletTemplate,
fields='__all__',
filters=PowerOutletTemplateFilter
filters=PowerOutletTemplateFilter,
pagination=True
)
class PowerOutletTemplateType(ModularComponentTemplateType):
power_port: Annotated["PowerPortTemplateType", strawberry.lazy('dcim.graphql.types')] | None
@ -631,7 +689,9 @@ class PowerOutletTemplateType(ModularComponentTemplateType):
@strawberry_django.type(
models.PowerPanel,
fields='__all__',
filters=PowerPanelFilter
filters=PowerPanelFilter,
pagination=True
)
class PowerPanelType(NetBoxObjectType, ContactsMixin):
site: Annotated["SiteType", strawberry.lazy('dcim.graphql.types')]
@ -643,7 +703,9 @@ class PowerPanelType(NetBoxObjectType, ContactsMixin):
@strawberry_django.type(
models.PowerPort,
exclude=['_path'],
filters=PowerPortFilter
filters=PowerPortFilter,
pagination=True
)
class PowerPortType(ModularComponentType, CabledObjectMixin, PathEndpointMixin):
@ -653,7 +715,9 @@ class PowerPortType(ModularComponentType, CabledObjectMixin, PathEndpointMixin):
@strawberry_django.type(
models.PowerPortTemplate,
fields='__all__',
filters=PowerPortTemplateFilter
filters=PowerPortTemplateFilter,
pagination=True
)
class PowerPortTemplateType(ModularComponentTemplateType):
poweroutlet_templates: List[Annotated["PowerOutletTemplateType", strawberry.lazy('dcim.graphql.types')]]
@ -662,7 +726,9 @@ class PowerPortTemplateType(ModularComponentTemplateType):
@strawberry_django.type(
models.RackType,
fields='__all__',
filters=RackTypeFilter
filters=RackTypeFilter,
pagination=True
)
class RackTypeType(NetBoxObjectType):
manufacturer: Annotated["ManufacturerType", strawberry.lazy('dcim.graphql.types')]
@ -671,7 +737,9 @@ class RackTypeType(NetBoxObjectType):
@strawberry_django.type(
models.Rack,
fields='__all__',
filters=RackFilter
filters=RackFilter,
pagination=True
)
class RackType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
site: Annotated["SiteType", strawberry.lazy('dcim.graphql.types')]
@ -689,7 +757,9 @@ class RackType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObje
@strawberry_django.type(
models.RackReservation,
fields='__all__',
filters=RackReservationFilter
filters=RackReservationFilter,
pagination=True
)
class RackReservationType(NetBoxObjectType):
units: List[int]
@ -701,7 +771,9 @@ class RackReservationType(NetBoxObjectType):
@strawberry_django.type(
models.RackRole,
fields='__all__',
filters=RackRoleFilter
filters=RackRoleFilter,
pagination=True
)
class RackRoleType(OrganizationalObjectType):
color: str
@ -712,7 +784,9 @@ class RackRoleType(OrganizationalObjectType):
@strawberry_django.type(
models.RearPort,
fields='__all__',
filters=RearPortFilter
filters=RearPortFilter,
pagination=True
)
class RearPortType(ModularComponentType, CabledObjectMixin):
color: str
@ -723,7 +797,9 @@ class RearPortType(ModularComponentType, CabledObjectMixin):
@strawberry_django.type(
models.RearPortTemplate,
fields='__all__',
filters=RearPortTemplateFilter
filters=RearPortTemplateFilter,
pagination=True
)
class RearPortTemplateType(ModularComponentTemplateType):
color: str
@ -734,7 +810,9 @@ class RearPortTemplateType(ModularComponentTemplateType):
@strawberry_django.type(
models.Region,
exclude=['parent'],
filters=RegionFilter
filters=RegionFilter,
pagination=True
)
class RegionType(VLANGroupsMixin, ContactsMixin, OrganizationalObjectType):
@ -759,7 +837,9 @@ class RegionType(VLANGroupsMixin, ContactsMixin, OrganizationalObjectType):
@strawberry_django.type(
models.Site,
fields='__all__',
filters=SiteFilter
filters=SiteFilter,
pagination=True
)
class SiteType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObjectType):
time_zone: str | None
@ -793,7 +873,9 @@ class SiteType(VLANGroupsMixin, ImageAttachmentsMixin, ContactsMixin, NetBoxObje
@strawberry_django.type(
models.SiteGroup,
exclude=['parent'], # bug - temp
filters=SiteGroupFilter
filters=SiteGroupFilter,
pagination=True
)
class SiteGroupType(VLANGroupsMixin, ContactsMixin, OrganizationalObjectType):
@ -818,7 +900,9 @@ class SiteGroupType(VLANGroupsMixin, ContactsMixin, OrganizationalObjectType):
@strawberry_django.type(
models.VirtualChassis,
fields='__all__',
filters=VirtualChassisFilter
filters=VirtualChassisFilter,
pagination=True
)
class VirtualChassisType(NetBoxObjectType):
member_count: BigInt
@ -830,7 +914,9 @@ class VirtualChassisType(NetBoxObjectType):
@strawberry_django.type(
models.VirtualDeviceContext,
fields='__all__',
filters=VirtualDeviceContextFilter
filters=VirtualDeviceContextFilter,
pagination=True
)
class VirtualDeviceContextType(NetBoxObjectType):
device: Annotated["DeviceType", strawberry.lazy('dcim.graphql.types')] | None

View File

@ -70,7 +70,9 @@ class BaseIPAddressFamilyType:
@strawberry_django.type(
models.ASN,
fields='__all__',
filters=ASNFilter
filters=ASNFilter,
pagination=True
)
class ASNType(NetBoxObjectType):
asn: BigInt
@ -84,7 +86,9 @@ class ASNType(NetBoxObjectType):
@strawberry_django.type(
models.ASNRange,
fields='__all__',
filters=ASNRangeFilter
filters=ASNRangeFilter,
pagination=True
)
class ASNRangeType(NetBoxObjectType):
start: BigInt
@ -96,7 +100,9 @@ class ASNRangeType(NetBoxObjectType):
@strawberry_django.type(
models.Aggregate,
fields='__all__',
filters=AggregateFilter
filters=AggregateFilter,
pagination=True
)
class AggregateType(NetBoxObjectType, BaseIPAddressFamilyType):
prefix: str
@ -107,7 +113,9 @@ class AggregateType(NetBoxObjectType, BaseIPAddressFamilyType):
@strawberry_django.type(
models.FHRPGroup,
fields='__all__',
filters=FHRPGroupFilter
filters=FHRPGroupFilter,
pagination=True
)
class FHRPGroupType(NetBoxObjectType, IPAddressesMixin):
@ -117,7 +125,9 @@ class FHRPGroupType(NetBoxObjectType, IPAddressesMixin):
@strawberry_django.type(
models.FHRPGroupAssignment,
exclude=['interface_type', 'interface_id'],
filters=FHRPGroupAssignmentFilter
filters=FHRPGroupAssignmentFilter,
pagination=True
)
class FHRPGroupAssignmentType(BaseObjectType):
group: Annotated["FHRPGroupType", strawberry.lazy('ipam.graphql.types')]
@ -133,7 +143,9 @@ class FHRPGroupAssignmentType(BaseObjectType):
@strawberry_django.type(
models.IPAddress,
exclude=['assigned_object_type', 'assigned_object_id', 'address'],
filters=IPAddressFilter
filters=IPAddressFilter,
pagination=True
)
class IPAddressType(NetBoxObjectType, BaseIPAddressFamilyType):
address: str
@ -157,7 +169,9 @@ class IPAddressType(NetBoxObjectType, BaseIPAddressFamilyType):
@strawberry_django.type(
models.IPRange,
fields='__all__',
filters=IPRangeFilter
filters=IPRangeFilter,
pagination=True
)
class IPRangeType(NetBoxObjectType):
start_address: str
@ -170,7 +184,9 @@ class IPRangeType(NetBoxObjectType):
@strawberry_django.type(
models.Prefix,
exclude=['scope_type', 'scope_id', '_location', '_region', '_site', '_site_group'],
filters=PrefixFilter
filters=PrefixFilter,
pagination=True
)
class PrefixType(NetBoxObjectType, BaseIPAddressFamilyType):
prefix: str
@ -192,7 +208,9 @@ class PrefixType(NetBoxObjectType, BaseIPAddressFamilyType):
@strawberry_django.type(
models.RIR,
fields='__all__',
filters=RIRFilter
filters=RIRFilter,
pagination=True
)
class RIRType(OrganizationalObjectType):
@ -204,7 +222,9 @@ class RIRType(OrganizationalObjectType):
@strawberry_django.type(
models.Role,
fields='__all__',
filters=RoleFilter
filters=RoleFilter,
pagination=True
)
class RoleType(OrganizationalObjectType):
@ -216,7 +236,9 @@ class RoleType(OrganizationalObjectType):
@strawberry_django.type(
models.RouteTarget,
fields='__all__',
filters=RouteTargetFilter
filters=RouteTargetFilter,
pagination=True
)
class RouteTargetType(NetBoxObjectType):
tenant: Annotated["TenantType", strawberry.lazy('tenancy.graphql.types')] | None
@ -230,7 +252,9 @@ class RouteTargetType(NetBoxObjectType):
@strawberry_django.type(
models.Service,
fields='__all__',
filters=ServiceFilter
filters=ServiceFilter,
pagination=True
)
class ServiceType(NetBoxObjectType):
ports: List[int]
@ -243,7 +267,9 @@ class ServiceType(NetBoxObjectType):
@strawberry_django.type(
models.ServiceTemplate,
fields='__all__',
filters=ServiceTemplateFilter
filters=ServiceTemplateFilter,
pagination=True
)
class ServiceTemplateType(NetBoxObjectType):
ports: List[int]
@ -252,7 +278,9 @@ class ServiceTemplateType(NetBoxObjectType):
@strawberry_django.type(
models.VLAN,
exclude=['qinq_svlan'],
filters=VLANFilter
filters=VLANFilter,
pagination=True
)
class VLANType(NetBoxObjectType):
site: Annotated["SiteType", strawberry.lazy('ipam.graphql.types')] | None
@ -275,7 +303,9 @@ class VLANType(NetBoxObjectType):
@strawberry_django.type(
models.VLANGroup,
exclude=['scope_type', 'scope_id'],
filters=VLANGroupFilter
filters=VLANGroupFilter,
pagination=True
)
class VLANGroupType(OrganizationalObjectType):
@ -299,7 +329,9 @@ class VLANGroupType(OrganizationalObjectType):
@strawberry_django.type(
models.VLANTranslationPolicy,
fields='__all__',
filters=VLANTranslationPolicyFilter
filters=VLANTranslationPolicyFilter,
pagination=True
)
class VLANTranslationPolicyType(NetBoxObjectType):
rules: List[Annotated["VLANTranslationRuleType", strawberry.lazy('ipam.graphql.types')]]
@ -308,7 +340,9 @@ class VLANTranslationPolicyType(NetBoxObjectType):
@strawberry_django.type(
models.VLANTranslationRule,
fields='__all__',
filters=VLANTranslationRuleFilter
filters=VLANTranslationRuleFilter,
pagination=True
)
class VLANTranslationRuleType(NetBoxObjectType):
policy: Annotated[

View File

@ -788,6 +788,7 @@ LOCALE_PATHS = (
STRAWBERRY_DJANGO = {
"DEFAULT_PK_FIELD_NAME": "id",
"TYPE_DESCRIPTION_FROM_MODEL_DOCSTRING": True,
"PAGINATION_DEFAULT_LIMIT": 11,
}
#