Product SiteDocumentation Site

20.2. Parent Tags

A tag can contain a parent element, which creates a hierarchical link to a parent tag. The tags hierarchy is represented as a flat collection that decends from the root tag.

The root tag

The root tag is a special pseudo-tag assumed as the default tag if no parent tag is specified. The root tag cannot be deleted nor assigned a parent tag.
This tag hierarchy is expressed in the following way:
<tags>
    <tag id="-1" href="/rhevm-api/tags/-1">
        <name>root</name>
        <description>root</description>
        <parent>
            <tag id="-1" href="/rhevm-api/tags/-1"/>
        </parent>
    </tag>
    <tag id="f436ebfc-67f2-41bd-8ec6-902b6f7dcb5e"
      href="/rhevm-api/tags/f436ebfc-67f2-41bd-8ec6-902b6f7dcb5e">
        <name>Finance</name>
        <description>Resources for the Finance department</description>
        <parent>
            <tag id="-1" href="/rhevm-api/tags/-1"/>
        </parent>
    </tag>
    <tag id="ty38wobf-23n5-18we-v18j-5u8t348cs7rt"
      href="/rhevm-api/tags/ty38wobf-23n5-18we-v18j-5u8t348cs7rt">
        <name>Billing</name>
        <description>Billing Resources</description>
        <parent>
            <tag id="f436ebfc-67f2-41bd-8ec6-902b6f7dcb5e"
              href="/rhevm-api/tags/f436ebfc-67f2-41bd-8ec6-902b6f7dcb5e"/>
        </parent>
    </tag>
</tags>
POSTing a new tag with a parent element creates a link to a parent tag, using either the id= attribute in the tag element:
<tag>
    <name>Billing</name>
    <description>Billing Resources</description>
    <parent>
        <tag id="f436ebfc-67f2-41bd-8ec6-902b6f7dcb5et"/>
    </parent>
</tag>
Or using the name element:
<tag>
    <name>Billing</name>
    <description>Billing Resources</description>
    <parent>
        <tag>
            <name>Finance</name>
        </tag>
    </parent>
</tag>
A tag can change its parent using a PUT request:
PUT /rhevm-api/tags/ty38wobf-23n5-18we-v18j-5u8t348cs7rt HTTP/1.1
Accept: application/xml
Content-Type: application/xml

<tag>
    <parent>
        <tag id="f436ebfc-67f2-41bd-8ec6-902b6f7dcb5e"/>
    </parent>
</tag>