karthik manchala
karthik manchala

Reputation: 13650

How to update properties of NiFi template programatically (rest-api?)

I have NiFi template exported as xml. I am using rest-api to upload template to a NiFi instance. Now, I want to update/add some properties (say, password) of the template from rest-api (or any other option available, programatically).

I read the docs and various community threads without success. Referred links:

Open for any approach, Thanks

Upvotes: 3

Views: 2638

Answers (1)

JDP10101
JDP10101

Reputation: 1852

I think there is a bit of confusion in your wording. Correct me if I'm wrong but I believe what you want to do is:

  1. Create a template in one location
  2. Export it
  3. Upload it to another NiFi instance
  4. Add the template to the canvas (so now it's just components on your NiFi canvas)
  5. Edit the properties of the components that were added

There are generally two different reasons you would want to edit the properties after importing a template: the properties are specific to the instance you're running on; they were sensitive properties.

With the addition of the "variable registry" in NiFi-0.7.0 you can have multiple files that at NiFi's start-up are read in to give custom variables to use. Here is a section about it in the NiFi docs. This allows you to have custom variables to reference via Expression Language (EL) specific to each environment you run on.

The "variable registry" doesn't help for the sensitive properties though, because the EL used to reference them doesn't get exported with the template (since the property is sensitive). You will need to use the rest-api to update the processor properties explicitly. The NiFi docs give the exact call to use to update a processor (under Processors -> Put). Upgrading the variable registry to work securely is on the NiFi roadmap.

If I was completely off and you simply want to modify a template after importing it into a NiFi instance. You would have to add the template to your graph, delete the template from the listing, re-create it using the components on your graph. After templates are imported/created they are immutable.

Upvotes: 2

Related Questions