-
Notifications
You must be signed in to change notification settings - Fork 21
/
serializers.py
335 lines (284 loc) · 11.4 KB
/
serializers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
from rest_framework import serializers
from .models import ASN, Country, Delay, Forwarding, Delay_alarms, Forwarding_alarms, Disco_events, Disco_probes, Hegemony, HegemonyCone, Atlas_location, Atlas_delay, Atlas_delay_alarms, Hegemony_alarms, Hegemony_country, Hegemony_prefix, Metis_atlas_selection, Metis_atlas_deployment, TR_hegemony
class UserRegisterSerializer(serializers.Serializer):
email = serializers.EmailField(required=True)
password = serializers.CharField(required=True)
code = serializers.CharField(required=True)
def validate(self, data):
return data
class UserSerializer(serializers.Serializer):
email = serializers.EmailField(required=True)
password = serializers.CharField(required=True)
def validate(self, data):
return data
class UserEmailSerializer(serializers.Serializer):
email = serializers.EmailField(required=True)
def validate(self, data):
return data
class UserLoginSerializer(serializers.Serializer):
email = serializers.EmailField(required=True)
password = serializers.CharField(required=True)
def validate(self, data):
return data
class UserChangePasswordSerializer(serializers.Serializer):
email = serializers.EmailField(required=True)
password = serializers.CharField(required=True)
new_password = serializers.CharField(required=True)
def validate(self, data):
return data
class UserForgetPasswordSerializer(serializers.Serializer):
email = serializers.EmailField(required=True)
new_password = serializers.CharField(required=True)
code = serializers.CharField(required=True)
def validate(self, data):
return data
class DelaySerializer(serializers.ModelSerializer):
queryset = Delay.objects.select_related("asn")
asn_name = serializers.PrimaryKeyRelatedField(
queryset=queryset, source='asn.name',
help_text="Name of the Autonomous System corresponding to the reported IP address.")
magnitude = serializers.FloatField(help_text="Amplitude of the delay change")
class Meta:
model = Delay
fields = ('asn', 'timebin', 'magnitude', 'asn_name')
class DelayAlarmsSerializer(serializers.ModelSerializer):
queryset = Delay_alarms.objects.prefetch_related('msmid', "asn").all()
msmid = serializers.StringRelatedField(many=True)
asn_name = serializers.PrimaryKeyRelatedField(
queryset=queryset, source='asn.name',
help_text="Name of the Autonomous System corresponding to the reported IP address.")
class Meta:
model = Delay_alarms
fields = ('asn',
'asn_name',
'timebin',
'link',
'medianrtt',
'diffmedian',
'deviation',
'nbprobes',
'msm_prb_ids',
'msmid')
class ForwardingSerializer(serializers.ModelSerializer):
queryset = Forwarding.objects.select_related("asn")
asn_name = serializers.PrimaryKeyRelatedField(
queryset=queryset, source='asn.name',
help_text="Name of the Autonomous System corresponding to the reported IP address.")
class Meta:
model = Forwarding
fields = ('asn', 'timebin', 'magnitude', 'asn_name')
class ForwardingAlarmsSerializer(serializers.ModelSerializer):
queryset = Forwarding_alarms.objects.prefetch_related('msmid', 'asn').all()
msmid = serializers.StringRelatedField(many=True)
asn_name = serializers.PrimaryKeyRelatedField(
queryset=queryset, source='asn.name',
help_text="Name of the Autonomous System corresponding to the reported IP address.")
class Meta:
model = Forwarding_alarms
fields = ('asn',
'asn_name',
'timebin',
'ip',
'correlation',
'pktdiff',
'previoushop',
'responsibility',
'msm_prb_ids',
'msmid')
class DiscoProbesSerializer(serializers.ModelSerializer):
class Meta:
model = Disco_probes
fields = ('probe_id',
'ipv4',
'prefixv4',
'event',
'starttime',
'endtime',
'level',
'lat',
'lon')
class DiscoEventsSerializer(serializers.ModelSerializer):
discoprobes = DiscoProbesSerializer(many=True, read_only=True)
class Meta:
model = Disco_events
fields = ('id',
'streamtype',
'streamname',
'starttime',
'endtime',
'avglevel',
'nbdiscoprobes',
'totalprobes',
'ongoing',
'discoprobes')
class HegemonySerializer(serializers.ModelSerializer):
asn_name = serializers.CharField(source='asn.name',
help_text="Autonomous System name of the dependency.")
originasn_name = serializers.CharField(
source='originasn.name', help_text="Autonomous System name of the dependent network.")
class Meta:
model = Hegemony
fields = ('timebin',
'originasn',
'asn',
'hege',
'af',
'asn_name',
'originasn_name')
class HegemonyAlarmsSerializer(serializers.ModelSerializer):
queryset = Hegemony_alarms.objects.prefetch_related("asn","originasn").all()
asn_name = serializers.CharField(source='asn.name',
help_text="Autonomous System name of the reported dependency.")
originasn_name = serializers.CharField(source='originasn.name',
help_text="Autonomous System name of the reported dependent network.")
class Meta:
model = Hegemony_alarms
fields = ('timebin',
'originasn',
'asn',
'deviation',
'af',
'asn_name',
'originasn_name')
class HegemonyConeSerializer(serializers.ModelSerializer):
class Meta:
model = HegemonyCone
fields = ('timebin', 'asn', 'conesize', 'af')
class HegemonyCountrySerializer(serializers.ModelSerializer):
asn_name = serializers.CharField(source='asn.name',
help_text="Autonomous System name of the dependency.")
class Meta:
model = Hegemony_country
fields = ('timebin',
'country',
'asn',
'hege',
'af',
'asn_name',
'weight',
'weightscheme',
'transitonly')
class HegemonyPrefixSerializer(serializers.ModelSerializer):
originasn_name = serializers.CharField(source='originasn.name',
help_text="Autonomous System name of the ASN originating the prefix.")
asn_name = serializers.CharField(source='asn.name',
help_text="Autonomous System name of the dependency.")
class Meta:
model = Hegemony_prefix
fields = ('timebin',
'prefix',
'originasn',
'country',
'asn',
'hege',
'af',
'visibility',
'rpki_status',
'irr_status',
'delegated_prefix_status',
'delegated_asn_status',
'descr',
'moas',
'originasn_name',
'asn_name')
class NetworkDelaySerializer(serializers.ModelSerializer):
startpoint_type = serializers.CharField(source='startpoint.type')
startpoint_name = serializers.CharField(source='startpoint.name')
startpoint_af = serializers.IntegerField(source='startpoint.af')
endpoint_type = serializers.CharField(source='endpoint.type')
endpoint_name = serializers.CharField(source='endpoint.name')
endpoint_af = serializers.IntegerField(source='endpoint.af')
class Meta:
model = Atlas_delay
fields = ('timebin',
'startpoint_type',
'startpoint_name',
'startpoint_af',
'endpoint_type',
'endpoint_name',
'endpoint_af',
'median',
'nbtracks',
'nbprobes',
'entropy',
'hop',
'nbrealrtts')
class NetworkDelayLocationsSerializer(serializers.ModelSerializer):
class Meta:
model = Atlas_location
fields = ('type', 'name', 'af')
class ASNSerializer(serializers.ModelSerializer):
hegemony = serializers.BooleanField(source='ashash',
help_text='True if participate in AS dependency analysis.')
delay_forwarding = serializers.BooleanField(source='tartiflette',
help_text='True if participate in link delay and forwarding anomaly analysis.')
class Meta:
model = ASN
fields = ('number',
'name',
'hegemony',
'delay_forwarding',
'disco')
class CountrySerializer(serializers.ModelSerializer):
class Meta:
model = Country
fields = ('code', 'name')
class NetworkDelayAlarmsSerializer(serializers.ModelSerializer):
startpoint_type = serializers.CharField(source='startpoint.type')
startpoint_name = serializers.CharField(source='startpoint.name')
startpoint_af = serializers.IntegerField(source='startpoint.af')
endpoint_type = serializers.CharField(source='endpoint.type')
endpoint_name = serializers.CharField(source='endpoint.name')
endpoint_af = serializers.IntegerField(source='endpoint.af')
class Meta:
model = Atlas_delay_alarms
fields = ('timebin',
'startpoint_type',
'startpoint_name',
'startpoint_af',
'endpoint_type',
'endpoint_name',
'endpoint_af',
'deviation')
class MetisAtlasSelectionSerializer(serializers.ModelSerializer):
asn_name = serializers.CharField(source='asn.name',
help_text="Autonomous System name.")
class Meta:
model = Metis_atlas_selection
fields = ('timebin',
'metric',
'rank',
'asn',
'af',
'asn_name')
class MetisAtlasDeploymentSerializer(serializers.ModelSerializer):
asn_name = serializers.CharField(source='asn.name',
help_text="Autonomous System name.")
class Meta:
model = Metis_atlas_deployment
fields = ('timebin',
'metric',
'rank',
'asn',
'af',
'nbsamples',
'asn_name')
class TRHegemonySerializer(serializers.ModelSerializer):
origin_type = serializers.CharField(source='origin.type')
origin_name = serializers.CharField(source='origin.name')
origin_af = serializers.IntegerField(source='origin.af')
dependency_type = serializers.CharField(source='dependency.type')
dependency_name = serializers.CharField(source='dependency.name')
dependency_af = serializers.IntegerField(source='dependency.af')
class Meta:
model = TR_hegemony
fields = ('timebin',
'origin_type',
'origin_name',
'origin_af',
'dependency_type',
'dependency_name',
'dependency_af',
'hege',
'af',
'nbsamples')