I want to transfer my Nifi-ETL pipeline (mainly PUTSQL-processors) from my development instance to my production instance of Apache Nifi, optimally with Python for re-usability.
I thought I would give it a shot to just try and copy-paste them.
- GET processor from DEV with GET-request on /nifi-api/processors/{id}
- PUT processor to PRD Nifi-instance with PUT-request on /nifi-api/processors/{id}
Code:
# GET processor and parse to JSON
response = requests.get(nifi_url_dev + 'processors/' + proc_id
, headers=header)
processor = json.loads(response.content)
# PUT processor
processor['revision']['version'] = 0 # reset version
payload = json.dumps(processor).encode('utf8')
response = requests.put(nifi_url_prd + 'processors/' + proc_id
, data=payload
, headers=header)
This failed on the PUT with a 409 HTTP Conflict Error. I am guessing this is because I am trying to put a ressource on an URI that expects a resource to exist already at that place.
The documentation lists "Create a processor, Set properties, Schedule" next to the processor APIs, but when looking into it, there is no dedicated API for creation - I decided to go with PUT because it says "Updates a processor" which is the closest thing I can see in there to creating a new one from scratch.
Do you have any ideas on how to create processors with Python? Either by copying existing ones or creating entirely new ones?