Skip to content

Commit 9381564

Browse files
rinna11Rinna Izumijnovinger
authored
Fixes #20422: Allow Aggregate and Prefix to filter by family in GraphQL (#20626)
Co-authored-by: Rinna Izumi <[email protected]> Co-authored-by: Jason Novinger <[email protected]>
1 parent 3d143d6 commit 9381564

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

netbox/ipam/graphql/filters.py

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

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

105113
@strawberry_django.filter_type(models.FHRPGroup, lookups=True)
106114
class FHRPGroupFilter(PrimaryModelFilterMixin):
@@ -292,6 +300,14 @@ def contains(self, value: list[str], prefix) -> Q:
292300
q |= Q(**{f"{prefix}prefix__net_contains": query})
293301
return q
294302

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

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

0 commit comments

Comments
 (0)