Skip to content

Commit 71581e8

Browse files
author
Rinna Izumi
committed
Fixes #20422: Allow AggregateFilter and PrefixFilter to filter by family in GraphQL
1 parent 56d9146 commit 71581e8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

netbox/ipam/graphql/filters.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ def contains(self, value: list[str], prefix) -> Q:
101101
q |= Q(**{f"{prefix}prefix__net_contains": query})
102102
return q
103103

104+
def family(
105+
self,
106+
value: Annotated['IPAddressFamilyEnum', strawberry.lazy('ipam.graphql.enums')],
107+
prefix,
108+
) -> Q:
109+
return Q(**{f"{prefix}prefix__family": value.value})
110+
104111

105112
@strawberry_django.filter_type(models.FHRPGroup, lookups=True)
106113
class FHRPGroupFilter(PrimaryModelFilterMixin):
@@ -292,6 +299,14 @@ def contains(self, value: list[str], prefix) -> Q:
292299
q |= Q(**{f"{prefix}prefix__net_contains": query})
293300
return q
294301

302+
@strawberry_django.filter_field()
303+
def family(
304+
self,
305+
value: Annotated['IPAddressFamilyEnum', strawberry.lazy('ipam.graphql.enums')],
306+
prefix,
307+
) -> Q:
308+
return Q(**{f"{prefix}prefix__family": value.value})
309+
295310

296311
@strawberry_django.filter_type(models.RIR, lookups=True)
297312
class RIRFilter(OrganizationalModelFilterMixin):

0 commit comments

Comments
 (0)