18245 graphql

This commit is contained in:
Arthur 2025-03-21 07:32:48 -07:00
parent 7c8862cb1e
commit f362522590
3 changed files with 27 additions and 0 deletions

View File

@ -53,6 +53,7 @@ __all__ = (
'DeviceBayFilter',
'DeviceBayTemplateFilter',
'DeviceRoleFilter',
'DeviceRoleGroupFilter',
'DeviceTypeFilter',
'FrontPortFilter',
'FrontPortTemplateFilter',
@ -309,6 +310,20 @@ class DeviceRoleFilter(OrganizationalModelFilterMixin, RenderConfigFilterMixin):
vm_role: FilterLookup[bool] | None = strawberry_django.filter_field()
@strawberry_django.filter(models.DeviceRoleGroup, lookups=True)
class DeviceRoleGroupFilter(OrganizationalModelFilterMixin):
parent: Annotated['DeviceRoleGroupFilter', strawberry.lazy('dcim.graphql.filters')] | None = (
strawberry_django.filter_field()
)
parent_id: ID | None = strawberry.UNSET
roles: Annotated['DeviceRoleFilter', strawberry.lazy('dcim.graphql.filters')] | None = (
strawberry_django.filter_field()
)
children: Annotated['DeviceRoleGroupFilter', strawberry.lazy('dcim.graphql.filters'), True] | None = (
strawberry_django.filter_field()
)
@strawberry_django.filter(models.DeviceType, lookups=True)
class DeviceTypeFilter(ImageAttachmentFilterMixin, PrimaryModelFilterMixin, WeightFilterMixin):
manufacturer: Annotated['ManufacturerFilter', strawberry.lazy('dcim.graphql.filters')] | None = (

View File

@ -35,6 +35,9 @@ class DCIMQuery:
device_role: DeviceRoleType = strawberry_django.field()
device_role_list: List[DeviceRoleType] = strawberry_django.field()
device_role_group: DeviceRoleGroupType = strawberry_django.field()
device_role_group_list: List[DeviceRoleGroupType] = strawberry_django.field()
device_type: DeviceTypeType = strawberry_django.field()
device_type_list: List[DeviceTypeType] = strawberry_django.field()

View File

@ -46,6 +46,7 @@ __all__ = (
'DeviceBayType',
'DeviceBayTemplateType',
'DeviceRoleType',
'DeviceRoleGroupType',
'DeviceTypeType',
'FrontPortType',
'FrontPortTemplateType',
@ -334,6 +335,14 @@ class DeviceRoleType(OrganizationalObjectType):
devices: List[Annotated["DeviceType", strawberry.lazy('dcim.graphql.types')]]
@strawberry_django.type(models.DeviceRoleGroup, fields='__all__', filters=DeviceRoleGroupFilter)
class DeviceRoleGroupType(OrganizationalObjectType):
parent: Annotated['DeviceRoleGroupType', strawberry.lazy('dcim.graphql.types')] | None
roles: List[DeviceRoleType]
children: List[Annotated['DeviceRoleGroupType', strawberry.lazy('dcim.graphql.types')]]
@strawberry_django.type(
models.DeviceType,
fields='__all__',