Deleting Objects
When using the WAPI to remove objects from the Grid, often times you will need to obtain a reference or a list of references to objects, and perform a delete call on those object references. Ordinarily it is two (2) calls:
-
Obtain reference by performing a GET request for the
_refof an object -
Make a DELETE request on the
_refof the object
Tip
The Infoblox NIOS WAPI API is fully documented and available online. You can access the API guide by using the following url path on your Infoblox Grid Manager:
https://<grid_mgr>/wapidoc
See the WAPI Guide for details on all objects, properties, functions, and parameters.
Delete Network
- Retrieve the object reference from the network
- Delete the network
Tip
The wapi.getone('<wapi_object>', params, **kwargs) method does not return a response object.
It will return an object reference of type string.
To fetch the reference for network container 192.168.2.0/24 from the Grid, we start to create our script with the following:
To delete the network we add the following to our script:
Our response above is an httpx Response object, and it will contain a number of properties
and methods.
The ones used most often in working with WAPI data are:
| property/method | Description |
|---|---|
json() |
A method returns JSON-encoded object of the result (if the result was JSON encoded) |
status_code |
A property representing the HTTP Status Code (200 is OK, 404 is Not Found and so on) |
text |
A property which returns the content of the response in unicode |
We can test the success or failure of the above request by checking for an OK status on the response object this is
done like adding the following to our script:
Delete Host Record
- Retrieve the object reference from the record:host
- Delete the host
To fetch the reference for my_router.example.com from the Grid, we start to create our script with the following:
To delete the record:host we add the following to our script:
We can test the success or failure of the above request by checking for an OK status on the response object this is
done like adding the following to our script: