Skip to content

Commit c499d85

Browse files
committed
classfilterdata(): added docs for object of arrays/objects
Ticket: CFE-4562 Signed-off-by: Lars Erik Wik <[email protected]>
1 parent f17f46a commit c499d85

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

content/reference/functions/classfilterdata.markdown

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@ If the `data_structure` argument is specified to be:
1616

1717
- `"array_of_arrays"`, the `data_container` argument is interpreted as an array
1818
of arrays, and the `key_or_index` argument is interpreted as an index within
19-
the children arrays.
19+
the children arrays. The `key_or_index` argument is required.
2020
- `"array_of_objects"`, the `data_container` argument is interpreted as an array
2121
of objects, and the `key_or_index` argument is interpreted as a key within the
22-
children objects.
22+
children objects. The `key_or_index` argument is required.
23+
- `"object_of_arrays"`, the `data_container` argument is interpreted as an object
24+
of arrays, and the `key_or_index` argument is interpreted as an index within
25+
the children arrays (if specified). If the `key_or_index` argument is omitted,
26+
the key of the child array itself is used as a class expression.
27+
- `"object_of_objects"`, the `data_container` argument is interpreted as an object
28+
if objects, and the `key_or_index` argument is interpreted as a key within the
29+
children objects (if specified). If the `key_or_index` argument is omitted, the
30+
key of the child object itself is used as a class expression.
2331
- `"auto"`, the interpretation is automatically detected based on the data
2432
structure.
2533

@@ -45,6 +53,46 @@ If the `data_structure` argument is specified to be:
4553

4654
{{< CFEngine_include_snippet(classfilterdata_array_of_objects.cf, #\+begin_src\s+example_output\s*, .*end_src) >}}
4755

56+
**Example (with object of arrays and endogenous key):**
57+
58+
**Policy:**
59+
60+
{{< CFEngine_include_snippet(classfilterdata_object_of_arrays_endogenous.cf, #\+begin_src cfengine3, .*end_src) >}}
61+
62+
**Output:**
63+
64+
{{< CFEngine_include_snippet(classfilterdata_object_of_arrays_endogenous.cf, #\+begin_src\s+example_output\s*, .*end_src) >}}
65+
66+
**Example (with object of objects and endogenous key):**
67+
68+
**Policy:**
69+
70+
{{< CFEngine_include_snippet(classfilterdata_object_of_objects_endogenous.cf, #\+begin_src cfengine3, .*end_src) >}}
71+
72+
**Output:**
73+
74+
{{< CFEngine_include_snippet(classfilterdata_object_of_objects_endogenous.cf, #\+begin_src\s+example_output\s*, .*end_src) >}}
75+
76+
**Example (with object of arrays and exogenous key):**
77+
78+
**Policy:**
79+
80+
{{< CFEngine_include_snippet(classfilterdata_object_of_arrays_exogenous.cf, #\+begin_src cfengine3, .*end_src) >}}
81+
82+
**Output:**
83+
84+
{{< CFEngine_include_snippet(classfilterdata_object_of_arrays_exogenous.cf, #\+begin_src\s+example_output\s*, .*end_src) >}}
85+
86+
**Example (with object of objects and exogenous key):**
87+
88+
**Policy:**
89+
90+
{{< CFEngine_include_snippet(classfilterdata_object_of_objects_exogenous.cf, #\+begin_src cfengine3, .*end_src) >}}
91+
92+
**Output:**
93+
94+
{{< CFEngine_include_snippet(classfilterdata_object_of_objects_exogenous.cf, #\+begin_src\s+example_output\s*, .*end_src) >}}
95+
4896
**Notes:**
4997

5098
This function can accept many types of data parameters _(See [collecting function][Functions#collecting functions])_.

0 commit comments

Comments
 (0)