NiPyApi will look for a NiFi environment on the usual port, or you can change this in nipyapi.config shown above.
Congratulations! You have just commanded the NiFi API in less than 5 lines of code.
Investigating the Package
Now we can try using a few of the NiPyApi commands to interact with the NiFi environment - while the entire NiFi and NiFi-Registry APIs are implemented, only some of the calls are surfaced for common use - you can find out about them in great detail either through the online documentation at ReadTheDocs, or by investigating the Github Repo. For now, try looking at the console documentation of the nipyapi.canvas functions using the help() command:
Help on module nipyapi.canvas in nipyapi:
For interactions with the NiFi Canvas
STATUS: Work in Progress to determine pythonic datamodel
create_process_group(parent_pg, new_pg_name, location)
Creates a new PG with a given name under the provided parent PG
:param parent_pg: ProcessGroupEntity object of the parent PG
:param new_pg_name: String to name the new PG
:param location: Tuple of (x,y) coordinates to place the new PG
:return: ProcessGroupEntity of the new PG
You can see there are a lot of functions here that you can use to complete tasks against NiFi, and there are even more in the nipyapi.templates and nipyapi.versioning modules.
Trying an Automation Script
There is a handy interactive Demo built into NiPyApi, and this time we're also going to use the new NiFi-Registry as well.
It will procedurally generate a Process Group containing a Processor in NiFi, and then put them under Version Control in the NiFi Registry. It will then also clone the version from one Registry Bucket to another, simulating code promotion:
Note that if you did not use the supplied Docker configuration above, you may have to modify the script to connect to your NiFi and NiFi-Registry environments.