Request Identifiers for Configuration Objects of a Specific Type Using the Junos XML Protocol
In a Junos XML protocol session with a device running
Junos OS, to request output that shows only the identifier for each
configuration object of a specific type in a hierarchy, a client application
emits a <get-configuration> tag element
that encloses the tag elements representing all levels of the configuration
hierarchy from the root (represented by the <configuration> tag element) down to the immediate parent level for the object type.
An empty tag represents the requested object type, and the recurse="false" attribute is included. The entire request
is enclosed in an <rpc> tag element.
To request the identifier for all objects of a specified type,
the client application includes only the recurse="false" attribute:
<rpc>
<get-configuration>
<configuration>
<!-- opening tags for each parent of the object type -->
<object-type recurse="false"/>
<!-- closing tags for each parent of the object type -->
</configuration>
</get-configuration>
</rpc>To request the identifier for a specified number of objects,
the client application combines the recurse="false" attribute with the count and start attributes discussed in Requesting a Specific Number of Configuration Objects Using the Junos
XML Protocol:
<rpc>
<get-configuration>
<configuration>
<!-- opening tags for each parent of the object type -->
<object-type recurse="false" count="count" start="index"/>
<!-- closing tags for each parent of the object type -->
</configuration>
</get-configuration>
</rpc>When the application requests Junos XML-tagged output
(the default), the Junos XML protocol server returns the requested
objects in <configuration> and <rpc-reply> tag elements. If the application has
requested a specified number of objects, the junos:position and junos:total attributes are included
in the opening tag for each object, as described in Requesting a Specific Number of Configuration Objects
Using the Junos XML Protocol.
In the following example output, the identifier tag element
is called <name>. (For information about
the attributes in the opening <configuration> tag, see Specifying the Source for Configuration
Information Requests in a Junos XML Protocol Session.)
<rpc-reply xmlns:junos="URL">
<configuration attributes>
<!-- opening tags for each parent of the object type -->
<first-object [junos:position="index1" junos:total="total"]>
<name>identifier-for-first-object</name>
</first-object>
<second-object [junos:position="index2" junos:total="total"]>
<name>identifier-for-second-object</name>
</second-object>
<!-- additional instances of the object -->
<!-- closing tags for each parent of the object type -->
</configuration>
</rpc-reply>The junos:position and junos:total attributes do not appear if the client
requests formatted ASCII output by including the format="text" attribute or if the client requests JSON-formatted output by including
the format="json" attribute in the <get-configuration> tag element (as described in Specifying the Output Format for Configuration Data
in a Junos XML Protocol Session).
To specify the source of the output (candidate or active configuration),
the application can include attributes in the opening <get-configuration> tag, its opening <junoscript> tag, or both. For more information,
see Specifying the Source for Configuration
Information Requests in a Junos XML Protocol Session.
The application can also request additional configuration elements
of the same or other types by including the appropriate tag elements
in the same <get-configuration> tag
element. For more information, see Requesting
Multiple Configuration Elements Using the Junos XML Protocol.
The following example shows how to request the identifier for
each interface configured at the [edit interfaces] hierarchy level. The output is from the candidate configuration
and is tagged with Junos XML tag elements (the default).