NiFi Rest Api documentation can be found at https://nifi.apache.org/docs/nifi-docs/rest-api/index.html
- You need to find the processor ID (use PG Name and Processor Name).
- Find the current Version of the Processor.
- Find current state. (this )
- Build Payload.
export hostname='localhost'
export port='8081'
export pg_name='test_pg'
export processors_name='Start'
export resources=`curl -XGET http:https://$hostname:$port/nifi-api/resources`
export pg_name='test_pg'
export pg_id_string=`echo $resources| jq -c '.resources[] | select(.name| contains ("'$pg_name'")) | .identifier' | grep -v 'data\|policies\|operation' | grep 'process-groups' | tr -d '"'`
export pg_id=${pg_id_string/\/process-groups\//}
export processors=`curl http:https://$hostname:$port/nifi-api/flow/process-groups/$pg_id`
export processor_id=`echo $processors | jq -c '.processGroupFlow.flow.processors[]| select(.component.name | contains("'$processors_name'")) | .component.id' | tr -d '"'`
export processor_version=`echo $processors | jq -c '.processGroupFlow.flow.processors[]| select(.component.name | contains("'$processors_name'")) | .revision.version' | tr -d '"'`
export processor_status=`echo $processors | jq -c '.processGroupFlow.flow.processors[]| select(.component.name | contains("'$processors_name'")) | .status.runStatus' | tr -d '"'`
export clientId=$(uuidgen | tr "[:upper:]" "[:lower:]")
curl -H 'Content-Type: application/json' -XPUT -d '''
{
"status": {
"runStatus": "RUNNING"
},
"component": {
"state": "RUNNING",
"id": "'$processor_id'"
},
"id": "'$processor_id'",
"revision": {
"version": '$processor_version',
"clientId": "'$clientId'"
}
} ''' http:https://$hostname:$port/nifi-api/processors/$processor_id
curl -H 'Content-Type: application/json' -XPUT -d '''
{
"status": {
"runStatus": "STOPPED"
},
"component": {
"state": "STOPPED",
"id": "'$processor_id'"
},
"id": "'$processor_id'",
"revision": {
"version": '$processor_version',
"clientId": "'$clientId'"
}
} ''' http:https://$hostname:$port/nifi-api/processors/$processor_id
curl -H 'Content-Type: application/json' -XPUT -d '''
{
"status": {
"runStatus": "DISABLED"
},
"component": {
"state": "DISABLED",
"id": "'$processor_id'"
},
"id": "'$processor_id'",
"revision": {
"version": '$processor_version',
"clientId": "'$clientId'"
}
} ''' http:https://$hostname:$port/nifi-api/processors/$processor_id
export resources=`curl -XGET http:https://$hostname:$port/nifi-api/resources`
export pg_id_string=`echo $resources| jq -c '.resources[] | select(.name| contains ("'$pg_name'")) | .identifier' | grep -v 'data\|policies\|operation' | grep 'process-groups'`
export pg_id="${pg_id_string/\/process-groups\//}"
curl -H 'Content-Type: application/json' -XPUT -d '{"id":"'$pg_id'","state":"RUNNING"}' http:https://$hostname:$port/nifi-api/flow/process-groups/$pg_id
curl -H 'Content-Type: application/json' -XPUT -d '{"id":"'$pg_id'","state":"STOPPED"}' http:https://$hostname:$port/nifi-api/flow/process-groups/$pg_id
curl -i -X PUT -H 'Content-Type: application/json' -d '{"revision":{"version":??,"clientId":"test"},"processor":{"id":"20eb7bbd-2f68-4538-aa13-0f4fa33e63c4","state":"RUNNING"}}'