forked from elastic/ecs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
field_details.j2
172 lines (111 loc) · 4.1 KB
/
field_details.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
{# Title & Description
-#}
[[ecs-{{ fieldset['name'] }}]]
=== {{ fieldset['title'] }} Fields
{{ fieldset['description']|replace("\n", "\n\n") }}
{# Fieldset label beta header -#}
{% if fieldset['beta'] -%}
beta::[ {{ fieldset['beta'] }}]
{% endif -%}
{# Field Details Table Header -#}
[discrete]
==== {{ fieldset['title'] }} Field Details
[options="header"]
|=====
| Field | Description | Level
// ===============================================================
{# Iterate through each field in the set -#}
{% for field in sorted_fields -%}
{% if 'original_fieldset' not in field -%}
{# `Field` column -#}
|
[[field-{{field['dashed_name']}}]]
<<field-{{field['dashed_name']}}, {{ field['flat_name'] }}>>
{# `Description` column -#}
{#- Beta fields will add the `beta` label -#}
{% if field['beta'] -%}
a| beta:[ {{ field['beta'] }} ]
{{ field['description']|replace("\n", "\n\n") }}
{%- else -%}
a| {{ field['description']|replace("\n", "\n\n") }}
{%- endif %}
{#- iterate through each expected value -#}
{%- if field['expected_values'] %}
Expected values for this field:
{% for val in field['expected_values'] %}
* `{{ val }}`
{%- endfor %}{# for expected_values #}
{%- endif %}{# if 'expected_values' #}
type: {{ field['type'] }}
{% if 'multi_fields' in field -%}
Multi-fields:
{% for mf in field['multi_fields'] -%}
* {{ mf['flat_name'] }} (type: {{ mf ['type'] }})
{% endfor %}{# for mf #}
{% endif %}{# if 'multi_fields' #}
{% if 'array' in field['normalize'] -%}
Note: this field should contain an array of values.
{% endif %}
{% if 'allowed_values' in field %}
*Important*: The field value must be one of the following:
{{ field['allowed_value_names']|join(', ') }}
To learn more about when to use which value, visit the page
<<ecs-allowed-values-{{ field['dashed_name'] }},allowed values for {{ field['flat_name'] }}>>
{% elif 'example' in field -%}
example: `{{ field['example'] }}`
{%- endif %}{# if 'allowed_values' elif 'example' #}
{# `Level` column -#}
| {{ field['level'] }}
// ===============================================================
{% endif %}{# if 'original_fieldset' -#}
{% endfor %}{# for 'field' -#}
|=====
{# do we have `nestings` or `reusable` sections to worry about? -#}
{% if 'nestings' in fieldset or 'reusable' in fieldset -%}
[discrete]
==== Field Reuse
{% if 'reusable' in fieldset -%}
The `{{ fieldset['name'] }}` fields are expected to be nested at:
{% for entry in sorted_reuse_fields %}
* `{{ entry }}`
{% endfor %}
{% if 'top_level' in fieldset['reusable'] and fieldset['reusable']['top_level'] -%}
Note also that the `{{ fieldset['name'] }}` fields may be used directly at the root of the events.
{% else -%}
Note also that the `{{ fieldset['name'] }}` fields are not expected to be used directly at the root of the events.
{%- endif %}{# if 'top_level' -#}
{% endif %}{# if 'reusable' #}
{%- if 'nestings' in fieldset -%}
[[ecs-{{ fieldset['name'] }}-nestings]]
[discrete]
===== Field sets that can be nested under {{ fieldset['title'] }}
[options="header"]
|=====
| Location | Field Set | Description
// ===============================================================
{% for entry in render_nestings_reuse_section -%}
{#- Beta marker on nested fields -#}
| `{{ entry['flat_nesting'] }}`
| <<ecs-{{ entry['name'] }},{{ entry['name'] }}>>
{#- Beta marker on nested fields -#}
{%- if entry['beta'] -%}
| beta:[ {{ entry['beta'] }}]
{{ entry['short'] }}
{%- else %}
| {{ entry['short'] }}
{%- endif %}
{% if entry['normalize'] and 'array' in entry['normalize'] -%}
Note: this reuse should contain an array of {{ entry['name'] }} field set objects.
{% endif -%}
// ===============================================================
{% endfor -%}
|=====
{% endif %}{# if 'nestings' #}
{%- endif %}{# if 'nestings' or 'reusable' in fieldset #}
{%- if usage_doc %}
{# Field Usage Table Header -#}
[discrete]
==== {{ fieldset['title'] }} Field Usage
For usage and examples of the {{ fieldset['name'] }} fields, please see the <<ecs-{{ fieldset['name']|replace("_", "-") }}-usage, {{ fieldset['title'] }} Fields Usage and Examples>> section.
include::usage/{{ fieldset['name'] }}.asciidoc[]
{% endif %}