Created on 03-06-201705:29 PM - edited 08-17-201901:57 PM
The objective of this article is to clearly demonstrate how to use NiFi's REST API to create a template on a secured cluster. I plan to publish multiple articles on using NiFi rest api based on community feedback around the use cases in the field. No pie in the sky type of knowledge share. Adding complexity to the workflows as I publish new articles and how they look via rest api publishing.
Use Case Setup:
Create template of my process group UVindex via rest api. UVindex resides within a process group hierarchy
UNindex is a simply process groups which polls Chiago uv index data every 5 minutes and stores on hdfs. CurrentWeatherData is in the same process group but for this use case I only want to create template for UVIndex process group.
Fetch Access Token
Fetch Client ID
Fetch Process Group attributes
Step 1 - Fetch Access Token
Access token is required for rest api interactions on secured nifi cluster. Token will be used in the header for all rest api interactions
Which returns large json object. Here you can parse the json object for the name of the process group (UVindex) and grab the
UUID and version.
Step 4 - Create Snippet
To create a template, first a snippet must be created
. The snippet ID will be used to name and create template. All details of what a template should be composed of are within a snippet
For the payload populate PartentGroupID using the parent process group UUID. Under "processGroups" populate with UUID of the process group you want to create a template of, your client ID, and version captured in step 3. You may have connections or other objects which may require values within the payload. For this template it does not. In follow up articles I will create higher complexity work flows which will require such objection to be populated during snippet creation.