in scripts/schema/cleaner.py [0:0]
def schema_mandatory_attributes(schema: FieldEntry) -> None:
"""Ensures for the presence of the mandatory schema attributes and raises if any are missing"""
current_schema_attributes: List[str] = sorted(list(schema['field_details'].keys()) +
list(schema['schema_details'].keys()))
missing_attributes: List[str] = ecs_helpers.list_subtract(SCHEMA_MANDATORY_ATTRIBUTES, current_schema_attributes)
if len(missing_attributes) > 0:
msg = "Schema {} is missing the following mandatory attributes: {}.\nFound these: {}".format(
schema['field_details']['name'], ', '.join(missing_attributes), current_schema_attributes)
raise ValueError(msg)
if 'reusable' in schema['schema_details']:
reuse_attributes: List[str] = sorted(schema['schema_details']['reusable'].keys())
missing_reuse_attributes: List[str] = ecs_helpers.list_subtract(['expected', 'top_level'], reuse_attributes)
if len(missing_reuse_attributes) > 0:
msg = "Reusable schema {} is missing the following reuse attributes: {}.\nFound these: {}".format(
schema['field_details']['name'], ', '.join(missing_reuse_attributes), reuse_attributes)
raise ValueError(msg)