- Using the CLI Template Configuration API end point to get template IDs based on tag.
- The behaviour seems to be inconsistent. Got a bunch of templates with the tag ZEN and as shown below, doing a query with tags=ZEN get back a list of template IDs:
curl -u carls-username https://myprimeserver.example.com/webacs/api/v2/data/CliTemplate?tags=ZEN
Enter host password for user 'carls-username':
<?xml version="1.0" ?>
<queryResponse last="14" first="0" count="15" type="CliTemplate" responseType="listEntityIds" requestUrl="https://myprimeserver.example.com/webacs/api/v2/data/CliTemplate?tags=ZEN" rootUrl="https://myprimeserver.example.com/webacs/api/v2/data">
<entityId type="CliTemplate" url="https://myprimeserver.example.com/webacs/api/v2/data/CliTemplate/664668">664668</entityId>
<==== Logs Removed =====>
</queryResponse>
If you select the last template ID above for a closer look you can see that you have also added an additional tag of CARLSTAG so it has both ZEN and CARLSTAG:
$ curl -u carls-username https://myprimeserver.example.com/webacs/api/v2/data/CliTemplate/16716703
Enter host password for user 'carls-username':
<?xml version="1.0" ?>
<queryResponse type="CliTemplate" responseType="getEntity" requestUrl="https://myprimeserver.example.com/webacs/api/v2/data/CliTemplate/16716703" rootUrl="https://myprimeserver.example.com/webacs/api/v2/data">
<entity dtoType="cliTemplateDTO" type="CliTemplate" url="https://myprimeserver.example.com/webacs/api/v2/data/CliTemplate/16716703">
<cliTemplateDTO displayName="16716703" id="16716703">
<author>the.author</author>
<content>### Content removed as it's not relevant</content>
<createdOn>2016-09-28T10:20:37.230+01:00</createdOn>
<deployCount>0</deployCount>
<description>Example Template Commands</description>
<deviceType>Routers</deviceType>
<name>ZEN-TEMPLATE-HELP</name>
<path>My Templates/Provisioning Templates</path>
<tags>CARLSTAG,ZEN</tags>
<templateId>16716703</templateId>
<variables>
<variable>
<defaultValue>10000</defaultValue>
<description>Downstream BW in bps</description>
<displayLabel>bpsDown</displayLabel>
<name>bpsDown</name>
<required>false</required>
<type>String</type>
</variable>
</variables>
</cliTemplateDTO>
</entity>
</queryResponse>
If you query for CARLSTAG specifically you get a response count of 0.
$ curl -u carls-username https://myprimeserver.example.com/webacs/api/v2/data/CliTemplate?tags=CARLSTAG
Enter host password for user 'carls-username':
<?xml version="1.0" ?>
<queryResponse count="0" type="CliTemplate" responseType="listEntityIds" requestUrl="https://myprimeserver.example.com/webacs/api/v2/data/CliTemplate?tags=CARLSTAG" rootUrl="https://myprimeserver.example.com/webacs/api/v2/data"></queryResponse>
The tags response parameter is of the type String. So when you filter with tags=CARLSTAG this is called literal filtering. So the API will look for templates where the tag field is, and only is, "CARLSTAG". In other words, this filters to those templates that exclusively have that tag.
Since you're trying to find templates that have the tag, but could have other tags, use the contains() expression. For example, tags=contains("CARLSTAG") will filter to all templates that have CARLSTAG, even if they have other tags.
Comments
0 comments
Please sign in to leave a comment.