I am able to execute the below nifi commands for retreiving system-diagnostics metrics. Is there anyway that these commands can be executed through java code by invoking nifi api using our own methods as we do in aws cloudwatch to put metrics.
read USER
read -s PASS
TOKEN=`curl -X POST --data "username=$USER&password=$PASS" -k https://nifiHostName.com:nifiPort/nifi-api/access/token`
curl -H "Authorization: Bearer $TOKEN" -k https://nifiHostName:nifiPort/nifi-api/system-diagnostics\ | python -m json.tool
If above is not possible can anyone answer how to give Authorization: Bearer $TOKEN through a simple Java code that would be great.
Or else by using simple https client is it possible to execute these commands through java. If yes could you please help me on this.