|
18 | 18 |
|
19 | 19 | from .config import CUSTOM_RULES_DIR, parse_rules_config
|
20 | 20 | from .custom_schemas import get_custom_schemas
|
| 21 | +from .integrations import load_integrations_schemas |
21 | 22 | from .utils import (DateTimeEncoder, cached, get_etc_path, gzip_compress,
|
22 | 23 | load_etc_dump, read_gzip, unzip)
|
23 | 24 |
|
@@ -150,6 +151,31 @@ def flatten(schema):
|
150 | 151 | return flattened
|
151 | 152 |
|
152 | 153 |
|
| 154 | +@cached |
| 155 | +def get_all_flattened_schema() -> dict: |
| 156 | + """Load all schemas into a flattened dictionary.""" |
| 157 | + all_flattened_schema = {} |
| 158 | + for _, schema in get_non_ecs_schema().items(): |
| 159 | + all_flattened_schema.update(flatten(schema)) |
| 160 | + |
| 161 | + ecs_schemas = get_schemas() |
| 162 | + for version in ecs_schemas: |
| 163 | + for index, info in ecs_schemas[version]["ecs_flat"].items(): |
| 164 | + all_flattened_schema.update({index: info["type"]}) |
| 165 | + |
| 166 | + for _, integration_schema in load_integrations_schemas().items(): |
| 167 | + for index, index_schema in integration_schema.items(): |
| 168 | + # Detect if ML integration |
| 169 | + if "jobs" in index_schema: |
| 170 | + ml_schemas = {k: v for k, v in index_schema.items() if k != "jobs"} |
| 171 | + for _, ml_schema in ml_schemas.items(): |
| 172 | + all_flattened_schema.update(flatten(ml_schema)) |
| 173 | + else: |
| 174 | + all_flattened_schema.update(flatten(index_schema)) |
| 175 | + |
| 176 | + return all_flattened_schema |
| 177 | + |
| 178 | + |
153 | 179 | @cached
|
154 | 180 | def get_non_ecs_schema():
|
155 | 181 | """Load non-ecs schema."""
|
|
0 commit comments