dsw-models 4.25.0__py2.py3-none-any.whl → 4.26.0__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
dsw/models/km/events.py DELETED
@@ -1,2424 +0,0 @@
1
- # pylint: disable=too-many-arguments, too-many-locals, too-many-lines
2
- import abc
3
- import typing
4
-
5
- # https://github.com/ds-wizard/engine-backend/blob/develop/engine-shared/src/Shared/Model/Event/
6
-
7
- T = typing.TypeVar('T')
8
-
9
-
10
- class MetricMeasure:
11
-
12
- def __init__(self, *, metric_uuid: str, measure: float, weight: float):
13
- self.metric_uuid = metric_uuid
14
- self.measure = measure
15
- self.weight = weight
16
-
17
- def to_dict(self) -> dict:
18
- return {
19
- 'metricUuid': self.metric_uuid,
20
- 'measure': self.measure,
21
- 'weight': self.weight,
22
- }
23
-
24
- @staticmethod
25
- def from_dict(data: dict) -> 'MetricMeasure':
26
- return MetricMeasure(
27
- metric_uuid=data['metricUuid'],
28
- measure=data['measure'],
29
- weight=data['weight'],
30
- )
31
-
32
-
33
- class EventField(typing.Generic[T]):
34
-
35
- def __init__(self, *, changed: bool, value: T | None):
36
- self.changed = changed
37
- self.value = value
38
-
39
- def to_dict(self) -> dict:
40
- if not self.changed:
41
- return {
42
- 'changed': False,
43
- }
44
- return {
45
- 'changed': True,
46
- 'value': self.value,
47
- }
48
-
49
- @staticmethod
50
- def from_dict(data: dict, loader=None) -> 'EventField':
51
- value = data.get('value', None)
52
- if loader is not None and value is not None:
53
- value = loader(value)
54
- return EventField(
55
- changed=data['changed'],
56
- value=value,
57
- )
58
-
59
-
60
- class MapEntry:
61
-
62
- def __init__(self, *, key: str, value: str):
63
- self.key = key
64
- self.value = value
65
-
66
- def to_dict(self) -> dict:
67
- value = self.value
68
- if hasattr(value, 'to_json'):
69
- value = value.to_json()
70
- return {
71
- 'key': self.key,
72
- 'value': value,
73
- }
74
-
75
- @staticmethod
76
- def from_dict(data: dict) -> 'MapEntry':
77
- return MapEntry(
78
- key=data['key'],
79
- value=data['value'],
80
- )
81
-
82
-
83
- class _KMEvent(abc.ABC):
84
- TYPE = 'UNKNOWN'
85
- METAMODEL_VERSION = 14
86
-
87
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
88
- created_at: str):
89
- self.event_uuid = event_uuid
90
- self.entity_uuid = entity_uuid
91
- self.parent_uuid = parent_uuid
92
- self.created_at = created_at
93
-
94
- def to_dict(self) -> dict:
95
- return {
96
- 'uuid': self.event_uuid,
97
- 'parentUuid': self.parent_uuid,
98
- 'entityUuid': self.entity_uuid,
99
- 'createdAt': self.created_at,
100
- }
101
-
102
- @classmethod
103
- @abc.abstractmethod
104
- def from_dict(cls, data: dict):
105
- pass
106
-
107
-
108
- class _KMAddEvent(_KMEvent, abc.ABC):
109
- TYPE = 'ADD'
110
-
111
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
112
- created_at: str, annotations: list[MapEntry]):
113
- super().__init__(
114
- event_uuid=event_uuid,
115
- entity_uuid=entity_uuid,
116
- parent_uuid=parent_uuid,
117
- created_at=created_at,
118
- )
119
- self.annotations = annotations
120
-
121
- def to_dict(self) -> dict:
122
- result = super().to_dict()
123
- result.update({
124
- 'annotations': self.annotations,
125
- })
126
- return result
127
-
128
-
129
- class _KMEditEvent(_KMEvent, abc.ABC):
130
- TYPE = 'EDIT'
131
-
132
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
133
- created_at: str, annotations: EventField[list[MapEntry]]):
134
- super().__init__(
135
- event_uuid=event_uuid,
136
- entity_uuid=entity_uuid,
137
- parent_uuid=parent_uuid,
138
- created_at=created_at,
139
- )
140
- self.annotations = annotations
141
-
142
- def to_dict(self) -> dict:
143
- result = super().to_dict()
144
- result.update({
145
- 'annotations': self.annotations.to_dict(),
146
- })
147
- return result
148
-
149
-
150
- class _KMDeleteEvent(_KMEvent, abc.ABC):
151
- TYPE = 'DELETE'
152
-
153
-
154
- class _KMMoveEvent(_KMEvent, abc.ABC):
155
- TYPE = 'MOVE'
156
-
157
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
158
- created_at: str, target_uuid: str):
159
- super().__init__(
160
- event_uuid=event_uuid,
161
- entity_uuid=entity_uuid,
162
- parent_uuid=parent_uuid,
163
- created_at=created_at,
164
- )
165
- self.target_uuid = target_uuid
166
-
167
- def to_dict(self) -> dict:
168
- result = super().to_dict()
169
- result.update({
170
- 'targetUuid': self.target_uuid,
171
- })
172
- return result
173
-
174
-
175
- EVENT_TYPES: dict[str, typing.Any] = {}
176
-
177
-
178
- def event_class(cls):
179
- EVENT_TYPES[cls.__name__] = cls
180
- return cls
181
-
182
-
183
- @event_class
184
- class AddKnowledgeModelEvent(_KMAddEvent):
185
-
186
- def to_dict(self) -> dict:
187
- result = super().to_dict()
188
- result.update({
189
- 'eventType': type(self).__name__,
190
- })
191
- return result
192
-
193
- @classmethod
194
- def from_dict(cls, data: dict) -> 'AddKnowledgeModelEvent':
195
- if data['eventType'] != cls.__name__:
196
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
197
- return AddKnowledgeModelEvent(
198
- event_uuid=data['uuid'],
199
- entity_uuid=data['entityUuid'],
200
- parent_uuid=data['parentUuid'],
201
- created_at=data['createdAt'],
202
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
203
- )
204
-
205
-
206
- @event_class
207
- class EditKnowledgeModelEvent(_KMEditEvent):
208
-
209
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
210
- created_at: str, annotations: EventField[list[MapEntry]],
211
- chapter_uuids: EventField[list[str]], tag_uuids: EventField[list[str]],
212
- integration_uuids: EventField[list[str]], metric_uuids: EventField[list[str]],
213
- phase_uuids: EventField[list[str]]):
214
- super().__init__(
215
- event_uuid=event_uuid,
216
- entity_uuid=entity_uuid,
217
- parent_uuid=parent_uuid,
218
- created_at=created_at,
219
- annotations=annotations,
220
- )
221
- self.chapter_uuids = chapter_uuids
222
- self.tag_uuids = tag_uuids
223
- self.integration_uuids = integration_uuids
224
- self.metric_uuids = metric_uuids
225
- self.phase_uuids = phase_uuids
226
-
227
- def to_dict(self) -> dict:
228
- result = super().to_dict()
229
- result.update({
230
- 'eventType': type(self).__name__,
231
- 'chapterUuids': self.chapter_uuids.to_dict(),
232
- 'tagUuids': self.tag_uuids.to_dict(),
233
- 'integrationUuids': self.integration_uuids.to_dict(),
234
- 'metricUuids': self.metric_uuids.to_dict(),
235
- 'phaseUuids': self.phase_uuids.to_dict(),
236
- })
237
- return result
238
-
239
- @classmethod
240
- def from_dict(cls, data: dict) -> 'EditKnowledgeModelEvent':
241
- if data['eventType'] != cls.__name__:
242
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
243
- return EditKnowledgeModelEvent(
244
- event_uuid=data['uuid'],
245
- entity_uuid=data['entityUuid'],
246
- parent_uuid=data['parentUuid'],
247
- created_at=data['createdAt'],
248
- annotations=EventField.from_dict(
249
- data=data['annotations'],
250
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
251
- ),
252
- chapter_uuids=EventField.from_dict(data['chapterUuids']),
253
- tag_uuids=EventField.from_dict(data['tagUuids']),
254
- integration_uuids=EventField.from_dict(data['integrationUuids']),
255
- metric_uuids=EventField.from_dict(data['metricUuids']),
256
- phase_uuids=EventField.from_dict(data['phaseUuids']),
257
- )
258
-
259
-
260
- @event_class
261
- class AddChapterEvent(_KMAddEvent):
262
-
263
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
264
- created_at: str, annotations: list[MapEntry],
265
- title: str, text: str | None):
266
- super().__init__(
267
- event_uuid=event_uuid,
268
- entity_uuid=entity_uuid,
269
- parent_uuid=parent_uuid,
270
- created_at=created_at,
271
- annotations=annotations,
272
- )
273
- self.title = title
274
- self.text = text
275
-
276
- def to_dict(self) -> dict:
277
- result = super().to_dict()
278
- result.update({
279
- 'eventType': type(self).__name__,
280
- 'title': self.title,
281
- 'text': self.text,
282
- })
283
- return result
284
-
285
- @classmethod
286
- def from_dict(cls, data: dict) -> 'AddChapterEvent':
287
- if data['eventType'] != cls.__name__:
288
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
289
- return AddChapterEvent(
290
- event_uuid=data['uuid'],
291
- entity_uuid=data['entityUuid'],
292
- parent_uuid=data['parentUuid'],
293
- created_at=data['createdAt'],
294
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
295
- title=data['title'],
296
- text=data['text'],
297
- )
298
-
299
-
300
- @event_class
301
- class EditChapterEvent(_KMEditEvent):
302
-
303
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
304
- created_at: str, annotations: EventField[list[MapEntry]],
305
- title: EventField[str], text: EventField[str | None],
306
- question_uuids: EventField[list[str]]):
307
- super().__init__(
308
- event_uuid=event_uuid,
309
- entity_uuid=entity_uuid,
310
- parent_uuid=parent_uuid,
311
- created_at=created_at,
312
- annotations=annotations,
313
- )
314
- self.title = title
315
- self.text = text
316
- self.question_uuids = question_uuids
317
-
318
- def to_dict(self) -> dict:
319
- result = super().to_dict()
320
- result.update({
321
- 'eventType': type(self).__name__,
322
- 'title': self.title.to_dict(),
323
- 'text': self.text.to_dict(),
324
- 'questionUuids': self.question_uuids.to_dict(),
325
- })
326
- return result
327
-
328
- @classmethod
329
- def from_dict(cls, data: dict) -> 'EditChapterEvent':
330
- if data['eventType'] != cls.__name__:
331
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
332
- return EditChapterEvent(
333
- event_uuid=data['uuid'],
334
- entity_uuid=data['entityUuid'],
335
- parent_uuid=data['parentUuid'],
336
- created_at=data['createdAt'],
337
- annotations=EventField.from_dict(
338
- data=data['annotations'],
339
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
340
- ),
341
- title=EventField.from_dict(data['title']),
342
- text=EventField.from_dict(data['text']),
343
- question_uuids=EventField.from_dict(data['questionUuids']),
344
- )
345
-
346
-
347
- @event_class
348
- class DeleteChapterEvent(_KMDeleteEvent):
349
-
350
- def to_dict(self) -> dict:
351
- result = super().to_dict()
352
- result.update({
353
- 'eventType': type(self).__name__,
354
- })
355
- return result
356
-
357
- @classmethod
358
- def from_dict(cls, data: dict) -> 'DeleteChapterEvent':
359
- if data['eventType'] != cls.__name__:
360
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
361
- return DeleteChapterEvent(
362
- event_uuid=data['uuid'],
363
- entity_uuid=data['entityUuid'],
364
- parent_uuid=data['parentUuid'],
365
- created_at=data['createdAt'],
366
- )
367
-
368
-
369
- @event_class
370
- class AddQuestionEvent(_KMAddEvent, abc.ABC):
371
-
372
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
373
- created_at: str, annotations: list[MapEntry],
374
- title: str, text: str | None, required_phase_uuid: str | None,
375
- tag_uuids: list[str]):
376
- super().__init__(
377
- event_uuid=event_uuid,
378
- entity_uuid=entity_uuid,
379
- parent_uuid=parent_uuid,
380
- created_at=created_at,
381
- annotations=annotations,
382
- )
383
- self.title = title
384
- self.text = text
385
- self.required_phase_uuid = required_phase_uuid
386
- self.tag_uuids = tag_uuids
387
-
388
- def to_dict(self) -> dict:
389
- result = super().to_dict()
390
- result.update({
391
- 'eventType': 'AddQuestionEvent',
392
- 'title': self.title,
393
- 'text': self.text,
394
- 'requiredPhaseUuid': self.required_phase_uuid,
395
- 'tagUuids': self.tag_uuids,
396
- })
397
- return result
398
-
399
- @classmethod
400
- def from_dict(cls, data: dict) -> 'AddQuestionEvent':
401
- if data['eventType'] != cls.__name__:
402
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
403
- question_type = data['questionType']
404
- if question_type == 'OptionsQuestion':
405
- return AddOptionsQuestionEvent.from_dict(data)
406
- if question_type == 'ListQuestion':
407
- return AddListQuestionEvent.from_dict(data)
408
- if question_type == 'ValueQuestion':
409
- return AddValueQuestionEvent.from_dict(data)
410
- if question_type == 'IntegrationQuestion':
411
- return AddIntegrationQuestionEvent.from_dict(data)
412
- if question_type == 'MultiChoiceQuestion':
413
- return AddMultiChoiceQuestionEvent.from_dict(data)
414
- raise ValueError(f'Unknown question type "{question_type}"')
415
-
416
-
417
- class AddOptionsQuestionEvent(AddQuestionEvent):
418
-
419
- def to_dict(self) -> dict:
420
- result = super().to_dict()
421
- result.update({
422
- 'questionType': 'OptionsQuestion',
423
- })
424
- return result
425
-
426
- @classmethod
427
- def from_dict(cls, data: dict) -> 'AddOptionsQuestionEvent':
428
- if data['eventType'] != 'AddQuestionEvent':
429
- raise ValueError('Event of incorrect type (expect AddQuestionEvent)')
430
- if data['questionType'] != 'OptionsQuestion':
431
- raise ValueError('Event of incorrect type (expect OptionsQuestion)')
432
- return AddOptionsQuestionEvent(
433
- event_uuid=data['uuid'],
434
- entity_uuid=data['entityUuid'],
435
- parent_uuid=data['parentUuid'],
436
- created_at=data['createdAt'],
437
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
438
- title=data['title'],
439
- text=data['text'],
440
- required_phase_uuid=data['requiredPhaseUuid'],
441
- tag_uuids=data['tagUuids'],
442
- )
443
-
444
-
445
- class AddMultiChoiceQuestionEvent(AddQuestionEvent):
446
-
447
- def to_dict(self) -> dict:
448
- result = super().to_dict()
449
- result.update({
450
- 'questionType': 'MultiChoiceQuestion',
451
- })
452
- return result
453
-
454
- @classmethod
455
- def from_dict(cls, data: dict) -> 'AddMultiChoiceQuestionEvent':
456
- if data['eventType'] != 'AddQuestionEvent':
457
- raise ValueError('Event of incorrect type (expect AddQuestionEvent)')
458
- if data['questionType'] != 'MultiChoiceQuestion':
459
- raise ValueError('Event of incorrect type (expect MultiChoiceQuestion)')
460
- return AddMultiChoiceQuestionEvent(
461
- event_uuid=data['uuid'],
462
- entity_uuid=data['entityUuid'],
463
- parent_uuid=data['parentUuid'],
464
- created_at=data['createdAt'],
465
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
466
- title=data['title'],
467
- text=data['text'],
468
- required_phase_uuid=data['requiredPhaseUuid'],
469
- tag_uuids=data['tagUuids'],
470
- )
471
-
472
-
473
- class AddListQuestionEvent(AddQuestionEvent):
474
-
475
- def to_dict(self) -> dict:
476
- result = super().to_dict()
477
- result.update({
478
- 'questionType': 'ListQuestion',
479
- })
480
- return result
481
-
482
- @classmethod
483
- def from_dict(cls, data: dict) -> 'AddListQuestionEvent':
484
- if data['eventType'] != 'AddQuestionEvent':
485
- raise ValueError('Event of incorrect type (expect AddQuestionEvent)')
486
- if data['questionType'] != 'ListQuestion':
487
- raise ValueError('Event of incorrect type (expect ListQuestion)')
488
- return AddListQuestionEvent(
489
- event_uuid=data['uuid'],
490
- entity_uuid=data['entityUuid'],
491
- parent_uuid=data['parentUuid'],
492
- created_at=data['createdAt'],
493
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
494
- title=data['title'],
495
- text=data['text'],
496
- required_phase_uuid=data['requiredPhaseUuid'],
497
- tag_uuids=data['tagUuids'],
498
- )
499
-
500
-
501
- class AddValueQuestionEvent(AddQuestionEvent):
502
-
503
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
504
- created_at: str, annotations: list[MapEntry],
505
- title: str, text: str | None, required_phase_uuid: str | None,
506
- tag_uuids: list[str], value_type: str):
507
- super().__init__(
508
- event_uuid=event_uuid,
509
- entity_uuid=entity_uuid,
510
- parent_uuid=parent_uuid,
511
- created_at=created_at,
512
- annotations=annotations,
513
- title=title,
514
- text=text,
515
- required_phase_uuid=required_phase_uuid,
516
- tag_uuids=tag_uuids,
517
- )
518
- self.value_type = value_type
519
-
520
- def to_dict(self) -> dict:
521
- result = super().to_dict()
522
- result.update({
523
- 'questionType': 'ValueQuestion',
524
- 'valueType': self.value_type,
525
- })
526
- return result
527
-
528
- @classmethod
529
- def from_dict(cls, data: dict) -> 'AddValueQuestionEvent':
530
- if data['eventType'] != 'AddQuestionEvent':
531
- raise ValueError('Event of incorrect type (expect AddQuestionEvent)')
532
- if data['questionType'] != 'ValueQuestion':
533
- raise ValueError('Event of incorrect type (expect ValueQuestion)')
534
- return AddValueQuestionEvent(
535
- event_uuid=data['uuid'],
536
- entity_uuid=data['entityUuid'],
537
- parent_uuid=data['parentUuid'],
538
- created_at=data['createdAt'],
539
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
540
- title=data['title'],
541
- text=data['text'],
542
- required_phase_uuid=data['requiredPhaseUuid'],
543
- tag_uuids=data['tagUuids'],
544
- value_type=data['valueType'],
545
- )
546
-
547
-
548
- class AddIntegrationQuestionEvent(AddQuestionEvent):
549
-
550
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
551
- created_at: str, annotations: list[MapEntry],
552
- title: str, text: str | None, required_phase_uuid: str | None,
553
- tag_uuids: list[str], integration_uuid: str, props: dict[str, str]):
554
- super().__init__(
555
- event_uuid=event_uuid,
556
- entity_uuid=entity_uuid,
557
- parent_uuid=parent_uuid,
558
- created_at=created_at,
559
- annotations=annotations,
560
- title=title,
561
- text=text,
562
- required_phase_uuid=required_phase_uuid,
563
- tag_uuids=tag_uuids,
564
- )
565
- self.integration_uuid = integration_uuid
566
- self.props = props
567
-
568
- def to_dict(self) -> dict:
569
- result = super().to_dict()
570
- result.update({
571
- 'questionType': 'IntegrationQuestion',
572
- 'integrationUuid': self.integration_uuid,
573
- 'props': self.props,
574
- })
575
- return result
576
-
577
- @classmethod
578
- def from_dict(cls, data: dict) -> 'AddIntegrationQuestionEvent':
579
- if data['eventType'] != 'AddQuestionEvent':
580
- raise ValueError('Event of incorrect type (expect AddQuestionEvent)')
581
- if data['questionType'] != 'IntegrationQuestion':
582
- raise ValueError('Event of incorrect type (expect IntegrationQuestion)')
583
- return AddIntegrationQuestionEvent(
584
- event_uuid=data['uuid'],
585
- entity_uuid=data['entityUuid'],
586
- parent_uuid=data['parentUuid'],
587
- created_at=data['createdAt'],
588
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
589
- title=data['title'],
590
- text=data['text'],
591
- required_phase_uuid=data['requiredPhaseUuid'],
592
- tag_uuids=data['tagUuids'],
593
- integration_uuid=data['integrationUuid'],
594
- props=data['props'],
595
- )
596
-
597
-
598
- @event_class
599
- class EditQuestionEvent(_KMEditEvent, abc.ABC):
600
-
601
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
602
- created_at: str, annotations: EventField[list[MapEntry]],
603
- title: EventField[str], text: EventField[str | None],
604
- required_phase_uuid: EventField[str | None],
605
- tag_uuids: EventField[list[str]], expert_uuids: EventField[list[str]],
606
- reference_uuids: EventField[list[str]]):
607
- super().__init__(
608
- event_uuid=event_uuid,
609
- entity_uuid=entity_uuid,
610
- parent_uuid=parent_uuid,
611
- created_at=created_at,
612
- annotations=annotations,
613
- )
614
- self.title = title
615
- self.text = text
616
- self.required_phase_uuid = required_phase_uuid
617
- self.tag_uuids = tag_uuids
618
- self.expert_uuids = expert_uuids
619
- self.reference_uuids = reference_uuids
620
-
621
- def to_dict(self) -> dict:
622
- result = super().to_dict()
623
- result.update({
624
- 'eventType': 'EditQuestionEvent',
625
- 'title': self.title.to_dict(),
626
- 'text': self.text.to_dict(),
627
- 'requiredPhaseUuid': self.required_phase_uuid.to_dict(),
628
- 'tagUuids': self.tag_uuids.to_dict(),
629
- 'expertUuids': self.expert_uuids.to_dict(),
630
- 'referenceUuids': self.reference_uuids.to_dict(),
631
- })
632
- return result
633
-
634
- @classmethod
635
- def from_dict(cls, data: dict) -> 'EditQuestionEvent':
636
- if data['eventType'] != cls.__name__:
637
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
638
- question_type = data['questionType']
639
- if question_type == 'OptionsQuestion':
640
- return EditOptionsQuestionEvent.from_dict(data)
641
- if question_type == 'ListQuestion':
642
- return EditListQuestionEvent.from_dict(data)
643
- if question_type == 'ValueQuestion':
644
- return EditValueQuestionEvent.from_dict(data)
645
- if question_type == 'IntegrationQuestion':
646
- return EditIntegrationQuestionEvent.from_dict(data)
647
- if question_type == 'MultiChoiceQuestion':
648
- return EditMultiChoiceQuestionEvent.from_dict(data)
649
- raise ValueError(f'Unknown question type "{question_type}"')
650
-
651
-
652
- class EditOptionsQuestionEvent(EditQuestionEvent):
653
-
654
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
655
- created_at: str, annotations: EventField[list[MapEntry]],
656
- title: EventField[str], text: EventField[str | None],
657
- required_phase_uuid: EventField[str | None],
658
- tag_uuids: EventField[list[str]], expert_uuids: EventField[list[str]],
659
- reference_uuids: EventField[list[str]],
660
- answer_uuids: EventField[list[str]]):
661
- super().__init__(
662
- event_uuid=event_uuid,
663
- entity_uuid=entity_uuid,
664
- parent_uuid=parent_uuid,
665
- created_at=created_at,
666
- annotations=annotations,
667
- title=title,
668
- text=text,
669
- required_phase_uuid=required_phase_uuid,
670
- tag_uuids=tag_uuids,
671
- expert_uuids=expert_uuids,
672
- reference_uuids=reference_uuids,
673
- )
674
- self.answer_uuids = answer_uuids
675
-
676
- def to_dict(self) -> dict:
677
- result = super().to_dict()
678
- result.update({
679
- 'questionType': 'OptionsQuestion',
680
- 'answerUuids': self.answer_uuids.to_dict(),
681
- })
682
- return result
683
-
684
- @classmethod
685
- def from_dict(cls, data: dict) -> 'EditOptionsQuestionEvent':
686
- if data['eventType'] != 'EditQuestionEvent':
687
- raise ValueError('Event of incorrect type (expect EditQuestionEvent)')
688
- if data['questionType'] != 'OptionsQuestion':
689
- raise ValueError('Event of incorrect type (expect OptionsQuestion)')
690
- return EditOptionsQuestionEvent(
691
- event_uuid=data['uuid'],
692
- entity_uuid=data['entityUuid'],
693
- parent_uuid=data['parentUuid'],
694
- created_at=data['createdAt'],
695
- annotations=EventField.from_dict(
696
- data=data['annotations'],
697
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
698
- ),
699
- title=EventField.from_dict(data['title']),
700
- text=EventField.from_dict(data['text']),
701
- required_phase_uuid=EventField.from_dict(data['requiredPhaseUuid']),
702
- tag_uuids=EventField.from_dict(data['tagUuids']),
703
- expert_uuids=EventField.from_dict(data['expertUuids']),
704
- reference_uuids=EventField.from_dict(data['referenceUuids']),
705
- answer_uuids=EventField.from_dict(data['answerUuids']),
706
- )
707
-
708
-
709
- class EditMultiChoiceQuestionEvent(EditQuestionEvent):
710
-
711
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
712
- created_at: str, annotations: EventField[list[MapEntry]],
713
- title: EventField[str], text: EventField[str | None],
714
- required_phase_uuid: EventField[str | None],
715
- tag_uuids: EventField[list[str]], expert_uuids: EventField[list[str]],
716
- reference_uuids: EventField[list[str]],
717
- choice_uuids: EventField[list[str]]):
718
- super().__init__(
719
- event_uuid=event_uuid,
720
- entity_uuid=entity_uuid,
721
- parent_uuid=parent_uuid,
722
- created_at=created_at,
723
- annotations=annotations,
724
- title=title,
725
- text=text,
726
- required_phase_uuid=required_phase_uuid,
727
- tag_uuids=tag_uuids,
728
- expert_uuids=expert_uuids,
729
- reference_uuids=reference_uuids,
730
- )
731
- self.choice_uuids = choice_uuids
732
-
733
- def to_dict(self) -> dict:
734
- result = super().to_dict()
735
- result.update({
736
- 'questionType': 'MultiChoiceQuestion',
737
- 'choiceUuids': self.choice_uuids.to_dict(),
738
- })
739
- return result
740
-
741
- @classmethod
742
- def from_dict(cls, data: dict) -> 'EditMultiChoiceQuestionEvent':
743
- if data['eventType'] != 'EditQuestionEvent':
744
- raise ValueError('Event of incorrect type (expect EditQuestionEvent)')
745
- if data['questionType'] != 'MultiChoiceQuestion':
746
- raise ValueError('Event of incorrect type (expect MultiChoiceQuestion)')
747
- return EditMultiChoiceQuestionEvent(
748
- event_uuid=data['uuid'],
749
- entity_uuid=data['entityUuid'],
750
- parent_uuid=data['parentUuid'],
751
- created_at=data['createdAt'],
752
- annotations=EventField.from_dict(
753
- data=data['annotations'],
754
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
755
- ),
756
- title=EventField.from_dict(data['title']),
757
- text=EventField.from_dict(data['text']),
758
- required_phase_uuid=EventField.from_dict(data['requiredPhaseUuid']),
759
- tag_uuids=EventField.from_dict(data['tagUuids']),
760
- expert_uuids=EventField.from_dict(data['expertUuids']),
761
- reference_uuids=EventField.from_dict(data['referenceUuids']),
762
- choice_uuids=EventField.from_dict(data['choiceUuids']),
763
- )
764
-
765
-
766
- class EditListQuestionEvent(EditQuestionEvent):
767
-
768
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
769
- created_at: str, annotations: EventField[list[MapEntry]],
770
- title: EventField[str], text: EventField[str | None],
771
- required_phase_uuid: EventField[str | None],
772
- tag_uuids: EventField[list[str]], expert_uuids: EventField[list[str]],
773
- reference_uuids: EventField[list[str]],
774
- item_template_question_uuids: EventField[list[str]]):
775
- super().__init__(
776
- event_uuid=event_uuid,
777
- entity_uuid=entity_uuid,
778
- parent_uuid=parent_uuid,
779
- created_at=created_at,
780
- annotations=annotations,
781
- title=title,
782
- text=text,
783
- required_phase_uuid=required_phase_uuid,
784
- tag_uuids=tag_uuids,
785
- expert_uuids=expert_uuids,
786
- reference_uuids=reference_uuids,
787
- )
788
- self.item_template_question_uuids = item_template_question_uuids
789
-
790
- def to_dict(self) -> dict:
791
- result = super().to_dict()
792
- result.update({
793
- 'questionType': 'ListQuestion',
794
- 'itemTemplateQuestionUuids': self.item_template_question_uuids.to_dict(),
795
- })
796
- return result
797
-
798
- @classmethod
799
- def from_dict(cls, data: dict) -> 'EditListQuestionEvent':
800
- if data['eventType'] != 'EditQuestionEvent':
801
- raise ValueError('Event of incorrect type (expect EditQuestionEvent)')
802
- if data['questionType'] != 'ListQuestion':
803
- raise ValueError('Event of incorrect type (expect ListQuestion)')
804
- return EditListQuestionEvent(
805
- event_uuid=data['uuid'],
806
- entity_uuid=data['entityUuid'],
807
- parent_uuid=data['parentUuid'],
808
- created_at=data['createdAt'],
809
- annotations=EventField.from_dict(
810
- data=data['annotations'],
811
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
812
- ),
813
- title=EventField.from_dict(data['title']),
814
- text=EventField.from_dict(data['text']),
815
- required_phase_uuid=EventField.from_dict(data['requiredPhaseUuid']),
816
- tag_uuids=EventField.from_dict(data['tagUuids']),
817
- expert_uuids=EventField.from_dict(data['expertUuids']),
818
- reference_uuids=EventField.from_dict(data['referenceUuids']),
819
- item_template_question_uuids=EventField.from_dict(data['itemTemplateQuestionUuids']),
820
- )
821
-
822
-
823
- class EditValueQuestionEvent(EditQuestionEvent):
824
-
825
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
826
- created_at: str, annotations: EventField[list[MapEntry]],
827
- title: EventField[str], text: EventField[str | None],
828
- required_phase_uuid: EventField[str | None],
829
- tag_uuids: EventField[list[str]], expert_uuids: EventField[list[str]],
830
- reference_uuids: EventField[list[str]], value_type: EventField[str]):
831
- super().__init__(
832
- event_uuid=event_uuid,
833
- entity_uuid=entity_uuid,
834
- parent_uuid=parent_uuid,
835
- created_at=created_at,
836
- annotations=annotations,
837
- title=title,
838
- text=text,
839
- required_phase_uuid=required_phase_uuid,
840
- tag_uuids=tag_uuids,
841
- expert_uuids=expert_uuids,
842
- reference_uuids=reference_uuids,
843
- )
844
- self.value_type = value_type
845
-
846
- def to_dict(self) -> dict:
847
- result = super().to_dict()
848
- result.update({
849
- 'questionType': 'ValueQuestion',
850
- 'valueType': self.value_type.to_dict(),
851
- })
852
- return result
853
-
854
- @classmethod
855
- def from_dict(cls, data: dict) -> 'EditValueQuestionEvent':
856
- if data['eventType'] != 'EditQuestionEvent':
857
- raise ValueError('Event of incorrect type (expect EditQuestionEvent)')
858
- if data['questionType'] != 'ValueQuestion':
859
- raise ValueError('Event of incorrect type (expect ValueQuestion)')
860
- return EditValueQuestionEvent(
861
- event_uuid=data['uuid'],
862
- entity_uuid=data['entityUuid'],
863
- parent_uuid=data['parentUuid'],
864
- created_at=data['createdAt'],
865
- annotations=EventField.from_dict(
866
- data=data['annotations'],
867
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
868
- ),
869
- title=EventField.from_dict(data['title']),
870
- text=EventField.from_dict(data['text']),
871
- required_phase_uuid=EventField.from_dict(data['requiredPhaseUuid']),
872
- tag_uuids=EventField.from_dict(data['tagUuids']),
873
- expert_uuids=EventField.from_dict(data['expertUuids']),
874
- reference_uuids=EventField.from_dict(data['referenceUuids']),
875
- value_type=EventField.from_dict(data['valueType']),
876
- )
877
-
878
-
879
- class EditIntegrationQuestionEvent(EditQuestionEvent):
880
-
881
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
882
- created_at: str, annotations: EventField[list[MapEntry]],
883
- title: EventField[str], text: EventField[str | None],
884
- required_phase_uuid: EventField[str | None],
885
- tag_uuids: EventField[list[str]], expert_uuids: EventField[list[str]],
886
- reference_uuids: EventField[list[str]], integration_uuid: EventField[str],
887
- props: EventField[dict[str, str]]):
888
- super().__init__(
889
- event_uuid=event_uuid,
890
- entity_uuid=entity_uuid,
891
- parent_uuid=parent_uuid,
892
- created_at=created_at,
893
- annotations=annotations,
894
- title=title,
895
- text=text,
896
- required_phase_uuid=required_phase_uuid,
897
- tag_uuids=tag_uuids,
898
- expert_uuids=expert_uuids,
899
- reference_uuids=reference_uuids,
900
- )
901
- self.integration_uuid = integration_uuid
902
- self.props = props
903
-
904
- def to_dict(self) -> dict:
905
- result = super().to_dict()
906
- result.update({
907
- 'questionType': 'IntegrationQuestion',
908
- 'integrationUuid': self.integration_uuid.to_dict(),
909
- 'props': self.props.to_dict(),
910
- })
911
- return result
912
-
913
- @classmethod
914
- def from_dict(cls, data: dict) -> 'EditIntegrationQuestionEvent':
915
- if data['eventType'] != 'EditQuestionEvent':
916
- raise ValueError('Event of incorrect type (expect EditQuestionEvent)')
917
- if data['questionType'] != 'IntegrationQuestion':
918
- raise ValueError('Event of incorrect type (expect IntegrationQuestion)')
919
- return EditIntegrationQuestionEvent(
920
- event_uuid=data['uuid'],
921
- entity_uuid=data['entityUuid'],
922
- parent_uuid=data['parentUuid'],
923
- created_at=data['createdAt'],
924
- annotations=EventField.from_dict(
925
- data=data['annotations'],
926
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
927
- ),
928
- title=EventField.from_dict(data['title']),
929
- text=EventField.from_dict(data['text']),
930
- required_phase_uuid=EventField.from_dict(data['requiredPhaseUuid']),
931
- tag_uuids=EventField.from_dict(data['tagUuids']),
932
- expert_uuids=EventField.from_dict(data['expertUuids']),
933
- reference_uuids=EventField.from_dict(data['referenceUuids']),
934
- integration_uuid=EventField.from_dict(data['integrationUuid']),
935
- props=EventField.from_dict(data['props']),
936
- )
937
-
938
-
939
- @event_class
940
- class DeleteQuestionEvent(_KMDeleteEvent):
941
-
942
- def to_dict(self) -> dict:
943
- result = super().to_dict()
944
- result.update({
945
- 'eventType': type(self).__name__,
946
- })
947
- return result
948
-
949
- @classmethod
950
- def from_dict(cls, data: dict) -> 'DeleteQuestionEvent':
951
- if data['eventType'] != cls.__name__:
952
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
953
- return DeleteQuestionEvent(
954
- event_uuid=data['uuid'],
955
- entity_uuid=data['entityUuid'],
956
- parent_uuid=data['parentUuid'],
957
- created_at=data['createdAt'],
958
- )
959
-
960
-
961
- @event_class
962
- class AddAnswerEvent(_KMAddEvent):
963
-
964
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
965
- created_at: str, annotations: list[MapEntry],
966
- label: str, advice: str | None, metric_measures: list[MetricMeasure]):
967
- super().__init__(
968
- event_uuid=event_uuid,
969
- entity_uuid=entity_uuid,
970
- parent_uuid=parent_uuid,
971
- created_at=created_at,
972
- annotations=annotations,
973
- )
974
- self.label = label
975
- self.advice = advice
976
- self.metric_measures = metric_measures
977
-
978
- def to_dict(self) -> dict:
979
- result = super().to_dict()
980
- result.update({
981
- 'eventType': type(self).__name__,
982
- 'label': self.label,
983
- 'advice': self.advice,
984
- 'metricMeasures': [m.to_dict() for m in self.metric_measures],
985
- })
986
- return result
987
-
988
- @classmethod
989
- def from_dict(cls, data: dict) -> 'AddAnswerEvent':
990
- if data['eventType'] != cls.__name__:
991
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
992
- return AddAnswerEvent(
993
- event_uuid=data['uuid'],
994
- entity_uuid=data['entityUuid'],
995
- parent_uuid=data['parentUuid'],
996
- created_at=data['createdAt'],
997
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
998
- label=data['label'],
999
- advice=data['advice'],
1000
- metric_measures=[MetricMeasure.from_dict(m) for m in data['metricMeasures']],
1001
- )
1002
-
1003
-
1004
- @event_class
1005
- class EditAnswerEvent(_KMEditEvent):
1006
-
1007
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1008
- created_at: str, annotations: EventField[list[MapEntry]],
1009
- label: EventField[str], advice: EventField[str | None],
1010
- follow_up_uuids: EventField[list[str]],
1011
- metric_measures: EventField[list[MetricMeasure]]):
1012
- super().__init__(
1013
- event_uuid=event_uuid,
1014
- entity_uuid=entity_uuid,
1015
- parent_uuid=parent_uuid,
1016
- created_at=created_at,
1017
- annotations=annotations,
1018
- )
1019
- self.label = label
1020
- self.advice = advice
1021
- self.follow_up_uuids = follow_up_uuids
1022
- self.metric_measures = metric_measures
1023
-
1024
- def to_dict(self) -> dict:
1025
- result = super().to_dict()
1026
- result.update({
1027
- 'eventType': type(self).__name__,
1028
- 'label': self.label.to_dict(),
1029
- 'advice': self.advice.to_dict(),
1030
- 'followUpUuids': self.follow_up_uuids.to_dict(),
1031
- 'metricMeasures': self.metric_measures.to_dict(),
1032
- })
1033
- return result
1034
-
1035
- @classmethod
1036
- def from_dict(cls, data: dict) -> 'EditAnswerEvent':
1037
- if data['eventType'] != cls.__name__:
1038
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
1039
- return EditAnswerEvent(
1040
- event_uuid=data['uuid'],
1041
- entity_uuid=data['entityUuid'],
1042
- parent_uuid=data['parentUuid'],
1043
- created_at=data['createdAt'],
1044
- annotations=EventField.from_dict(
1045
- data=data['annotations'],
1046
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
1047
- ),
1048
- label=EventField.from_dict(data['label']),
1049
- advice=EventField.from_dict(data['advice']),
1050
- follow_up_uuids=EventField.from_dict(data['followUpUuids']),
1051
- metric_measures=EventField.from_dict(
1052
- data=data['metricMeasures'],
1053
- loader=lambda v: [MetricMeasure.from_dict(x) for x in v],
1054
- ),
1055
- )
1056
-
1057
-
1058
- @event_class
1059
- class DeleteAnswerEvent(_KMDeleteEvent):
1060
-
1061
- def to_dict(self) -> dict:
1062
- result = super().to_dict()
1063
- result.update({
1064
- 'eventType': type(self).__name__,
1065
- })
1066
- return result
1067
-
1068
- @classmethod
1069
- def from_dict(cls, data: dict) -> 'DeleteAnswerEvent':
1070
- if data['eventType'] != cls.__name__:
1071
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
1072
- return DeleteAnswerEvent(
1073
- event_uuid=data['uuid'],
1074
- entity_uuid=data['entityUuid'],
1075
- parent_uuid=data['parentUuid'],
1076
- created_at=data['createdAt'],
1077
- )
1078
-
1079
-
1080
- @event_class
1081
- class AddChoiceEvent(_KMAddEvent):
1082
-
1083
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1084
- created_at: str, annotations: list[MapEntry],
1085
- label: str):
1086
- super().__init__(
1087
- event_uuid=event_uuid,
1088
- entity_uuid=entity_uuid,
1089
- parent_uuid=parent_uuid,
1090
- created_at=created_at,
1091
- annotations=annotations,
1092
- )
1093
- self.label = label
1094
-
1095
- def to_dict(self) -> dict:
1096
- result = super().to_dict()
1097
- result.update({
1098
- 'eventType': type(self).__name__,
1099
- 'label': self.label,
1100
- })
1101
- return result
1102
-
1103
- @classmethod
1104
- def from_dict(cls, data: dict) -> 'AddChoiceEvent':
1105
- if data['eventType'] != cls.__name__:
1106
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
1107
- return AddChoiceEvent(
1108
- event_uuid=data['uuid'],
1109
- entity_uuid=data['entityUuid'],
1110
- parent_uuid=data['parentUuid'],
1111
- created_at=data['createdAt'],
1112
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
1113
- label=data['label'],
1114
- )
1115
-
1116
-
1117
- @event_class
1118
- class EditChoiceEvent(_KMEditEvent):
1119
-
1120
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1121
- created_at: str, annotations: EventField[list[MapEntry]],
1122
- label: EventField[str]):
1123
- super().__init__(
1124
- event_uuid=event_uuid,
1125
- entity_uuid=entity_uuid,
1126
- parent_uuid=parent_uuid,
1127
- created_at=created_at,
1128
- annotations=annotations,
1129
- )
1130
- self.label = label
1131
-
1132
- def to_dict(self) -> dict:
1133
- result = super().to_dict()
1134
- result.update({
1135
- 'eventType': type(self).__name__,
1136
- 'label': self.label.to_dict(),
1137
- })
1138
- return result
1139
-
1140
- @classmethod
1141
- def from_dict(cls, data: dict) -> 'EditChoiceEvent':
1142
- if data['eventType'] != cls.__name__:
1143
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
1144
- return EditChoiceEvent(
1145
- event_uuid=data['uuid'],
1146
- entity_uuid=data['entityUuid'],
1147
- parent_uuid=data['parentUuid'],
1148
- created_at=data['createdAt'],
1149
- annotations=EventField.from_dict(
1150
- data=data['annotations'],
1151
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
1152
- ),
1153
- label=EventField.from_dict(data['label']),
1154
- )
1155
-
1156
-
1157
- @event_class
1158
- class DeleteChoiceEvent(_KMDeleteEvent):
1159
-
1160
- def to_dict(self) -> dict:
1161
- result = super().to_dict()
1162
- result.update({
1163
- 'eventType': type(self).__name__,
1164
- })
1165
- return result
1166
-
1167
- @classmethod
1168
- def from_dict(cls, data: dict) -> 'DeleteChoiceEvent':
1169
- if data['eventType'] != cls.__name__:
1170
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
1171
- return DeleteChoiceEvent(
1172
- event_uuid=data['uuid'],
1173
- entity_uuid=data['entityUuid'],
1174
- parent_uuid=data['parentUuid'],
1175
- created_at=data['createdAt'],
1176
- )
1177
-
1178
-
1179
- @event_class
1180
- class AddExpertEvent(_KMAddEvent):
1181
-
1182
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1183
- created_at: str, annotations: list[MapEntry],
1184
- name: str, email: str):
1185
- super().__init__(
1186
- event_uuid=event_uuid,
1187
- entity_uuid=entity_uuid,
1188
- parent_uuid=parent_uuid,
1189
- created_at=created_at,
1190
- annotations=annotations,
1191
- )
1192
- self.name = name
1193
- self.email = email
1194
-
1195
- def to_dict(self) -> dict:
1196
- result = super().to_dict()
1197
- result.update({
1198
- 'eventType': type(self).__name__,
1199
- 'name': self.name,
1200
- 'email': self.email,
1201
- })
1202
- return result
1203
-
1204
- @classmethod
1205
- def from_dict(cls, data: dict) -> 'AddExpertEvent':
1206
- if data['eventType'] != cls.__name__:
1207
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
1208
- return AddExpertEvent(
1209
- event_uuid=data['uuid'],
1210
- entity_uuid=data['entityUuid'],
1211
- parent_uuid=data['parentUuid'],
1212
- created_at=data['createdAt'],
1213
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
1214
- name=data['name'],
1215
- email=data['email'],
1216
- )
1217
-
1218
-
1219
- @event_class
1220
- class EditExpertEvent(_KMEditEvent):
1221
-
1222
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1223
- created_at: str, annotations: EventField[list[MapEntry]],
1224
- name: EventField[str], email: EventField[str]):
1225
- super().__init__(
1226
- event_uuid=event_uuid,
1227
- entity_uuid=entity_uuid,
1228
- parent_uuid=parent_uuid,
1229
- created_at=created_at,
1230
- annotations=annotations,
1231
- )
1232
- self.name = name
1233
- self.email = email
1234
-
1235
- def to_dict(self) -> dict:
1236
- result = super().to_dict()
1237
- result.update({
1238
- 'eventType': type(self).__name__,
1239
- 'name': self.name.to_dict(),
1240
- 'email': self.email.to_dict(),
1241
- })
1242
- return result
1243
-
1244
- @classmethod
1245
- def from_dict(cls, data: dict) -> 'EditExpertEvent':
1246
- if data['eventType'] != cls.__name__:
1247
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
1248
- return EditExpertEvent(
1249
- event_uuid=data['uuid'],
1250
- entity_uuid=data['entityUuid'],
1251
- parent_uuid=data['parentUuid'],
1252
- created_at=data['createdAt'],
1253
- annotations=EventField.from_dict(
1254
- data=data['annotations'],
1255
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
1256
- ),
1257
- name=EventField.from_dict(data['name']),
1258
- email=EventField.from_dict(data['email']),
1259
- )
1260
-
1261
-
1262
- @event_class
1263
- class DeleteExpertEvent(_KMDeleteEvent):
1264
-
1265
- def to_dict(self) -> dict:
1266
- result = super().to_dict()
1267
- result.update({
1268
- 'eventType': type(self).__name__,
1269
- })
1270
- return result
1271
-
1272
- @classmethod
1273
- def from_dict(cls, data: dict) -> 'DeleteExpertEvent':
1274
- if data['eventType'] != cls.__name__:
1275
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
1276
- return DeleteExpertEvent(
1277
- event_uuid=data['uuid'],
1278
- entity_uuid=data['entityUuid'],
1279
- parent_uuid=data['parentUuid'],
1280
- created_at=data['createdAt'],
1281
- )
1282
-
1283
-
1284
- @event_class
1285
- class AddReferenceEvent(_KMAddEvent, abc.ABC):
1286
-
1287
- def to_dict(self) -> dict:
1288
- result = super().to_dict()
1289
- result.update({
1290
- 'eventType': 'AddReferenceEvent',
1291
- })
1292
- return result
1293
-
1294
- @classmethod
1295
- def from_dict(cls, data: dict) -> 'AddReferenceEvent':
1296
- if data['eventType'] != cls.__name__:
1297
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
1298
- reference_type = data['referenceType']
1299
- if reference_type == 'ResourcePageReference':
1300
- return AddResourcePageReferenceEvent.from_dict(data)
1301
- if reference_type == 'URLReference':
1302
- return AddURLReferenceEvent.from_dict(data)
1303
- if reference_type == 'CrossReference':
1304
- return AddCrossReferenceEvent.from_dict(data)
1305
- raise ValueError(f'Unknown reference type "{reference_type}"')
1306
-
1307
-
1308
- class AddResourcePageReferenceEvent(AddReferenceEvent):
1309
-
1310
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1311
- created_at: str, annotations: list[MapEntry],
1312
- short_uuid: str):
1313
- super().__init__(
1314
- event_uuid=event_uuid,
1315
- entity_uuid=entity_uuid,
1316
- parent_uuid=parent_uuid,
1317
- created_at=created_at,
1318
- annotations=annotations,
1319
- )
1320
- self.short_uuid = short_uuid
1321
-
1322
- def to_dict(self) -> dict:
1323
- result = super().to_dict()
1324
- result.update({
1325
- 'referenceType': 'ResourcePageReference',
1326
- 'shortUuid': self.short_uuid,
1327
- })
1328
- return result
1329
-
1330
- @classmethod
1331
- def from_dict(cls, data: dict) -> 'AddResourcePageReferenceEvent':
1332
- if data['eventType'] != 'AddReferenceEvent':
1333
- raise ValueError('Event of incorrect type (expect AddReferenceEvent)')
1334
- if data['referenceType'] != 'ResourcePageReference':
1335
- raise ValueError('Event of incorrect type (expect ResourcePageReference)')
1336
- return AddResourcePageReferenceEvent(
1337
- event_uuid=data['uuid'],
1338
- entity_uuid=data['entityUuid'],
1339
- parent_uuid=data['parentUuid'],
1340
- created_at=data['createdAt'],
1341
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
1342
- short_uuid=data['shortUuid'],
1343
- )
1344
-
1345
-
1346
- class AddURLReferenceEvent(AddReferenceEvent):
1347
-
1348
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1349
- created_at: str, annotations: list[MapEntry],
1350
- url: str, label: str):
1351
- super().__init__(
1352
- event_uuid=event_uuid,
1353
- entity_uuid=entity_uuid,
1354
- parent_uuid=parent_uuid,
1355
- created_at=created_at,
1356
- annotations=annotations,
1357
- )
1358
- self.url = url
1359
- self.label = label
1360
-
1361
- def to_dict(self) -> dict:
1362
- result = super().to_dict()
1363
- result.update({
1364
- 'referenceType': 'URLReference',
1365
- 'url': self.url,
1366
- 'label': self.label,
1367
- })
1368
- return result
1369
-
1370
- @classmethod
1371
- def from_dict(cls, data: dict) -> 'AddURLReferenceEvent':
1372
- if data['eventType'] != 'AddReferenceEvent':
1373
- raise ValueError('Event of incorrect type (expect AddReferenceEvent)')
1374
- if data['referenceType'] != 'URLReference':
1375
- raise ValueError('Event of incorrect type (expect URLReference)')
1376
- return AddURLReferenceEvent(
1377
- event_uuid=data['uuid'],
1378
- entity_uuid=data['entityUuid'],
1379
- parent_uuid=data['parentUuid'],
1380
- created_at=data['createdAt'],
1381
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
1382
- url=data['url'],
1383
- label=data['label'],
1384
- )
1385
-
1386
-
1387
- class AddCrossReferenceEvent(AddReferenceEvent):
1388
-
1389
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1390
- created_at: str, annotations: list[MapEntry],
1391
- target_uuid: str, description: str):
1392
- super().__init__(
1393
- event_uuid=event_uuid,
1394
- entity_uuid=entity_uuid,
1395
- parent_uuid=parent_uuid,
1396
- created_at=created_at,
1397
- annotations=annotations,
1398
- )
1399
- self.target_uuid = target_uuid
1400
- self.description = description
1401
-
1402
- def to_dict(self) -> dict:
1403
- result = super().to_dict()
1404
- result.update({
1405
- 'referenceType': 'CrossReference',
1406
- 'targetUuid': self.target_uuid,
1407
- 'description': self.description,
1408
- })
1409
- return result
1410
-
1411
- @classmethod
1412
- def from_dict(cls, data: dict) -> 'AddCrossReferenceEvent':
1413
- if data['eventType'] != 'AddReferenceEvent':
1414
- raise ValueError('Event of incorrect type (expect AddReferenceEvent)')
1415
- if data['referenceType'] != 'CrossReference':
1416
- raise ValueError('Event of incorrect type (expect CrossReference)')
1417
- return AddCrossReferenceEvent(
1418
- event_uuid=data['uuid'],
1419
- entity_uuid=data['entityUuid'],
1420
- parent_uuid=data['parentUuid'],
1421
- created_at=data['createdAt'],
1422
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
1423
- target_uuid=data['targetUuid'],
1424
- description=data['description'],
1425
- )
1426
-
1427
-
1428
- @event_class
1429
- class EditReferenceEvent(_KMEditEvent, abc.ABC):
1430
-
1431
- def to_dict(self) -> dict:
1432
- result = super().to_dict()
1433
- result.update({
1434
- 'eventType': 'EditReferenceEvent',
1435
- })
1436
- return result
1437
-
1438
- @classmethod
1439
- def from_dict(cls, data: dict) -> 'EditReferenceEvent':
1440
- if data['eventType'] != cls.__name__:
1441
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
1442
- reference_type = data['referenceType']
1443
- if reference_type == 'ResourcePageReference':
1444
- return EditResourcePageReferenceEvent.from_dict(data)
1445
- if reference_type == 'URLReference':
1446
- return EditURLReferenceEvent.from_dict(data)
1447
- if reference_type == 'CrossReference':
1448
- return EditCrossReferenceEvent.from_dict(data)
1449
- raise ValueError(f'Unknown reference type "{reference_type}"')
1450
-
1451
-
1452
- class EditResourcePageReferenceEvent(EditReferenceEvent):
1453
-
1454
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1455
- created_at: str, annotations: EventField[list[MapEntry]],
1456
- short_uuid: EventField[str]):
1457
- super().__init__(
1458
- event_uuid=event_uuid,
1459
- entity_uuid=entity_uuid,
1460
- parent_uuid=parent_uuid,
1461
- created_at=created_at,
1462
- annotations=annotations,
1463
- )
1464
- self.short_uuid = short_uuid
1465
-
1466
- def to_dict(self) -> dict:
1467
- result = super().to_dict()
1468
- result.update({
1469
- 'referenceType': 'ResourcePageReference',
1470
- 'shortUuid': self.short_uuid.to_dict(),
1471
- })
1472
- return result
1473
-
1474
- @classmethod
1475
- def from_dict(cls, data: dict) -> 'EditResourcePageReferenceEvent':
1476
- if data['eventType'] != 'EditReferenceEvent':
1477
- raise ValueError('Event of incorrect type (expect EditReferenceEvent)')
1478
- if data['referenceType'] != 'ResourcePageReference':
1479
- raise ValueError('Event of incorrect type (expect ResourcePageReference)')
1480
- return EditResourcePageReferenceEvent(
1481
- event_uuid=data['uuid'],
1482
- entity_uuid=data['entityUuid'],
1483
- parent_uuid=data['parentUuid'],
1484
- created_at=data['createdAt'],
1485
- annotations=EventField.from_dict(
1486
- data=data['annotations'],
1487
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
1488
- ),
1489
- short_uuid=EventField.from_dict(data['shortUuid']),
1490
- )
1491
-
1492
-
1493
- class EditURLReferenceEvent(EditReferenceEvent):
1494
-
1495
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1496
- created_at: str, annotations: EventField[list[MapEntry]],
1497
- url: EventField[str], label: EventField[str]):
1498
- super().__init__(
1499
- event_uuid=event_uuid,
1500
- entity_uuid=entity_uuid,
1501
- parent_uuid=parent_uuid,
1502
- created_at=created_at,
1503
- annotations=annotations,
1504
- )
1505
- self.url = url
1506
- self.label = label
1507
-
1508
- def to_dict(self) -> dict:
1509
- result = super().to_dict()
1510
- result.update({
1511
- 'referenceType': 'URLReference',
1512
- 'url': self.url.to_dict(),
1513
- 'label': self.label.to_dict(),
1514
- })
1515
- return result
1516
-
1517
- @classmethod
1518
- def from_dict(cls, data: dict) -> 'EditURLReferenceEvent':
1519
- if data['eventType'] != 'EditReferenceEvent':
1520
- raise ValueError('Event of incorrect type (expect EditReferenceEvent)')
1521
- if data['referenceType'] != 'URLReference':
1522
- raise ValueError('Event of incorrect type (expect URLReference)')
1523
- return EditURLReferenceEvent(
1524
- event_uuid=data['uuid'],
1525
- entity_uuid=data['entityUuid'],
1526
- parent_uuid=data['parentUuid'],
1527
- created_at=data['createdAt'],
1528
- annotations=EventField.from_dict(
1529
- data=data['annotations'],
1530
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
1531
- ),
1532
- url=EventField.from_dict(data['url']),
1533
- label=EventField.from_dict(data['label']),
1534
- )
1535
-
1536
-
1537
- class EditCrossReferenceEvent(EditReferenceEvent):
1538
-
1539
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1540
- created_at: str, annotations: EventField[list[MapEntry]],
1541
- target_uuid: EventField[str], description: EventField[str]):
1542
- super().__init__(
1543
- event_uuid=event_uuid,
1544
- entity_uuid=entity_uuid,
1545
- parent_uuid=parent_uuid,
1546
- created_at=created_at,
1547
- annotations=annotations,
1548
- )
1549
- self.target_uuid = target_uuid
1550
- self.description = description
1551
-
1552
- def to_dict(self) -> dict:
1553
- result = super().to_dict()
1554
- result.update({
1555
- 'referenceType': 'CrossReference',
1556
- 'targetUuid': self.target_uuid.to_dict(),
1557
- 'description': self.description.to_dict(),
1558
- })
1559
- return result
1560
-
1561
- @classmethod
1562
- def from_dict(cls, data: dict) -> 'EditCrossReferenceEvent':
1563
- if data['eventType'] != 'EditReferenceEvent':
1564
- raise ValueError('Event of incorrect type (expect EditReferenceEvent)')
1565
- if data['referenceType'] != 'CrossReference':
1566
- raise ValueError('Event of incorrect type (expect CrossReference)')
1567
- return EditCrossReferenceEvent(
1568
- event_uuid=data['uuid'],
1569
- entity_uuid=data['entityUuid'],
1570
- parent_uuid=data['parentUuid'],
1571
- created_at=data['createdAt'],
1572
- annotations=EventField.from_dict(
1573
- data=data['annotations'],
1574
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
1575
- ),
1576
- target_uuid=EventField.from_dict(data['targetUuid']),
1577
- description=EventField.from_dict(data['description']),
1578
- )
1579
-
1580
-
1581
- @event_class
1582
- class DeleteReferenceEvent(_KMDeleteEvent):
1583
-
1584
- def to_dict(self) -> dict:
1585
- result = super().to_dict()
1586
- result.update({
1587
- 'eventType': type(self).__name__,
1588
- })
1589
- return result
1590
-
1591
- @classmethod
1592
- def from_dict(cls, data: dict) -> 'DeleteReferenceEvent':
1593
- if data['eventType'] != cls.__name__:
1594
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
1595
- return DeleteReferenceEvent(
1596
- event_uuid=data['uuid'],
1597
- entity_uuid=data['entityUuid'],
1598
- parent_uuid=data['parentUuid'],
1599
- created_at=data['createdAt'],
1600
- )
1601
-
1602
-
1603
- @event_class
1604
- class AddTagEvent(_KMAddEvent):
1605
-
1606
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1607
- created_at: str, annotations: list[MapEntry],
1608
- name: str, description: str | None, color: str):
1609
- super().__init__(
1610
- event_uuid=event_uuid,
1611
- entity_uuid=entity_uuid,
1612
- parent_uuid=parent_uuid,
1613
- created_at=created_at,
1614
- annotations=annotations,
1615
- )
1616
- self.name = name # why not title?
1617
- self.description = description # why not text?
1618
- self.color = color
1619
-
1620
- def to_dict(self) -> dict:
1621
- result = super().to_dict()
1622
- result.update({
1623
- 'eventType': type(self).__name__,
1624
- 'name': self.name,
1625
- 'description': self.description,
1626
- 'color': self.color,
1627
- })
1628
- return result
1629
-
1630
- @classmethod
1631
- def from_dict(cls, data: dict) -> 'AddTagEvent':
1632
- if data['eventType'] != cls.__name__:
1633
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
1634
- return AddTagEvent(
1635
- event_uuid=data['uuid'],
1636
- entity_uuid=data['entityUuid'],
1637
- parent_uuid=data['parentUuid'],
1638
- created_at=data['createdAt'],
1639
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
1640
- name=data['name'],
1641
- description=data['description'],
1642
- color=data['color'],
1643
- )
1644
-
1645
-
1646
- @event_class
1647
- class EditTagEvent(_KMEditEvent):
1648
-
1649
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1650
- created_at: str, annotations: EventField[list[MapEntry]],
1651
- name: EventField[str], description: EventField[str | None],
1652
- color: EventField[str]):
1653
- super().__init__(
1654
- event_uuid=event_uuid,
1655
- entity_uuid=entity_uuid,
1656
- parent_uuid=parent_uuid,
1657
- created_at=created_at,
1658
- annotations=annotations,
1659
- )
1660
- self.name = name # why not title?
1661
- self.description = description # why not text?
1662
- self.color = color
1663
-
1664
- def to_dict(self) -> dict:
1665
- result = super().to_dict()
1666
- result.update({
1667
- 'eventType': type(self).__name__,
1668
- 'name': self.name.to_dict(),
1669
- 'description': self.description.to_dict(),
1670
- 'color': self.color.to_dict(),
1671
- })
1672
- return result
1673
-
1674
- @classmethod
1675
- def from_dict(cls, data: dict) -> 'EditTagEvent':
1676
- if data['eventType'] != cls.__name__:
1677
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
1678
- return EditTagEvent(
1679
- event_uuid=data['uuid'],
1680
- entity_uuid=data['entityUuid'],
1681
- parent_uuid=data['parentUuid'],
1682
- created_at=data['createdAt'],
1683
- annotations=EventField.from_dict(
1684
- data=data['annotations'],
1685
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
1686
- ),
1687
- name=EventField.from_dict(data['name']),
1688
- description=EventField.from_dict(data['description']),
1689
- color=EventField.from_dict(data['color']),
1690
- )
1691
-
1692
-
1693
- @event_class
1694
- class DeleteTagEvent(_KMDeleteEvent):
1695
-
1696
- def to_dict(self) -> dict:
1697
- result = super().to_dict()
1698
- result.update({
1699
- 'eventType': type(self).__name__,
1700
- })
1701
- return result
1702
-
1703
- @classmethod
1704
- def from_dict(cls, data: dict) -> 'DeleteTagEvent':
1705
- if data['eventType'] != cls.__name__:
1706
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
1707
- return DeleteTagEvent(
1708
- event_uuid=data['uuid'],
1709
- entity_uuid=data['entityUuid'],
1710
- parent_uuid=data['parentUuid'],
1711
- created_at=data['createdAt'],
1712
- )
1713
-
1714
-
1715
- @event_class
1716
- class AddIntegrationEvent(_KMAddEvent, abc.ABC):
1717
-
1718
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1719
- created_at: str, annotations: list[MapEntry],
1720
- integration_id: str, name: str, props: list[str], logo: str | None,
1721
- item_url: str | None):
1722
- super().__init__(
1723
- event_uuid=event_uuid,
1724
- entity_uuid=entity_uuid,
1725
- parent_uuid=parent_uuid,
1726
- created_at=created_at,
1727
- annotations=annotations,
1728
- )
1729
- self.integration_id = integration_id
1730
- self.name = name
1731
- self.props = props
1732
- self.logo = logo
1733
- self.item_url = item_url
1734
-
1735
- def to_dict(self) -> dict:
1736
- result = super().to_dict()
1737
- result.update({
1738
- 'eventType': 'AddIntegrationEvent',
1739
- 'id': self.integration_id,
1740
- 'name': self.name,
1741
- 'props': self.props,
1742
- 'logo': self.logo,
1743
- 'itemUrl': self.item_url,
1744
- })
1745
- return result
1746
-
1747
- @classmethod
1748
- def from_dict(cls, data: dict) -> 'AddIntegrationEvent':
1749
- if data['eventType'] != cls.__name__:
1750
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
1751
- integration_type = data['integrationType']
1752
- if integration_type == 'ApiIntegration':
1753
- return AddApiIntegrationEvent.from_dict(data)
1754
- if integration_type == 'WidgetIntegration':
1755
- return AddWidgetIntegrationEvent.from_dict(data)
1756
- raise ValueError(f'Unknown integration type "{integration_type}"')
1757
-
1758
-
1759
- class AddApiIntegrationEvent(AddIntegrationEvent):
1760
-
1761
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1762
- created_at: str, annotations: list[MapEntry],
1763
- integration_id: str, name: str, props: list[str], logo: str | None,
1764
- item_url: str | None, rq_method: str, rq_url: str,
1765
- rq_headers: list[MapEntry], rq_body: str, rq_empty_search: bool,
1766
- rs_list_field: str | None, rs_item_id: str | None,
1767
- rs_item_template: str):
1768
- super().__init__(
1769
- event_uuid=event_uuid,
1770
- entity_uuid=entity_uuid,
1771
- parent_uuid=parent_uuid,
1772
- created_at=created_at,
1773
- annotations=annotations,
1774
- integration_id=integration_id,
1775
- name=name,
1776
- props=props,
1777
- logo=logo,
1778
- item_url=item_url
1779
- )
1780
- self.rq_method = rq_method
1781
- self.rq_url = rq_url
1782
- self.rq_headers = rq_headers
1783
- self.rq_body = rq_body
1784
- self.rq_empty_search = rq_empty_search
1785
- self.rs_list_field = rs_list_field
1786
- self.rs_item_id = rs_item_id
1787
- self.rs_item_template = rs_item_template
1788
-
1789
- def to_dict(self) -> dict:
1790
- result = super().to_dict()
1791
- result.update({
1792
- 'integrationType': 'ApiIntegration',
1793
- 'requestMethod': self.rq_method,
1794
- 'requestUrl': self.rq_url,
1795
- 'requestHeaders': self.rq_headers,
1796
- 'requestBody': self.rq_body,
1797
- 'requestEmptySearch': self.rq_empty_search,
1798
- 'responseListField': self.rs_list_field,
1799
- 'responseItemId': self.rs_item_id,
1800
- 'responseItemTemplate': self.rs_item_template,
1801
- })
1802
- return result
1803
-
1804
- @classmethod
1805
- def from_dict(cls, data: dict) -> 'AddApiIntegrationEvent':
1806
- if data['eventType'] != 'AddIntegrationEvent':
1807
- raise ValueError('Event of incorrect type (expect AddIntegrationEvent)')
1808
- if data['integrationType'] != 'ApiIntegration':
1809
- raise ValueError('Event of incorrect type (expect ApiIntegration)')
1810
- return AddApiIntegrationEvent(
1811
- event_uuid=data['uuid'],
1812
- entity_uuid=data['entityUuid'],
1813
- parent_uuid=data['parentUuid'],
1814
- created_at=data['createdAt'],
1815
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
1816
- integration_id=data['id'],
1817
- name=data['name'],
1818
- props=data['props'],
1819
- logo=data['logo'],
1820
- item_url=data['itemUrl'],
1821
- rq_method=data['requestMethod'],
1822
- rq_url=data['requestUrl'],
1823
- rq_headers=data['requestHeaders'],
1824
- rq_body=data['requestBody'],
1825
- rq_empty_search=data['requestEmptySearch'],
1826
- rs_list_field=data['responseListField'],
1827
- rs_item_id=data['responseItemId'],
1828
- rs_item_template=data['responseItemTemplate'],
1829
- )
1830
-
1831
-
1832
- class AddWidgetIntegrationEvent(AddIntegrationEvent):
1833
-
1834
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1835
- created_at: str, annotations: list[MapEntry],
1836
- integration_id: str, name: str, props: list[str], logo: str | None,
1837
- item_url: str | None, widget_url: str):
1838
- super().__init__(
1839
- event_uuid=event_uuid,
1840
- entity_uuid=entity_uuid,
1841
- parent_uuid=parent_uuid,
1842
- created_at=created_at,
1843
- annotations=annotations,
1844
- integration_id=integration_id,
1845
- name=name,
1846
- props=props,
1847
- logo=logo,
1848
- item_url=item_url
1849
- )
1850
- self.widget_url = widget_url
1851
-
1852
- def to_dict(self) -> dict:
1853
- result = super().to_dict()
1854
- result.update({
1855
- 'integrationType': 'WidgetIntegration',
1856
- 'widgetUrl': self.widget_url,
1857
- })
1858
- return result
1859
-
1860
- @classmethod
1861
- def from_dict(cls, data: dict) -> 'AddWidgetIntegrationEvent':
1862
- if data['eventType'] != 'AddIntegrationEvent':
1863
- raise ValueError('Event of incorrect type (expect AddIntegrationEvent)')
1864
- if data['integrationType'] != 'WidgetIntegration':
1865
- raise ValueError('Event of incorrect type (expect WidgetIntegration)')
1866
- return AddWidgetIntegrationEvent(
1867
- event_uuid=data['uuid'],
1868
- entity_uuid=data['entityUuid'],
1869
- parent_uuid=data['parentUuid'],
1870
- created_at=data['createdAt'],
1871
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
1872
- integration_id=data['id'],
1873
- name=data['name'],
1874
- props=data['props'],
1875
- logo=data['logo'],
1876
- item_url=data['itemUrl'],
1877
- widget_url=data['widgetUrl'],
1878
- )
1879
-
1880
-
1881
- @event_class
1882
- class EditIntegrationEvent(_KMEditEvent, abc.ABC):
1883
-
1884
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1885
- created_at: str, annotations: EventField[list[MapEntry]],
1886
- integration_id: EventField[str], name: EventField[str],
1887
- props: EventField[list[str]], logo: EventField[str | None],
1888
- item_url: EventField[str | None]):
1889
- super().__init__(
1890
- event_uuid=event_uuid,
1891
- entity_uuid=entity_uuid,
1892
- parent_uuid=parent_uuid,
1893
- created_at=created_at,
1894
- annotations=annotations,
1895
- )
1896
- self.integration_id = integration_id
1897
- self.name = name
1898
- self.props = props
1899
- self.logo = logo
1900
- self.item_url = item_url
1901
-
1902
- def to_dict(self) -> dict:
1903
- result = super().to_dict()
1904
- result.update({
1905
- 'eventType': 'EditIntegrationEvent',
1906
- 'id': self.integration_id.to_dict(),
1907
- 'name': self.name.to_dict(),
1908
- 'props': self.props.to_dict(),
1909
- 'logo': self.logo.to_dict(),
1910
- 'itemUrl': self.item_url.to_dict(),
1911
- })
1912
- return result
1913
-
1914
- @classmethod
1915
- def from_dict(cls, data: dict) -> 'EditIntegrationEvent':
1916
- if data['eventType'] != cls.__name__:
1917
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
1918
- integration_type = data['integrationType']
1919
- if integration_type == 'ApiIntegration':
1920
- return EditApiIntegrationEvent.from_dict(data)
1921
- if integration_type == 'WidgetIntegration':
1922
- return EditWidgetIntegrationEvent.from_dict(data)
1923
- raise ValueError(f'Unknown integration type "{integration_type}"')
1924
-
1925
-
1926
- class EditApiIntegrationEvent(EditIntegrationEvent):
1927
-
1928
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
1929
- created_at: str, annotations: EventField[list[MapEntry]],
1930
- integration_id: EventField[str], name: EventField[str],
1931
- props: EventField[list[str]], logo: EventField[str | None],
1932
- item_url: EventField[str | None], rq_method: EventField[str],
1933
- rq_url: EventField[str], rq_headers: EventField[list[MapEntry]],
1934
- rq_body: EventField[str], rq_empty_search: EventField[bool],
1935
- rs_list_field: EventField[str | None], rs_item_id: EventField[str | None],
1936
- rs_item_template: EventField[str]):
1937
- super().__init__(
1938
- event_uuid=event_uuid,
1939
- entity_uuid=entity_uuid,
1940
- parent_uuid=parent_uuid,
1941
- created_at=created_at,
1942
- annotations=annotations,
1943
- integration_id=integration_id,
1944
- name=name,
1945
- props=props,
1946
- logo=logo,
1947
- item_url=item_url
1948
- )
1949
- self.rq_method = rq_method
1950
- self.rq_url = rq_url
1951
- self.rq_headers = rq_headers
1952
- self.rq_body = rq_body
1953
- self.rq_empty_search = rq_empty_search
1954
- self.rs_list_field = rs_list_field
1955
- self.rs_item_id = rs_item_id
1956
- self.rs_item_template = rs_item_template
1957
-
1958
- def to_dict(self) -> dict:
1959
- result = super().to_dict()
1960
- result.update({
1961
- 'integrationType': 'ApiIntegration',
1962
- 'requestMethod': self.rq_method.to_dict(),
1963
- 'requestUrl': self.rq_url.to_dict(),
1964
- 'requestHeaders': self.rq_headers.to_dict(),
1965
- 'requestBody': self.rq_body.to_dict(),
1966
- 'requestEmptySearch': self.rq_empty_search.to_dict(),
1967
- 'responseListField': self.rs_list_field.to_dict(),
1968
- 'responseItemId': self.rs_item_id.to_dict(),
1969
- 'responseItemTemplate': self.rs_item_template.to_dict(),
1970
- })
1971
- return result
1972
-
1973
- @classmethod
1974
- def from_dict(cls, data: dict) -> 'EditApiIntegrationEvent':
1975
- if data['eventType'] != 'EditIntegrationEvent':
1976
- raise ValueError('Event of incorrect type (expect EditIntegrationEvent)')
1977
- if data['integrationType'] != 'ApiIntegration':
1978
- raise ValueError('Event of incorrect type (expect ApiIntegration)')
1979
- return EditApiIntegrationEvent(
1980
- event_uuid=data['uuid'],
1981
- entity_uuid=data['entityUuid'],
1982
- parent_uuid=data['parentUuid'],
1983
- created_at=data['createdAt'],
1984
- annotations=EventField.from_dict(
1985
- data=data['annotations'],
1986
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
1987
- ),
1988
- integration_id=EventField.from_dict(data['id']),
1989
- name=EventField.from_dict(data['name']),
1990
- props=EventField.from_dict(data['props']),
1991
- logo=EventField.from_dict(data['logo']),
1992
- item_url=EventField.from_dict(data['itemUrl']),
1993
- rq_method=EventField.from_dict(data['requestMethod']),
1994
- rq_url=EventField.from_dict(data['requestUrl']),
1995
- rq_headers=EventField.from_dict(
1996
- data=data['requestHeaders'],
1997
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
1998
- ),
1999
- rq_body=EventField.from_dict(data['requestBody']),
2000
- rq_empty_search=EventField.from_dict(data['requestEmptySearch']),
2001
- rs_list_field=EventField.from_dict(data['responseListField']),
2002
- rs_item_id=EventField.from_dict(data['responseItemId']),
2003
- rs_item_template=EventField.from_dict(data['responseItemTemplate']),
2004
- )
2005
-
2006
-
2007
- class EditWidgetIntegrationEvent(EditIntegrationEvent):
2008
-
2009
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
2010
- created_at: str, annotations: EventField[list[MapEntry]],
2011
- integration_id: EventField[str], name: EventField[str],
2012
- props: EventField[list[str]], logo: EventField[str | None],
2013
- item_url: EventField[str | None], widget_url: EventField[str]):
2014
- super().__init__(
2015
- event_uuid=event_uuid,
2016
- entity_uuid=entity_uuid,
2017
- parent_uuid=parent_uuid,
2018
- created_at=created_at,
2019
- annotations=annotations,
2020
- integration_id=integration_id,
2021
- name=name,
2022
- props=props,
2023
- logo=logo,
2024
- item_url=item_url
2025
- )
2026
- self.widget_url = widget_url
2027
-
2028
- def to_dict(self) -> dict:
2029
- result = super().to_dict()
2030
- result.update({
2031
- 'integrationType': 'WidgetIntegration',
2032
- 'widgetUrl': self.widget_url.to_dict(),
2033
- })
2034
- return result
2035
-
2036
- @classmethod
2037
- def from_dict(cls, data: dict) -> 'EditWidgetIntegrationEvent':
2038
- if data['eventType'] != 'EditIntegrationEvent':
2039
- raise ValueError('Event of incorrect type (expect EditIntegrationEvent)')
2040
- if data['integrationType'] != 'WidgetIntegration':
2041
- raise ValueError('Event of incorrect type (expect WidgetIntegration)')
2042
- return EditWidgetIntegrationEvent(
2043
- event_uuid=data['uuid'],
2044
- entity_uuid=data['entityUuid'],
2045
- parent_uuid=data['parentUuid'],
2046
- created_at=data['createdAt'],
2047
- annotations=EventField.from_dict(
2048
- data=data['annotations'],
2049
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
2050
- ),
2051
- integration_id=EventField.from_dict(data['id']),
2052
- name=EventField.from_dict(data['name']),
2053
- props=EventField.from_dict(data['props']),
2054
- logo=EventField.from_dict(data['logo']),
2055
- item_url=EventField.from_dict(data['itemUrl']),
2056
- widget_url=EventField.from_dict(data['widgetUrl']),
2057
- )
2058
-
2059
-
2060
- @event_class
2061
- class DeleteIntegrationEvent(_KMDeleteEvent):
2062
-
2063
- def to_dict(self) -> dict:
2064
- result = super().to_dict()
2065
- result.update({
2066
- 'eventType': type(self).__name__,
2067
- })
2068
- return result
2069
-
2070
- @classmethod
2071
- def from_dict(cls, data: dict) -> 'DeleteIntegrationEvent':
2072
- if data['eventType'] != cls.__name__:
2073
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
2074
- return DeleteIntegrationEvent(
2075
- event_uuid=data['uuid'],
2076
- entity_uuid=data['entityUuid'],
2077
- parent_uuid=data['parentUuid'],
2078
- created_at=data['createdAt'],
2079
- )
2080
-
2081
-
2082
- @event_class
2083
- class AddMetricEvent(_KMAddEvent):
2084
-
2085
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
2086
- created_at: str, annotations: list[MapEntry],
2087
- title: str, abbreviation: str | None, description: str | None):
2088
- super().__init__(
2089
- event_uuid=event_uuid,
2090
- entity_uuid=entity_uuid,
2091
- parent_uuid=parent_uuid,
2092
- created_at=created_at,
2093
- annotations=annotations,
2094
- )
2095
- self.title = title
2096
- self.abbreviation = abbreviation
2097
- self.description = description
2098
-
2099
- def to_dict(self) -> dict:
2100
- result = super().to_dict()
2101
- result.update({
2102
- 'eventType': type(self).__name__,
2103
- 'title': self.title,
2104
- 'abbreviation': self.abbreviation,
2105
- 'description': self.description,
2106
- })
2107
- return result
2108
-
2109
- @classmethod
2110
- def from_dict(cls, data: dict) -> 'AddMetricEvent':
2111
- if data['eventType'] != cls.__name__:
2112
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
2113
- return AddMetricEvent(
2114
- event_uuid=data['uuid'],
2115
- entity_uuid=data['entityUuid'],
2116
- parent_uuid=data['parentUuid'],
2117
- created_at=data['createdAt'],
2118
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
2119
- title=data['title'],
2120
- abbreviation=data['abbreviation'],
2121
- description=data['description'],
2122
- )
2123
-
2124
-
2125
- @event_class
2126
- class EditMetricEvent(_KMEditEvent):
2127
-
2128
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
2129
- created_at: str, annotations: EventField[list[MapEntry]],
2130
- title: EventField[str], abbreviation: EventField[str | None],
2131
- description: EventField[str | None]):
2132
- super().__init__(
2133
- event_uuid=event_uuid,
2134
- entity_uuid=entity_uuid,
2135
- parent_uuid=parent_uuid,
2136
- created_at=created_at,
2137
- annotations=annotations,
2138
- )
2139
- self.title = title
2140
- self.abbreviation = abbreviation
2141
- self.description = description
2142
-
2143
- def to_dict(self) -> dict:
2144
- result = super().to_dict()
2145
- result.update({
2146
- 'eventType': type(self).__name__,
2147
- 'title': self.title.to_dict(),
2148
- 'abbreviation': self.abbreviation.to_dict(),
2149
- 'description': self.description.to_dict(),
2150
- })
2151
- return result
2152
-
2153
- @classmethod
2154
- def from_dict(cls, data: dict) -> 'EditMetricEvent':
2155
- if data['eventType'] != cls.__name__:
2156
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
2157
- return EditMetricEvent(
2158
- event_uuid=data['uuid'],
2159
- entity_uuid=data['entityUuid'],
2160
- parent_uuid=data['parentUuid'],
2161
- created_at=data['createdAt'],
2162
- annotations=EventField.from_dict(
2163
- data=data['annotations'],
2164
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
2165
- ),
2166
- title=EventField.from_dict(data['title']),
2167
- abbreviation=EventField.from_dict(data['abbreviation']),
2168
- description=EventField.from_dict(data['description']),
2169
- )
2170
-
2171
-
2172
- @event_class
2173
- class DeleteMetricEvent(_KMDeleteEvent):
2174
-
2175
- def to_dict(self) -> dict:
2176
- result = super().to_dict()
2177
- result.update({
2178
- 'eventType': type(self).__name__,
2179
- })
2180
- return result
2181
-
2182
- @classmethod
2183
- def from_dict(cls, data: dict) -> 'DeleteMetricEvent':
2184
- if data['eventType'] != cls.__name__:
2185
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
2186
- return DeleteMetricEvent(
2187
- event_uuid=data['uuid'],
2188
- entity_uuid=data['entityUuid'],
2189
- parent_uuid=data['parentUuid'],
2190
- created_at=data['createdAt'],
2191
- )
2192
-
2193
-
2194
- @event_class
2195
- class AddPhaseEvent(_KMAddEvent):
2196
-
2197
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
2198
- created_at: str, annotations: list[MapEntry],
2199
- title: str, description: str | None):
2200
- super().__init__(
2201
- event_uuid=event_uuid,
2202
- entity_uuid=entity_uuid,
2203
- parent_uuid=parent_uuid,
2204
- created_at=created_at,
2205
- annotations=annotations,
2206
- )
2207
- self.title = title
2208
- self.description = description # why not text?
2209
-
2210
- def to_dict(self) -> dict:
2211
- result = super().to_dict()
2212
- result.update({
2213
- 'eventType': type(self).__name__,
2214
- 'title': self.title,
2215
- 'description': self.description,
2216
- })
2217
- return result
2218
-
2219
- @classmethod
2220
- def from_dict(cls, data: dict) -> 'AddPhaseEvent':
2221
- if data['eventType'] != cls.__name__:
2222
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
2223
- return AddPhaseEvent(
2224
- event_uuid=data['uuid'],
2225
- entity_uuid=data['entityUuid'],
2226
- parent_uuid=data['parentUuid'],
2227
- created_at=data['createdAt'],
2228
- annotations=[MapEntry.from_dict(x) for x in data['annotations']],
2229
- title=data['title'],
2230
- description=data['description'],
2231
- )
2232
-
2233
-
2234
- @event_class
2235
- class EditPhaseEvent(_KMEditEvent):
2236
-
2237
- def __init__(self, *, event_uuid: str, entity_uuid: str, parent_uuid: str,
2238
- created_at: str, annotations: EventField[list[MapEntry]],
2239
- title: EventField[str], description: EventField[str | None]):
2240
- super().__init__(
2241
- event_uuid=event_uuid,
2242
- entity_uuid=entity_uuid,
2243
- parent_uuid=parent_uuid,
2244
- created_at=created_at,
2245
- annotations=annotations,
2246
- )
2247
- self.title = title
2248
- self.description = description
2249
-
2250
- def to_dict(self) -> dict:
2251
- result = super().to_dict()
2252
- result.update({
2253
- 'eventType': type(self).__name__,
2254
- 'title': self.title.to_dict(),
2255
- 'description': self.description.to_dict(),
2256
- })
2257
- return result
2258
-
2259
- @classmethod
2260
- def from_dict(cls, data: dict) -> 'EditPhaseEvent':
2261
- if data['eventType'] != cls.__name__:
2262
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
2263
- return EditPhaseEvent(
2264
- event_uuid=data['uuid'],
2265
- entity_uuid=data['entityUuid'],
2266
- parent_uuid=data['parentUuid'],
2267
- created_at=data['createdAt'],
2268
- annotations=EventField.from_dict(
2269
- data=data['annotations'],
2270
- loader=lambda v: [MapEntry.from_dict(x) for x in v],
2271
- ),
2272
- title=EventField.from_dict(data['title']),
2273
- description=EventField.from_dict(data['description']),
2274
- )
2275
-
2276
-
2277
- @event_class
2278
- class DeletePhaseEvent(_KMDeleteEvent):
2279
-
2280
- def to_dict(self) -> dict:
2281
- result = super().to_dict()
2282
- result.update({
2283
- 'eventType': type(self).__name__,
2284
- })
2285
- return result
2286
-
2287
- @classmethod
2288
- def from_dict(cls, data: dict) -> 'DeletePhaseEvent':
2289
- if data['eventType'] != cls.__name__:
2290
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
2291
- return DeletePhaseEvent(
2292
- event_uuid=data['uuid'],
2293
- entity_uuid=data['entityUuid'],
2294
- parent_uuid=data['parentUuid'],
2295
- created_at=data['createdAt'],
2296
- )
2297
-
2298
-
2299
- @event_class
2300
- class MoveQuestionEvent(_KMMoveEvent):
2301
-
2302
- def to_dict(self) -> dict:
2303
- result = super().to_dict()
2304
- result.update({
2305
- 'eventType': type(self).__name__,
2306
- })
2307
- return result
2308
-
2309
- @classmethod
2310
- def from_dict(cls, data: dict) -> 'MoveQuestionEvent':
2311
- if data['eventType'] != cls.__name__:
2312
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
2313
- return MoveQuestionEvent(
2314
- event_uuid=data['uuid'],
2315
- entity_uuid=data['entityUuid'],
2316
- parent_uuid=data['parentUuid'],
2317
- target_uuid=data['targetUuid'],
2318
- created_at=data['createdAt'],
2319
- )
2320
-
2321
-
2322
- @event_class
2323
- class MoveAnswerEvent(_KMMoveEvent):
2324
-
2325
- def to_dict(self) -> dict:
2326
- result = super().to_dict()
2327
- result.update({
2328
- 'eventType': type(self).__name__,
2329
- })
2330
- return result
2331
-
2332
- @classmethod
2333
- def from_dict(cls, data: dict) -> 'MoveAnswerEvent':
2334
- if data['eventType'] != cls.__name__:
2335
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
2336
- return MoveAnswerEvent(
2337
- event_uuid=data['uuid'],
2338
- entity_uuid=data['entityUuid'],
2339
- parent_uuid=data['parentUuid'],
2340
- target_uuid=data['targetUuid'],
2341
- created_at=data['createdAt'],
2342
- )
2343
-
2344
-
2345
- @event_class
2346
- class MoveChoiceEvent(_KMMoveEvent):
2347
-
2348
- def to_dict(self) -> dict:
2349
- result = super().to_dict()
2350
- result.update({
2351
- 'eventType': type(self).__name__,
2352
- })
2353
- return result
2354
-
2355
- @classmethod
2356
- def from_dict(cls, data: dict) -> 'MoveChoiceEvent':
2357
- if data['eventType'] != cls.__name__:
2358
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
2359
- return MoveChoiceEvent(
2360
- event_uuid=data['uuid'],
2361
- entity_uuid=data['entityUuid'],
2362
- parent_uuid=data['parentUuid'],
2363
- target_uuid=data['targetUuid'],
2364
- created_at=data['createdAt'],
2365
- )
2366
-
2367
-
2368
- @event_class
2369
- class MoveExpertEvent(_KMMoveEvent):
2370
-
2371
- def to_dict(self) -> dict:
2372
- result = super().to_dict()
2373
- result.update({
2374
- 'eventType': type(self).__name__,
2375
- })
2376
- return result
2377
-
2378
- @classmethod
2379
- def from_dict(cls, data: dict) -> 'MoveExpertEvent':
2380
- if data['eventType'] != cls.__name__:
2381
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
2382
- return MoveExpertEvent(
2383
- event_uuid=data['uuid'],
2384
- entity_uuid=data['entityUuid'],
2385
- parent_uuid=data['parentUuid'],
2386
- target_uuid=data['targetUuid'],
2387
- created_at=data['createdAt'],
2388
- )
2389
-
2390
-
2391
- @event_class
2392
- class MoveReferenceEvent(_KMMoveEvent):
2393
-
2394
- def to_dict(self) -> dict:
2395
- result = super().to_dict()
2396
- result.update({
2397
- 'eventType': type(self).__name__,
2398
- })
2399
- return result
2400
-
2401
- @classmethod
2402
- def from_dict(cls, data: dict) -> 'MoveReferenceEvent':
2403
- if data['eventType'] != cls.__name__:
2404
- raise ValueError(f'Event of incorrect type (expect {cls.__name__})')
2405
- return MoveReferenceEvent(
2406
- event_uuid=data['uuid'],
2407
- entity_uuid=data['entityUuid'],
2408
- parent_uuid=data['parentUuid'],
2409
- target_uuid=data['targetUuid'],
2410
- created_at=data['createdAt'],
2411
- )
2412
-
2413
-
2414
- class Event:
2415
-
2416
- @classmethod
2417
- def from_dict(cls, data: dict):
2418
- event_type = data['eventType']
2419
- if event_type not in EVENT_TYPES:
2420
- raise ValueError(f'Unknown event type: {event_type}')
2421
- t = EVENT_TYPES[event_type]
2422
- if not hasattr(t, 'from_dict'):
2423
- raise ValueError(f'Type {event_type} cannot be used for deserialization')
2424
- return t.from_dict(data)