Infoblox offers a rich set of Web-based Application Programming Interfaces, also called WAPIs, that are REST-based and allow you to easily integrate NIOS into your automation environment. This blog gives you an insight on why you should use these WAPIs.
Now that you are ready to use these WAPIs, first-time users may be asking, “All this is great, but where do I get started?”; and those of you who already use these WAPIs may be asking, “I already use WAPIs, what am I going to learn from this blog?”
Well, the answer to both is simple – WAPI Schema Fetching.
This blog will cover the following parameters available with the APIs that allow you to get information regarding the schema of the WAPI that will get you going:
PARAMETER | DESCRIPTION |
_schema | Fetches the schema of WAPI |
_schema_version | You can specify the schema version you wish to be returned. By default it is set to 1 |
_get_doc | The schema will include documentation. Applicable only when _schema_version is 2. |
_schema_searchable | The schema will include search-only fields. Applicable only when _schema_version is 2. |
How do I know what version of WAPI is supported by my Infoblox appliance?
When you request a WAPI schema using the _schema option without specifying objtype, an object with the following fields will be returned:
- requested_version – Actual requested version of the WAPI schema.
- supported_objects – List of supported objects in the requested version.
- supported_versions – List of all supported versions.
The highest version listed under supported_versions will give you the latest version supported by your Infoblox appliance.
Example:
- Sample API Call: https://grid-master/wapi/v1.0/?_schema
- Sample Output (lists shortened):
{ “requested_version”: “1.0”,
“supported_objects”: [“ipv4address”, “ipv6address”, “ipv6network”,
“ipv6networkcontainer”, “ipv6range”,
“macfilteraddress”, “network”, …],
“supported_versions“: [“1.0”, “1.1”, “1.2”, “1.2.1”, …,”2.12.1″,…]
}
- This appliance supports 2.12 as the latest WAPI version. In all subsequent calls, you can use this version.
How do I know what objects are supported in the latest version of WAPI on my Infoblox appliance?
You can run a _schema query against the latest WAPI version supported by your appliance. The supported_objects field lists all the network objects supported by WAPIs on your appliance.
Example:
- Sample API Call: https://grid-master/wapi/v2.12/?_schema
- Sample Output (lists shortened):
{ “requested_version”: “2.12”,
“supported_objects“: [“ad_auth_service”, “admingroup”, “adminrole”, “adminuser”, “allendpoints”, “allnsgroup”, “allrecords”,…],
“supported_versions”: [“1.0”, “1.1”, “1.2”, “1.2.1”, …,”2.12″,…]
}
- This appliance supports 263 network objects, when WAPI version 2.12.
How do I know what fields are supported within each API object?
When you request a WAPI schema using the _schema option while specifying objtype, an object with the following fields will be returned:
- cloud_additional_restrictions – List of cloud restrictions.
- fields – List of fields of the object.
- restrictions – List of object restrictions.
- type – Requested objtype.
- version – Actual requested version of the WAPI object schema.
You can run a _schema query on an API object (say, networkview) against the latest WAPI version supported by your appliance. The fields field details all the fields supported for the API object (in this case, networkview) by WAPIs on your appliance.
The returned fields list is composed of individual objects each describing a field of the API object. These objects have the following members:
- is_array – True if this field is an array.
- name – Name of this field.
- searchable_by – String with supported search modifiers: “=”, ”!”, ”:”, “~”, “<”, “>”.
- standard_field – True for fields that are returned by default.
- supports – List of supported operations: “s”(search), “w”(write), “u”(update), “r”(read).
- type – List of supported types.
Example:
- Sample API Call: https://grid-master/wapi/v2.12/networkview?_schema
- Sample Output (lists shortened):
{ “cloud_additional_restrictions”: [“function call”],
“fields“: [
{“is_array”: true,
“name”: “associated_dns_views”,
“standard_field”: false,
“supports”: “r”,
“type”: [“string”]
},
{“is_array”: true,
“name”: “associated_members”,
“standard_field”: false,
“supports”: “r”,
“type”: [“networkview:assocmember”]
},…],
“restrictions”: [“scheduling”,”csv”],
“type”: “networkview”,
“version”: “2.12”}
How do I get a list of all the search-only fields supported within each API object?
When you run a _schema query on an API object (say, network), set the _schema_searchable parameter to 1 and set the _schema_version parameter to 2. The schema returned will include all the search-only fields, as well.
Adding _schema_version=2, adds the following additional fields to the object schema:
- schema_version – The version of schema description requested.
- wapi_primitive – Determines if the requested WAPI primitive is object, structure or function call.
It also adds the following additional fields to the fields list:
- schema_version – The version of schema description requested.
- wapi_primitive – Determines if the requested WAPI primitive is object, structure or function call.
- supports_inline_funccall – Determines if the field can be initialized by calling an inline function.
- doc – The documentation of this field. It’s applicable only when _get_doc=1 is used. The returned documentation string might contain ReStructuredText directives.
It also delivers all information regarding structures and function calls
Example:
- Sample API Call: https://grid-master/wapi/v2.12/network?_schema&_schema_version=2&_schema_searchable=1
- Sample Output (lists shortened):
{“cloud_additional_restrictions”: [],
“fields”: [
{“is_array”: false,
“name”: “authority”,
“overridden_by”: “use_authority”,
“standard_field”: false,
“supports”: “rwu”,
“type”: [“bool”]
},
{“is_array”: false,
“name”: “auto_create_reversezone”,
“standard_field”: false,
“supports”: “w”,
“type”: [“bool”]
},…,
{“is_array”: false,
“name”: “contains_address”,
“searchable_by”: “=”,
“standard_field”: false,
“supports”: “s”,
“type”: [“string”]
},…],
“restrictions”: [],
“schema_version”: “2”,
“type”: “network”,
“version”: “2.12”,
“wapi_primitive”: “object”}
How do I get more information about the fields that are supported within each API object?
When you run a _schema query on an API object (say, network), set the _schema_version parameter to 2 and the _get_doc parameter to 1. The schema returned will include documentation about each of the fields supported under the doc field.
Example:
- Sample API Call:
https://grid-master/wapi/v2.12/network?_schema&_schema_version=2&_get_doc=1
- Sample Output (lists shortened):
{“cloud_additional_restrictions”: [],
“fields”: [
{“doc”: “Authority for the DHCP network.”,
“is_array”: false,
“name”: “authority”,
“overridden_by”: “use_authority”,
“standard_field”: false,
“supports”: “rwu”,
“type”: [“bool”]
},
{“doc”: “This flag controls whether reverse zones are automatically created when the network is added.”,
“is_array”: false,
“name”: “auto_create_reversezone”,
“standard_field”: false,
“supports”: “w”,
“type”: [“bool”]
},…],
“restrictions”: [],
“schema_version”: “2”,
“type”: “network”,
“version”: “2.12”,
“wapi_primitive”: “object”}
Conclusion
Now that you have become more familiar with the APIs, here are links to the samples Postman collection and Insomnia collection to get you started with Infoblox WAPIs. Happy coding!