1
1
# This file is a part of IntelOwl https://github.com/intelowlproject/IntelOwl
2
2
# See the file 'LICENSE' for copying permission.
3
+ import enum
3
4
import typing
4
5
from pathlib import PosixPath
5
6
@@ -19,6 +20,7 @@ class PythonModuleBasePaths(models.TextChoices):
19
20
Connector = PosixPath ("api_app.connectors_manager.connectors" ), "Connector"
20
21
Ingestor = PosixPath ("api_app.ingestors_manager.ingestors" ), "Ingestor"
21
22
Visualizer = PosixPath ("api_app.visualizers_manager.visualizers" ), "Visualizer"
23
+ Pivot = PosixPath ("api_app.pivots_manager.pivots" ), "Pivot"
22
24
23
25
24
26
class TLP (models .TextChoices ):
@@ -55,33 +57,37 @@ class Status(models.TextChoices):
55
57
RUNNING = "running" , "running"
56
58
57
59
ANALYZERS_RUNNING = "analyzers_running" , "analyzers_running"
58
- CONNECTORS_RUNNING = "connectors_running" , "connectors_running"
59
- VISUALIZERS_RUNNING = "visualizers_running" , "visualizers_running"
60
-
61
60
ANALYZERS_COMPLETED = "analyzers_completed" , "analyzers_completed"
61
+
62
+ CONNECTORS_RUNNING = "connectors_running" , "connectors_running"
62
63
CONNECTORS_COMPLETED = "connectors_completed" , "connectors_completed"
64
+
65
+ PIVOTS_RUNNING = "pivots_running" , "pivots_running"
66
+ PIVOTS_COMPLETED = "pivots_completed" , "pivots_completed"
67
+
68
+ VISUALIZERS_RUNNING = "visualizers_running" , "visualizers_running"
63
69
VISUALIZERS_COMPLETED = "visualizers_completed" , "visualizers_completed"
64
70
65
71
REPORTED_WITHOUT_FAILS = "reported_without_fails" , "reported_without_fails"
66
72
REPORTED_WITH_FAILS = "reported_with_fails" , "reported_with_fails"
67
73
KILLED = "killed" , "killed"
68
74
FAILED = "failed" , "failed"
69
75
76
+ @classmethod
77
+ def get_enums_with_suffix (
78
+ cls , suffix : str
79
+ ) -> typing .Generator [enum .Enum , None , None ]:
80
+ for key in cls :
81
+ if key .name .endswith (suffix ):
82
+ yield key
83
+
70
84
@classmethod
71
85
def running_statuses (cls ) -> typing .List ["Status" ]:
72
- return [
73
- cls .ANALYZERS_RUNNING ,
74
- cls .CONNECTORS_RUNNING ,
75
- cls .VISUALIZERS_RUNNING ,
76
- ]
86
+ return list (cls .get_enums_with_suffix ("_RUNNING" ))
77
87
78
88
@classmethod
79
89
def partial_statuses (cls ) -> typing .List ["Status" ]:
80
- return [
81
- cls .ANALYZERS_COMPLETED ,
82
- cls .CONNECTORS_COMPLETED ,
83
- cls .VISUALIZERS_COMPLETED ,
84
- ]
90
+ return list (cls .get_enums_with_suffix ("_COMPLETED" ))
85
91
86
92
@classmethod
87
93
def final_statuses (cls ) -> typing .List ["Status" ]:
0 commit comments