Skip to content

Commit 0ffbf3f

Browse files
committed
refactor(graphql): Replace ACLInterfaceAssignment with ACLAssignment
Updates GraphQL types to use the unified `ACLAssignment` model, removing legacy fields and adding support for additional object types like virtual chassis. Enhances alignment with the consolidated model structure for improved maintainability and consistency.
1 parent d7ab05f commit 0ffbf3f

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

netbox_acls/graphql/types.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,21 @@
1212
from . import filters
1313

1414
if TYPE_CHECKING:
15-
from dcim.graphql.types import DeviceType, InterfaceType
15+
from dcim.graphql.types import DeviceType, InterfaceType, VirtualChassisType
1616
from ipam.graphql.types import AggregateType, IPAddressType, IPRangeType, PrefixType
1717
from virtualization.graphql.types import VirtualMachineType, VMInterfaceType
1818

1919

2020
@strawberry_django.type(
2121
models.AccessList,
2222
fields="__all__",
23-
exclude=["assigned_object_type", "assigned_object_id"],
2423
filters=filters.AccessListFilter,
2524
)
2625
class AccessListType(NetBoxObjectType):
2726
"""
2827
Defines the object type for the django model AccessList.
2928
"""
3029

31-
# Model fields
32-
assigned_object_type: Annotated["ContentTypeType", strawberry.lazy("netbox.graphql.types")]
33-
assigned_object: Annotated[
34-
Union[
35-
Annotated["DeviceType", strawberry.lazy("dcim.graphql.types")],
36-
Annotated["VirtualMachineType", strawberry.lazy("virtualization.graphql.types")],
37-
],
38-
strawberry.union("ACLAssignmentType"),
39-
]
40-
4130
# Related models
4231
aclstandardrules: List[
4332
Annotated[
@@ -51,15 +40,21 @@ class AccessListType(NetBoxObjectType):
5140
strawberry.lazy("netbox_acls.graphql.types"),
5241
]
5342
]
43+
aclassignments: List[
44+
Annotated[
45+
"ACLAssignmentType",
46+
strawberry.lazy("netbox_acls.graphql.types"),
47+
]
48+
]
5449

5550

5651
@strawberry_django.type(
57-
models.ACLInterfaceAssignment,
52+
models.ACLAssignment,
5853
fields="__all__",
5954
exclude=["assigned_object_type", "assigned_object_id"],
60-
filters=filters.ACLInterfaceAssignmentFilter,
55+
filters=filters.ACLAssignmentFilter,
6156
)
62-
class ACLInterfaceAssignmentType(NetBoxObjectType):
57+
class ACLAssignmentType(NetBoxObjectType):
6358
"""
6459
Defines the object type for the django model ACLInterfaceAssignment.
6560
"""
@@ -69,10 +64,13 @@ class ACLInterfaceAssignmentType(NetBoxObjectType):
6964
assigned_object_type: Annotated["ContentTypeType", strawberry.lazy("netbox.graphql.types")]
7065
assigned_object: Annotated[
7166
Union[
67+
Annotated["DeviceType", strawberry.lazy("dcim.graphql.types")],
7268
Annotated["InterfaceType", strawberry.lazy("dcim.graphql.types")],
69+
Annotated["VirtualChassisType", strawberry.lazy("dcim.graphql.types")],
70+
Annotated["VirtualMachineType", strawberry.lazy("virtualization.graphql.types")],
7371
Annotated["VMInterfaceType", strawberry.lazy("virtualization.graphql.types")],
7472
],
75-
strawberry.union("ACLInterfaceAssignedObjectType"),
73+
strawberry.union("ACLAssignedObjectType"),
7674
]
7775

7876

0 commit comments

Comments
 (0)