Package: ib-client
ib-clientThe simplest infoblox client!Why another infoblox client?This may be the first question that come to your mind if you know that there is already
aclientsupported by Infoblox.The answer isgenericity. I try to be the more generic as possible to support all the objects proposed by the
infoblox API through the instropection of its API. If you know thewapidocumentation of an object / function, you will know how to use through the client which has asimpleandintuitiveAPI.Installationpipinstallib-clientN.B: ib-client works starting from python 3.6DocumentationThe documentation is available athttps://ib-client.readthedocs.io/en/stable/.FeaturesA client that allows you to perform all the operations available in the infoblox api.A CLI that allows you to quickly perform the same operations as you will do with the client.Ability to perform customrequests.Ability to load.envfiles to configure the client or the CLI.UsageClientHere is how you can instantiate the client.frominfobloximportClientclient=Client(url='https://foo.com/wapi/v2.8',user='foo',password='foo')To create a network:network=client.get_object('network')network.create(network='10.1.0.0/16')To read all networks created:network.get()You will have an output similar to the following:[{"_ref":"network/ZG5zLm5ldHdvcmskMTAuMS4wLjAvMTYvMA:10.1.0.0%2F16","network":"10.1.0.0/16","network_view":"default"},{"_ref":"network/ZG5zLm5ldHdvcmskMTAuMi4wLjAvMTYvMA:10.2.0.0%2F16","network":"10.2.0.0/16","network_view":"default"}]To modify a network:network.update(object_ref='network/ZG5zLm5ldHdvcmskMTAuMS4wLjAvMTYvMA:10.1.0.0/16',comment='just a comment')If you want to search for the network modified, you can do this:network.get(params={'comment~':'just'},return_fields=['network','networkview','comment'])It is also interesting to notice in the last call how we filtered the fields to be returned. The output contains the
network modified previously.[{"_ref":"network/ZG5zLm5ldHdvcmskMTAuMS4wLjAvMTYvMA:10.1.0.0%2F16","comment":"just a comment","network":"10.1.0.0/16","network_view":"default"}]N.B:the reference is always returned, so this is why we don't need to mention it in thereturn_fieldsparameter.Finally to delete a network, you can perform this call:network.delete(object_ref='network/ZG5zLm5ldHdvcmskMTAuMS4wLjAvMTYvMA:10.1.0.0/16')Simple enough!CLIBefore using the CLI, you will have to set 3 environment variables, otherwise you will have an error. The 3 environment
variables are:IB_URL:the wapi infoblox url likehttps://foo/wapi/v2.8IB_USER:the user to connect toIB_PASSWORD:the user's passwordIf you don't want to repeat these actions, you can create a.envfile in the directory where you want to use the CLI.
You need to provide the above information in the formKEY=VALUE, one per line.The cli hashelp informationavailable to help you quickly understand how to use itib-h
Usage:ib[OPTIONS]COMMAND[ARGS]...InfobloxCommandLineInterface.Itallowsyoutointeractwithinfobloxinthesamewayyouwilldowiththepythonapiclient.

Options:--versionShowtheversionandexit.-h,--helpShowthismessageandexit.

Commands:objectPerformsvariousobjectoperations.objectsListstheavailableobjectssupportsbytheinfoblox...requestMakesacustomrequestusingtherequestobjectof...schemaShowstheapischema.shell-completionInstallsshellcompletion.Each command also has help information available through the-hoption.
You can activate the shell completion onbash,fish,zshandPowershellby doing the following command:ibshell-completionNote:On Powershell, you may encounter an error in non administrator mode and if you are in administrator mode,
and you still encounter an error like the following:Set-ExecutionPolicy:WindowsPowerShellupdatedyourexecutionpolicysuccessfully,butthesettingisoverridden
byapolicydefinedatamorespecificscope.Duetotheoverride,yourshellwillretainitscurrenteffective
executionpolicyofBypass.Type"Get-ExecutionPolicy -List"toviewyourexecutionpolicysettings.
Formoreinformationpleasesee"Get-Help Set-ExecutionPolicy".Please refer tomicrosoft documentationto know how to fix the issue.We will now perform the same operations realized in the client part.Create a network:ibobject-nnetworkcreate-a'{"network": "10.1.0.0/16"}'Notes:the-noption afterobjectcommand specifies the object to work on.On Powershell, you will need a different syntax to escape properly json arguments:ibobject-nnetworkcreate-a"{\"network\": \"10.1.0.0/16\"}"I know it is ugly and tricky, but we can't do differently on Windows :(To get all created networks:ibobject-nnetworkgetUpdate a network:ibobject-nnetworkupdate-onetwork/ZG5zLm5ldHdvcmskMTAuMS4wLjAvMTYvMA:10.1.0.0%2F16-a'{"comment":"just a comment"}'Search for a network:ibobject-nnetworkget-p'{"comment~":"just"}'--return-fields=network,networkview,commentDelete a network:ibobject-nnetworkdelete-onetwork/ZG5zLm5ldHdvcmskMTAuMS4wLjAvMTYvMA:10.1.0.0%2F16WarningsThe client was created by working on major version 2 of the infoblox API, so it is sure to work on it, will not work
on a previous major version and is not sure to work on a higher major version.I don't have much time to test my client on an infoblox server, so it's likely there are some bugs. Feel free to suggest
pull requests. See the CONTRIBUTING.md file for more details. All contributions are welcome :)