Hi!
You can check the python code in the P4 tutorial. It currently reads some JSON files that translate the rules to actual rules sent to the switch using P4Runtime. That might be your first step. You can check program_switch_p4runtime at run_exercise.py (to see how JSON rules are installed) and particularly how p4runtime_lib.simple_controller works (which is what you are likely looking for.
Additionally, you can search for the ONOS controller. The tutorial in this link is the best option to start with it.
Hope it helps ![]()