{{% if target_oval_version >= [5, 11] %}}
<def-group>
  <definition class="compliance" id="{{{ _RULE_ID }}}" version="1">
    {{% call oval_metadata("In the YAML/JSON file '" + FILEPATH + "' at path '" + YAMLPATH + "' " + (ENTITY_CHECK if ENTITY_CHECK else "all") + ": ") %}}
      {{%- for val in VALUES -%}}
        {{{- "key '" + key + "' " if key in val else "" }}}value{{{ (" of type '" + val.type + "' ") if type in val else " " }}}
          {{{- val.operation if operation in val else "equals" }}} '{{{ val.value }}}'{{% if not loop.last %}} and{{% endif %}}
      {{%- endfor -%}}
    {{%- endcall -%}}
    <criteria>
        <criterion {{{ {'comment': "In the YAML/JSON file '" + FILEPATH + "' at path '" + YAMLPATH + "' " + (ENTITY_CHECK if ENTITY_CHECK else "all")}|xmlattr }}} test_ref="test_{{{ rule_id }}}"/>
        {{% if OCP_DATA %}}
        <criterion comment="Make sure that the file '{{{ FILEPATH }}}' exists." test_ref="test_file_for_{{{ rule_id }}}"/>
        {{% endif %}}
    </criteria>
  </definition>

  <local_variable id="{{{ rule_id }}}_file_location" datatype="string" comment="The actual path of the file to scan." version="1">
      {{% if OCP_DATA %}}
      <concat>
        <variable_component var_ref="ocp_data_root"/>
        <literal_component>{{{ FILEPATH }}}</literal_component>
      </concat>
      {{% else %}}
      <literal_component>{{{ FILEPATH }}}</literal_component>
      {{% endif %}}
  </local_variable>

  <ind:yamlfilecontent_test id="test_{{{ rule_id }}}" check="all" check_existence="{{{ CHECK_EXISTENCE|default("only_one_exists") }}}" 
    {{{ {'comment': "In the file '" + FILEPATH + "' find only one object at path '" + YAMLPATH + "'."}|xmlattr }}} version="1">
    <ind:object object_ref="object_{{{ rule_id }}}"/>
    <ind:state state_ref="state_{{{ rule_id }}}"/>
  </ind:yamlfilecontent_test>

  {{% if OCP_DATA %}}
  <unix:file_test id="test_file_for_{{{ rule_id }}}" check="all" check_existence="only_one_exists"
    comment="Find the file to be checked ('{{{ FILEPATH }}}')." version="1">
    <unix:object object_ref="object_file_for_{{{ rule_id }}}"/>
  </unix:file_test>
  {{% endif %}}

  <unix:file_object id="object_file_for_{{{ rule_id }}}" version="1">
    <unix:filepath var_ref="{{{ rule_id }}}_file_location"/>
  </unix:file_object>

  <ind:yamlfilecontent_object id="object_{{{ rule_id }}}" version="1">
    <ind:filepath var_ref="{{{ rule_id }}}_file_location"/>
    <ind:yamlpath>{{{ YAMLPATH }}}</ind:yamlpath>
  </ind:yamlfilecontent_object>

  <ind:yamlfilecontent_state id="state_{{{ rule_id }}}" version="1">
    <ind:value datatype="record"{{% if ENTITY_CHECK %}} entity_check="{{{ ENTITY_CHECK }}}"{{% endif %}}>
      {{% for val in VALUES %}}
      <field {{{ {'name': key if key in val else "#", 'datatype': val.type,  'operation':  val.operation}|xmlattr }}}>{{{ val.value }}}</field>
      {{% endfor %}}
    </ind:value>
  </ind:yamlfilecontent_state>

  {{% if OCP_DATA %}}
  <external_variable comment="Root of OCP data dump" datatype="string" id="ocp_data_root" version="1" />
  {{% endif %}}

</def-group>
{{% endif %}}
