Skip to content

Commit

Permalink
further graphql fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cruse1977 committed Jun 7, 2024
1 parent dda4127 commit f15248a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions netbox_acls/graphql/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,28 @@
import strawberry_django


from typing import Annotated, List
from typing import Annotated, List, Union
from .filters import *
from .. import models
from netbox.graphql.types import OrganizationalObjectType

@strawberry_django.type(
models.AccessList,
fields='__all__',
filters=AccessListFilter
filters=AccessListFilter,
exclude=('assigned_object_type', 'assigned_object_id')
)

class AccessListType(OrganizationalObjectType):
"""
Defines the object type for the django model AccessList.
"""
assigned_object_type: Annotated["ContentTypeType", strawberry.lazy("netbox.graphql.types")]
assigned_object: Annotated[Union[
Annotated["DeviceType", strawberry.lazy('dcim.graphql.types')],
Annotated["VirtualMachineType", strawberry.lazy('virtualization.graphql.types')],
], strawberry.union("ACLAssignmentType")]


class Meta:
"""
Expand All @@ -33,14 +40,23 @@ def accesslists(self) -> List[Annotated["AccessList", strawberry.lazy('accesslis
@strawberry_django.type(
models.ACLInterfaceAssignment,
fields='__all__',
exclude=('assigned_object_type', 'assigned_object_id'),
filters=ACLInterfaceAssignmentFilter
)
class ACLInterfaceAssignmentType(OrganizationalObjectType):
"""
Defines the object type for the django model AccessList.
"""
access_list: Annotated["AccessListType", strawberry.lazy("netbox_acls.graphql.types")]
assigned_object_type: Annotated["ContentTypeType", strawberry.lazy("netbox.graphql.types")]
assigned_object: Annotated[Union[
Annotated["InterfaceType", strawberry.lazy('dcim.graphql.types')],
Annotated["VMInterfaceType", strawberry.lazy('virtualization.graphql.types')],
], strawberry.union("ACLInterfaceAssignmentType")]




class Meta:
"""
Associates the filterset, fields, and model for the django model ACLInterfaceAssignment.
Expand Down

0 comments on commit f15248a

Please sign in to comment.