Skip to content

Commit 72cc0fa

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 5922caa commit 72cc0fa

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

netbox_acls/graphql/types.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,13 @@
1515
@strawberry_django.type(
1616
models.AccessList,
1717
fields="__all__",
18-
exclude=["assigned_object_type", "assigned_object_id"],
1918
filters=filters.AccessListFilter,
2019
)
2120
class AccessListType(NetBoxObjectType):
2221
"""
2322
Defines the object type for the django model AccessList.
2423
"""
2524

26-
# Model fields
27-
assigned_object_type: Annotated["ContentTypeType", strawberry.lazy("netbox.graphql.types")]
28-
assigned_object: Annotated[
29-
Union[
30-
Annotated["DeviceType", strawberry.lazy("dcim.graphql.types")],
31-
Annotated["VirtualMachineType", strawberry.lazy("virtualization.graphql.types")],
32-
],
33-
strawberry.union("ACLAssignmentType"),
34-
]
35-
3625
# Related models
3726
aclstandardrules: List[
3827
Annotated[
@@ -46,15 +35,21 @@ class AccessListType(NetBoxObjectType):
4635
strawberry.lazy("netbox_acls.graphql.types"),
4736
]
4837
]
38+
aclassignments: List[
39+
Annotated[
40+
"ACLAssignmentType",
41+
strawberry.lazy("netbox_acls.graphql.types"),
42+
]
43+
]
4944

5045

5146
@strawberry_django.type(
52-
models.ACLInterfaceAssignment,
47+
models.ACLAssignment,
5348
fields="__all__",
5449
exclude=["assigned_object_type", "assigned_object_id"],
55-
filters=filters.ACLInterfaceAssignmentFilter,
50+
filters=filters.ACLAssignmentFilter,
5651
)
57-
class ACLInterfaceAssignmentType(NetBoxObjectType):
52+
class ACLAssignmentType(NetBoxObjectType):
5853
"""
5954
Defines the object type for the django model ACLInterfaceAssignment.
6055
"""
@@ -64,10 +59,13 @@ class ACLInterfaceAssignmentType(NetBoxObjectType):
6459
assigned_object_type: Annotated["ContentTypeType", strawberry.lazy("netbox.graphql.types")]
6560
assigned_object: Annotated[
6661
Union[
62+
Annotated["DeviceType", strawberry.lazy("dcim.graphql.types")],
6763
Annotated["InterfaceType", strawberry.lazy("dcim.graphql.types")],
64+
Annotated["VirtualChassisType", strawberry.lazy("dcim.graphql.types")],
65+
Annotated["VirtualMachineType", strawberry.lazy("virtualization.graphql.types")],
6866
Annotated["VMInterfaceType", strawberry.lazy("virtualization.graphql.types")],
6967
],
70-
strawberry.union("ACLInterfaceAssignedObjectType"),
68+
strawberry.union("ACLAssignedObjectType"),
7169
]
7270

7371

0 commit comments

Comments
 (0)