Updating Objects
When using the WAPI to update objects from the Grid, often times you will need to obtain a reference or a list of references to objects, and perform a PUT call on those object references while passing in data you want to update against the reference. Ordinarily it is two (2) calls:
-
Obtain reference by performing a GET request for the
_refof an object -
Make a PUT 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.
Disable Network Object
- Retrieve the object reference from the network
- Disable 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 192.168.0.0/24 from the Grid, we start to create our script with the following:
To update 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:
Change Name on Host Record
- Retrieve the object reference from the record:host
- Change its name
To fetch the reference for host my-router.example.com from the Grid, we start to create our script with the following:
To update the hostname 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: