13
13
14
14
from netbox_bgp .models import (
15
15
BGPSession , RoutingPolicy , BGPPeerGroup ,
16
- Community , RoutingPolicyRule , PrefixList , PrefixListRule ,
16
+ Community , RoutingPolicyRule , PrefixList ,
17
+ PrefixListRule , CommunityList , CommunityListRule
17
18
)
18
19
19
20
from netbox_bgp .choices import CommunityStatusChoices , SessionStatusChoices
@@ -32,7 +33,7 @@ def to_representation(self, value):
32
33
class RoutingPolicySerializer (NetBoxModelSerializer ):
33
34
class Meta :
34
35
model = RoutingPolicy
35
- fields = ['id' , 'name' , 'description' , 'tags' , 'custom_fields' ]
36
+ fields = ['id' , 'name' , 'description' , 'tags' , 'custom_fields' , 'comments' ]
36
37
37
38
38
39
class NestedRoutingPolicySerializer (WritableNestedSerializer ):
@@ -44,6 +45,20 @@ class Meta:
44
45
validators = []
45
46
46
47
48
+ class NestedPrefixListSerializer (WritableNestedSerializer ):
49
+ url = HyperlinkedIdentityField (view_name = 'plugins:netbox_bgp:prefixlist' )
50
+
51
+ class Meta :
52
+ model = PrefixList
53
+ fields = ['id' , 'url' , 'display' , 'name' ]
54
+
55
+
56
+ class PrefixListSerializer (NetBoxModelSerializer ):
57
+ class Meta :
58
+ model = PrefixList
59
+ fields = ['id' , 'name' , 'display' ,'description' , 'family' , 'tags' , 'custom_fields' , 'comments' ]
60
+
61
+
47
62
class BGPPeerGroupSerializer (NetBoxModelSerializer ):
48
63
import_policies = SerializedPKRelatedField (
49
64
queryset = RoutingPolicy .objects .all (),
@@ -62,7 +77,7 @@ class BGPPeerGroupSerializer(NetBoxModelSerializer):
62
77
63
78
class Meta :
64
79
model = BGPPeerGroup
65
- fields = ['id' , 'display' , 'name' , 'description' , 'import_policies' , 'export_policies' ]
80
+ fields = ['id' , 'display' , 'name' , 'description' , 'import_policies' , 'export_policies' , 'comments' ]
66
81
67
82
68
83
class NestedBGPPeerGroupSerializer (WritableNestedSerializer ):
@@ -84,6 +99,8 @@ class BGPSessionSerializer(NetBoxModelSerializer):
84
99
local_as = NestedASNSerializer (required = True , allow_null = False )
85
100
remote_as = NestedASNSerializer (required = True , allow_null = False )
86
101
peer_group = NestedBGPPeerGroupSerializer (required = False , allow_null = True )
102
+ prefix_list_in = NestedPrefixListSerializer (required = False , allow_null = True )
103
+ prefix_list_out = NestedPrefixListSerializer (required = False , allow_null = True )
87
104
import_policies = SerializedPKRelatedField (
88
105
queryset = RoutingPolicy .objects .all (),
89
106
serializer = NestedRoutingPolicySerializer ,
@@ -106,8 +123,9 @@ class Meta:
106
123
'display' , 'status' , 'site' , 'tenant' ,
107
124
'device' , 'local_address' , 'remote_address' ,
108
125
'local_as' , 'remote_as' , 'peer_group' , 'import_policies' ,
109
- 'export_policies' , 'created' , 'last_updated' ,
110
- 'name' , 'description'
126
+ 'export_policies' , 'prefix_list_in' ,'prefix_list_out' ,
127
+ 'created' , 'last_updated' ,
128
+ 'name' , 'description' , 'comments'
111
129
]
112
130
113
131
@@ -146,7 +164,7 @@ class Meta:
146
164
'id' , 'tags' , 'custom_fields' , 'display' ,
147
165
'status' , 'tenant' , 'created' , 'last_updated' ,
148
166
'description' ,
149
- 'value' , 'site' , 'role'
167
+ 'value' , 'site' , 'role' , 'comments'
150
168
]
151
169
152
170
class NestedCommunitySerializer (WritableNestedSerializer ):
@@ -159,18 +177,31 @@ class Meta:
159
177
]
160
178
161
179
162
- class NestedPrefixListSerializer (WritableNestedSerializer ):
163
- url = HyperlinkedIdentityField (view_name = 'plugins:netbox_bgp:prefixlist' )
180
+ class CommunityListSerializer (NetBoxModelSerializer ):
181
+ class Meta :
182
+ model = CommunityList
183
+ fields = ['id' , 'name' , 'display' ,'description' , 'tags' , 'custom_fields' , 'comments' ]
184
+
185
+
186
+ class NestedCommunityListSerializer (WritableNestedSerializer ):
187
+ url = HyperlinkedIdentityField (view_name = 'plugins:netbox_bgp:communitylist' )
164
188
165
189
class Meta :
166
- model = PrefixList
190
+ model = CommunityList
167
191
fields = ['id' , 'url' , 'display' , 'name' ]
168
192
169
193
170
- class PrefixListSerializer (NetBoxModelSerializer ):
194
+ class CommunityListRuleSerializer (NetBoxModelSerializer ):
195
+ community_list = NestedCommunityListSerializer ()
196
+ community = NestedCommunitySerializer (required = False , allow_null = True )
197
+
171
198
class Meta :
172
- model = PrefixList
173
- fields = ['id' , 'name' , 'display' ,'description' , 'family' , 'tags' , 'custom_fields' ]
199
+ model = CommunityListRule
200
+ fields = [
201
+ 'id' , 'tags' , 'custom_fields' , 'display' ,
202
+ 'community_list' , 'created' , 'last_updated' ,
203
+ 'action' , 'community' , 'comments'
204
+ ]
174
205
175
206
176
207
class RoutingPolicyRuleSerializer (NetBoxModelSerializer ):
@@ -196,7 +227,7 @@ class Meta:
196
227
fields = [
197
228
'id' , 'index' , 'display' ,'action' , 'match_ip_address' ,
198
229
'routing_policy' , 'match_community' , 'match_custom' , 'set_actions' ,
199
- 'match_ipv6_address' , 'description' , 'tags' , 'custom_fields' ,
230
+ 'match_ipv6_address' , 'description' , 'tags' , 'custom_fields' , 'comments'
200
231
]
201
232
202
233
@@ -211,5 +242,5 @@ class Meta:
211
242
'id' , 'tags' , 'custom_fields' , 'display' ,
212
243
'prefix_list' , 'created' , 'last_updated' ,
213
244
'index' , 'action' ,
214
- 'prefix_custom' , 'ge' , 'le' , 'prefix'
245
+ 'prefix_custom' , 'ge' , 'le' , 'prefix' , 'comments'
215
246
]
0 commit comments