Esempio n. 1
0
def generate_nested_fields(fields):
    '''Generate ecs_nested.yml'''
    nested = {}
    # Flatten each field set, but keep all resulting fields nested under their
    # parent/host field set.
    for (name, details) in fields.items():
        fieldset_details = {
            **copy.deepcopy(details['field_details']),
            **copy.deepcopy(details['schema_details'])
        }

        fieldset_details.pop('node_name')
        if 'reusable' in fieldset_details:
            fieldset_details['reusable'].pop('order')

        # TODO Temporarily removed to simplify initial rewrite review
        fieldset_details.pop('dashed_name')
        fieldset_details.pop('flat_name')
        if False == fieldset_details['root']:
            fieldset_details.pop('root')

        fieldset_fields = {}
        visitor.visit_fields_with_memo(details['fields'], accumulate_field,
                                       fieldset_fields)
        fieldset_details['fields'] = fieldset_fields

        nested[name] = fieldset_details
    return nested
Esempio n. 2
0
def generate_flat_fields(fields):
    '''Generate ecs_flat.yml'''
    filtered = remove_non_root_reusables(fields)
    flattened = {}
    visitor.visit_fields_with_memo(filtered, accumulate_field, flattened)
    return flattened
Esempio n. 3
0
def generate_flat_fields(fields: Dict[str, FieldEntry]) -> Dict[str, Field]:
    """Generate ecs_flat.yml"""
    filtered: Dict[str, FieldEntry] = remove_non_root_reusables(fields)
    flattened: Dict[str, Field] = {}
    visitor.visit_fields_with_memo(filtered, accumulate_field, flattened)
    return flattened