- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
WAPI: How can I list objects under a smart folder?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2023 04:12 PM
I can list all smartfolder using this
Re: WAPI: How can I list objects under a smart folder?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 03:31 PM
You will need to traverse the children of either a specific personal smart folder or a specific global smart folder.
If it is a "grouped by" smart folder, the first set of results will be the grouping children, and you will need to traverse those results to get the grandchild results, iterated through each level.
First get the smart folder you're looking for: (escaping the spaces)
curl -k -u admin:infoblox -X GET 'https://gm.example.com/wapi/v2.12/smartfolder:personal?name=Networks%20by%20Type'
returns:
[ { "_ref": "smartfolder:personal/Li5teV9wZXJzb25hbF9zbWFydF9mb2xkZXIkb25lLnBlcnNvbmFsX3NtYXJ0X2ZvbGRlciQuY29tLmluZm9ibG94Lm9uZS5hZG1pbiRhZG1pbi5OZXR3b3JrcyBieSBUeXBl:Networks%20by%20Type/false", "is_shortcut": false, "name": "Networks by Type" } ]
Now ask for the children of one of those smart folder children:
curl -k -u admin:infoblox -X GET 'https://gm.example.com/wapi/v2.12/smartfolder:children?smart_folder=smartfolder:personal/Li5teV9wZXJzb25hbF9zbWFydF9mb2xkZXIkb25lLnBlcnNvbmFsX3NtYXJ0X2ZvbGRlciQuY29tLmluZm9ibG94Lm9uZS5hZG1pbiRhZG1pbi5OZXR3b3JrcyBieSBUeXBl:Networks%20by%20Type/false&_return_fields%2b=value'
which returns two values in this lab grid: ("Management" and "Data Center")
[ { "_ref": "smartfolder:children/Li5zbWFydF9mb2xkZXJfY2hpbGRyZW4kRGF0YSBDZW50ZXIJLi5teV9wZXJzb25hbF9zbWFydF9mb2xkZXIkb25lLnBlcnNvbmFsX3NtYXJ0X2ZvbGRlciQuY29tLmluZm9ibG94Lm9uZS5hZG1pbiRhZG1pbi5OZXR3b3JrcyBieSBUeXBl:children", "value": { "value_string": "Data Center" }, "value_type": "ENUM" }, { "_ref": "smartfolder:children/Li5zbWFydF9mb2xkZXJfY2hpbGRyZW4kTWFuYWdlbWVudAkuLm15X3BlcnNvbmFsX3NtYXJ0X2ZvbGRlciRvbmUucGVyc29uYWxfc21hcnRfZm9sZGVyJC5jb20uaW5mb2Jsb3gub25lLmFkbWluJGFkbWluLk5ldHdvcmtzIGJ5IFR5cGU:children", "value": { "value_string": "Management" }, "value_type": "ENUM" } ]
Now ask for the children within the "Data Center" grouping:
curl -k -u admin:infoblox -X GET 'https://gm.example.com/wapi/v2.12/smartfolder:children?smart_folder=smartfolder:children/Li5zbWFydF9mb2xkZXJfY2hpbGRyZW4kRGF0YSBDZW50ZXIJLi5teV9wZXJzb25hbF9zbWFydF9mb2xkZXIkb25lLnBlcnNvbmFsX3NtYXJ0X2ZvbGRlciQuY29tLmluZm9ibG94Lm9uZS5hZG1pbiRhZG1pbi5OZXR3b3JrcyBieSBUeXBl:children'
which returns a sinble result in this lab:
[ { "_ref": "smartfolder:children/Li5zbWFydF9mb2xkZXJfY2hpbGRyZW4kMQ:children", "resource": "network/ZG5zLm5ldHdvcmskMTAuOS4xNi4wLzI0LzA:192.168.4.0/24/default", "value": { "value_string": "192.168.4.0/24" }, "value_type": "STRING" } ]
And so on...