Package: ipfabric
IP FabricIPFabric is a Python module for connecting to and communicating against an IP Fabric instance.AboutFounded in 2015,IP Fabricdevelops network infrastructure visibility and analytics solution to
help enterprise network and security teams with network assurance and automation across multi-domain heterogeneous
environments. From in-depth discovery, through graph visualization, to packet walks and complete network history, IP
Fabric enables to confidently replace manual tasks necessary to handle growing network complexity driven by relentless
digital transformation.v7.0.0 Deprecation NoticesInipfabric>=v7.0.0the following will be changed/deprecated:In v7.0IPFDiagramwill be removed as it is now located inIPFClient().diagram, the following will be changed:IPFDiagram().diagram_model()->IPFClient().diagram.model()IPFDiagram().diagram_json()->IPFClient().diagram.json()IPFDiagram().diagram_svg()->IPFClient().diagram.svg()-IPFDiagram().diagram_png()->IPFClient().diagram.png()The use oftoken='<TOKEN>'orusername='<USER>', password='<PASS>'inIPFClient()will be removed:Token:IPFClient(auth='TOKEN')User/Pass:IPFClient(auth=('USER', 'PASS')).envfile will only acceptIPF_TOKENor (IPF_USERNAMEandIPF_PASSWORD) and notauthVersioningStarting with IP Fabric version 5.0.x the python-ipfabric and python-ipfabric-diagrams will need to
match your IP Fabric version.  The API's are changing and instead ofapi/v1they will now beapi/v5.0.Version 5.1 will have backwards compatability with version 5.0 however 6.0 will not support any 5.x versions.
By ensuring that your ipfabric SDK's match your IP Fabric Major Version will ensure compatibility and will continue to work.Defaulted to Streaming DataSeeNoticesfor full information.GET URL is limited to 4096 characters.Complex queries and filters could go over this limit; however in testing it was very difficult to reach this.CSV ExportOnly supported with a streaming GET request and return a bytes string of data in the Python SDK.It will also convert times to human-readable format.reports(returning Intent Check data) is not supported with CSV export, however is required when filtering based on Intents (colors).fromipfabricimportIPFClientipf=IPFClient(streaming=True)dev=ipf.inventory.devices.all()print(type(dev))# listdev_csv=ipf.fetch_all('tables/inventory/devices',export='csv')print(type(dev_csv))# bytes# Timezone can be changed for CSV export; see `ipfabric.tools.shared.TIMEZONES`dev_csv_tz=ipf.inventory.devices.all(export='csv',csv_tz='UTC')# If specifying to return reports and CSV request will drop reports input and use GETdev_csv_reports=ipf.fetch_all('tables/inventory/devices',reports=True,export='csv')"""CSV export does not return reports, parameter has been excluded."""print(type(dev_csv_reports))# bytes# If URL exceeds 4096 characters the following exception will be raised:# raise InvalidURL(f"URL exceeds max character limit of 4096: length={len(url)}.")Installationpip install ipfabricTo useexport='df'on some methods please installpandaswithipfabricpip install ipfabric[pd]IntroductionPlease take a look atAPI Programmability - Part 1: The Basicsfor instructions on creating an API token.Most of the methods and features can be located inExamplesto show how to use this package.
Another great introduction to this package can be found atAPI Programmability - Part 2: PythonAuthenticationUsername/PasswordSupply in client:fromipfabricimportIPFClientipf=IPFClient('https://demo3.ipfabric.io/',auth=('user','pass'))TokenfromipfabricimportIPFClientipf=IPFClient('https://demo3.ipfabric.io/',auth='token')EnvironmentThe easiest way to use this package is with a.envfile.  You can copy the sample and edit it with your environment variables.cp sample.env .envThis contains the following variables which can also be set as environment variables instead of a .env file.IPF_URL="https://demo3.ipfabric.io"
IPF_TOKEN=TOKEN
IPF_VERIFY=trueOr if using Username/Password:IPF_URL="https://demo3.ipfabric.io"
IPF_USERNAME=USER
IPF_PASSWORD=PASSDevelopmentPoetry InstallationIPFabric usesPoetryto make setting up a virtual environment with all dependencies
installed quick and easy.Install poetry globally:pip install poetryTo install a virtual environment run the following command in the root of this directory.poetry installTo run examples, install extras:poetry install ipfabric -E examplesTest and Buildpoetry run pytest
poetry buildPrior to pushing changes run:poetry run black ipfabric
poetry update