Skip to content

Commit 037dc0c

Browse files
committed
feat(graphql): Add ContentType filters for ACL rules
Introduces ContentType filtering for generic source and destination fields in ACLStandardRule and ACLExtendedRule GraphQL filters. Adds source_type, source_id, destination_type, and destination_id fields to enhance filtering flexibility and alignment with generic models.
1 parent a12c4fa commit 037dc0c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

netbox_acls/graphql/filters/access_list_rules.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
import strawberry
55
import strawberry_django
6+
from core.graphql.filters import ContentTypeFilter
67
from netbox.graphql.filter_mixins import NetBoxModelFilterMixin
78
from strawberry.scalars import ID
89
from strawberry_django import FilterLookup
910

1011
from ... import models
1112

1213
if TYPE_CHECKING:
13-
from ipam.graphql.filters import PrefixFilter
1414
from netbox.graphql.filter_lookups import IntegerArrayLookup, IntegerLookup
1515

1616
from ..enums import (
@@ -39,14 +39,19 @@ class ACLRuleFilterMixin(NetBoxModelFilterMixin):
3939
index: Annotated["IntegerLookup", strawberry.lazy("netbox.graphql.filter_lookups")] | None = (
4040
strawberry_django.filter_field()
4141
)
42-
remark: FilterLookup[str] | None = strawberry_django.filter_field()
4342
description: FilterLookup[str] | None = strawberry_django.filter_field()
4443
action: Annotated["ACLRuleActionEnum", strawberry.lazy("netbox_acls.graphql.enums")] | None = (
4544
strawberry_django.filter_field()
4645
)
47-
source_prefix: Annotated["PrefixFilter", strawberry.lazy("ipam.graphql.filters")] | None = (
46+
47+
# Remark
48+
remark: FilterLookup[str] | None = strawberry_django.filter_field()
49+
50+
# Source
51+
source_type: Annotated["ContentTypeFilter", strawberry.lazy("core.graphql.filters")] | None = (
4852
strawberry_django.filter_field()
4953
)
54+
source_id: ID | None = strawberry_django.filter_field()
5055

5156

5257
@strawberry_django.filter(models.ACLStandardRule, lookups=True)
@@ -64,15 +69,21 @@ class ACLExtendedRuleFilter(ACLRuleFilterMixin):
6469
GraphQL filter definition for the ACLExtendedRule model.
6570
"""
6671

72+
# Source
6773
source_ports: Annotated["IntegerArrayLookup", strawberry.lazy("netbox.graphql.filter_lookups")] | None = (
6874
strawberry_django.filter_field()
6975
)
70-
destination_prefix: Annotated["PrefixFilter", strawberry.lazy("ipam.graphql.filters")] | None = (
76+
77+
# Destination
78+
destination_type: Annotated["ContentTypeFilter", strawberry.lazy("core.graphql.filters")] | None = (
7179
strawberry_django.filter_field()
7280
)
81+
destination_id: ID | None = strawberry_django.filter_field()
7382
destination_ports: Annotated["IntegerArrayLookup", strawberry.lazy("netbox.graphql.filter_lookups")] | None = (
7483
strawberry_django.filter_field()
7584
)
85+
86+
# Protocol
7687
protocol: Annotated["ACLProtocolEnum", strawberry.lazy("netbox_acls.graphql.enums")] | None = (
7788
strawberry_django.filter_field()
7889
)

0 commit comments

Comments
 (0)