Article Options
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Create, Search and Delete a Host Object Using the REST API
There has been a great deal of interest in the new NIOS REST based API and we have had tons of questions about how it works. One common request is how to work with the host object via the new API. Here are some basic examples on how to create, search for and delete a host via the REST API:
Create a host:
curl -k -u admin:infoblox -H "Content-Type: application/json" -X POST https://10.65.16.12/wapi/v1.0/record:host -d '{ "ipv4addrs":[{"configure_for_dhcp": false,"ipv4addr": "10.10.10.12"}],"name": "newhost.bloxdemo.com","view": "default"}'
Search for the host that was just created:
curl -k -u admin:infoblox -X GET https://10.65.16.12/wapi/v1.0/record:host -d name~=newhost
The search returns a reference (_ref) for the host:
[ { "_ref": "record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS5ibG94ZGVtby5uZXdob3N0:newhost.bloxdemo.com/default", "ipv4addrs": [ { "_ref": "record:host_ipv4addr/ZG5zLmhvc3RfYWRkcmVzcyQuX2RlZmF1bHQuY29tLmJsb3hkZW1vLm5ld2hvc3QuMTAuMTAuMTAuMTIu:10.10.10.12/newhost.bloxdemo.com/default", "configure_for_dhcp": false, "host": "newhost.bloxdemo.com", "ipv4addr": "10.10.10.12" } ], "name": "newhost.bloxdemo.com", "view": "default" } ]
Delete the host using the reference:
curl -k -u admin:infoblox -X DELETE https://10.65.16.12/wapi/v1.0/record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS5ibG94ZGVtby5uZXdob3N0
Comments