1
1
"""
2
- Define the object types and queries availble via the graphql api.
2
+ Define the object types and queries available via the graphql api.
3
3
"""
4
4
5
+ from typing import Annotated , List , Union
6
+
5
7
import strawberry
6
8
import strawberry_django
9
+ from netbox .graphql .types import OrganizationalObjectType
7
10
8
-
9
- from typing import Annotated , List , Union
10
- from .filters import *
11
11
from .. import models
12
- from netbox .graphql .types import OrganizationalObjectType
12
+ from . import filters
13
+
13
14
14
15
@strawberry_django .type (
15
16
models .AccessList ,
16
- fields = ' __all__' ,
17
- filters = AccessListFilter ,
18
- exclude = ( 'assigned_object_type' , 'assigned_object_id' )
17
+ fields = " __all__" ,
18
+ exclude = [ "assigned_object_type" , "assigned_object_id" ] ,
19
+ filters = filters . AccessListFilter ,
19
20
)
20
-
21
21
class AccessListType (OrganizationalObjectType ):
22
22
"""
23
23
Defines the object type for the django model AccessList.
24
24
"""
25
- assigned_object_type : Annotated ["ContentTypeType" , strawberry .lazy ("netbox.graphql.types" )]
26
- assigned_object : Annotated [Union [
27
- Annotated ["DeviceType" , strawberry .lazy ('dcim.graphql.types' )],
28
- Annotated ["VirtualMachineType" , strawberry .lazy ('virtualization.graphql.types' )],
29
- ], strawberry .union ("ACLAssignmentType" )]
30
25
26
+ assigned_object_type : Annotated ["ContentTypeType" , strawberry .lazy ("netbox.graphql.types" )]
27
+ assigned_object : Annotated [
28
+ Union [
29
+ Annotated ["DeviceType" , strawberry .lazy ("dcim.graphql.types" )],
30
+ Annotated ["VirtualMachineType" , strawberry .lazy ("virtualization.graphql.types" )],
31
+ ],
32
+ strawberry .union ("ACLAssignmentType" ),
33
+ ]
31
34
32
35
class Meta :
33
36
"""
34
37
Associates the filterset, fields, and model for the django model AccessList.
35
38
"""
39
+
36
40
@strawberry_django .field
37
- def accesslists (self ) -> List [Annotated ["AccessList" , strawberry .lazy (' accesslists.graphql.types' )]]:
41
+ def accesslists (self ) -> List [Annotated ["AccessList" , strawberry .lazy (" accesslists.graphql.types" )]]:
38
42
return self .accesslists .all ()
39
-
43
+
44
+
40
45
@strawberry_django .type (
41
46
models .ACLInterfaceAssignment ,
42
- fields = ' __all__' ,
43
- exclude = ( ' assigned_object_type' , ' assigned_object_id' ) ,
44
- filters = ACLInterfaceAssignmentFilter
47
+ fields = " __all__" ,
48
+ exclude = [ " assigned_object_type" , " assigned_object_id" ] ,
49
+ filters = filters . ACLInterfaceAssignmentFilter ,
45
50
)
46
51
class ACLInterfaceAssignmentType (OrganizationalObjectType ):
47
52
"""
48
53
Defines the object type for the django model AccessList.
49
54
"""
55
+
50
56
access_list : Annotated ["AccessListType" , strawberry .lazy ("netbox_acls.graphql.types" )]
51
57
assigned_object_type : Annotated ["ContentTypeType" , strawberry .lazy ("netbox.graphql.types" )]
52
- assigned_object : Annotated [Union [
53
- Annotated [ "InterfaceType" , strawberry . lazy ( 'dcim.graphql.types' )],
54
- Annotated ["VMInterfaceType " , strawberry .lazy ('virtualization .graphql.types' )],
55
- ] , strawberry .union ( "ACLInterfaceAssignmentType " )]
56
-
57
-
58
-
58
+ assigned_object : Annotated [
59
+ Union [
60
+ Annotated ["InterfaceType " , strawberry .lazy ("dcim .graphql.types" )],
61
+ Annotated [ "VMInterfaceType" , strawberry .lazy ( "virtualization.graphql.types " )],
62
+ ],
63
+ strawberry . union ( "ACLInterfaceAssignmentType" ),
64
+ ]
59
65
60
66
class Meta :
61
67
"""
62
68
Associates the filterset, fields, and model for the django model ACLInterfaceAssignment.
63
69
"""
70
+
64
71
@strawberry_django .field
65
- def aclinterfaceassignments (self ) -> List [Annotated ["ACLInterfaceAssignment" , strawberry .lazy ('aclinterfaceassignments.graphql.types' )]]:
72
+ def aclinterfaceassignments (
73
+ self ,
74
+ ) -> List [Annotated ["ACLInterfaceAssignment" , strawberry .lazy ("aclinterfaceassignments.graphql.types" )]]:
66
75
return self .aclinterfaceassignments .all ()
67
76
77
+
68
78
@strawberry_django .type (
69
79
models .ACLExtendedRule ,
70
- fields = ' __all__' ,
71
- filters = ACLExtendedRuleFilter
80
+ fields = " __all__" ,
81
+ filters = filters . ACLExtendedRuleFilter ,
72
82
)
73
-
74
83
class ACLExtendedRuleType (OrganizationalObjectType ):
75
84
"""
76
85
Defines the object type for the django model ACLExtendedRule.
77
86
"""
87
+
78
88
source_ports : List [int ]
79
89
destination_ports : List [int ]
80
90
access_list : Annotated ["AccessListType" , strawberry .lazy ("netbox_acls.graphql.types" )]
@@ -85,29 +95,34 @@ class Meta:
85
95
"""
86
96
Associates the filterset, fields, and model for the django model ACLExtendedRule.
87
97
"""
98
+
88
99
@strawberry_django .field
89
- def aclextendedrules (self ) -> List [Annotated ["ACLExtendedRule" , strawberry .lazy ('aclextendedrule.graphql.types' )]]:
100
+ def aclextendedrules (
101
+ self ,
102
+ ) -> List [Annotated ["ACLExtendedRule" , strawberry .lazy ("aclextendedrule.graphql.types" )]]:
90
103
return self .aclextendedrules .all ()
91
104
92
105
93
106
@strawberry_django .type (
94
107
models .ACLStandardRule ,
95
- fields = ' __all__' ,
96
- filters = ACLStandardRuleFilter
108
+ fields = " __all__" ,
109
+ filters = filters . ACLStandardRuleFilter ,
97
110
)
98
-
99
111
class ACLStandardRuleType (OrganizationalObjectType ):
100
112
"""
101
113
Defines the object type for the django model ACLStandardRule.
102
114
"""
115
+
103
116
access_list : Annotated ["AccessListType" , strawberry .lazy ("netbox_acls.graphql.types" )]
104
117
source_prefix : Annotated ["PrefixType" , strawberry .lazy ("ipam.graphql.types" )]
105
118
106
119
class Meta :
107
120
"""
108
121
Associates the filterset, fields, and model for the django model ACLExtendedRule.
109
122
"""
123
+
110
124
@strawberry_django .field
111
- def aclstandardrules (self ) -> List [Annotated ["ACLStandardRule" , strawberry .lazy ('aclstandardrule.graphql.types' )]]:
125
+ def aclstandardrules (
126
+ self ,
127
+ ) -> List [Annotated ["ACLStandardRule" , strawberry .lazy ("aclstandardrule.graphql.types" )]]:
112
128
return self .aclstandardrules .all ()
113
-
0 commit comments