Created 07-08-2022 11:20 PM
I am trying to update parameter context within Nifi which is allocated to several process groups. We would like to update the value of one parameter within the parameter context. Please provide some sample payload to do to update parameter contexts either PUT or POST method
Created 07-11-2022 09:41 AM
@Chakkara
Updating a parameter context is a multi command process.
1. Fist you must GET the current parameter context configuration:
curl -k -X GET https://<hostname>:<port>/nifi-api/parameter-contexts/<parameter context UUID> --compressed
- This will return a potentially large json which will include the current revision, all the parameter contexts from that parameter context and all the referencing components. Assuming your NIFi is secured, your'll also need to include a method of authentication (client certificate, bearer token) in the above request.
2. Next you will POST your update-request using detail from above json response in step 1.
curl -k 'https://<hostname>:<port>/nifi-api/parameter-contexts/<PARAMETR Context UUID>/update-requests' --data-raw $'{"revision":{"version":<num from step 1>},"id":"<PARAMETR Context UUID>","uri":"https://<hostname>:<port>/nifi-api/parameter-contexts/<PARAMETR Context UUID>","permissions":{"canRead":true,"canWrite":true},"component":{"name":"param-test","description":"","parameters":[{"parameter":{"name":"<Parameter name>","sensitive":false,"value":"<new parameter value>","description":""}}],"boundProcessGroups":[{"revision":{"clientId":"edcad62f-0181-1000-2fc6-de0c25282a3b","version":<num from step 1>},"id":"70b33f0a-e362-1c0b-8147-8fada18d56bd","position":{"x":136,"y":-2456},"permissions":{"canRead":true,"canWrite":true},"component":{"id":"70b33f0a-e362-1c0b-8147-8fada18d56bd","parentGroupId":"7930f131-017b-1000-0000-00007ece6b9d","position":{"x":136,"y":-2456},"name":"Param2","comments":"","variables":{},"parameterContext":{"id":"<PARAMETR Context UUID>","permissions":{"canRead":true,"canWrite":true},"component":{"id":"<PARAMETR Context UUID>","name":"param-test"}},"flowfileConcurrency":"UNBOUNDED","flowfileOutboundPolicy":"STREAM_WHEN_AVAILABLE","runningCount":2,"stoppedCount":0,"invalidCount":0,"disabledCount":0,"activeRemotePortCount":0,"inactiveRemotePortCount":0,"upToDateCount":0,"locallyModifiedCount":0,"staleCount":0,"locallyModifiedAndStaleCount":0,"syncFailureCount":0,"localInputPortCount":0,"localOutputPortCount":0,"publicInputPortCount":0,"publicOutputPortCount":0,"inputPortCount":0,"outputPortCount":0},"runningCount":2,"stoppedCount":0,"invalidCount":0,"disabledCount":0,"activeRemotePortCount":0,"inactiveRemotePortCount":0,"upToDateCount":0,"locallyModifiedCount":0,"staleCount":0,"locallyModifiedAndStaleCount":0,"syncFailureCount":0,"localInputPortCount":0,"localOutputPortCount":0,"publicInputPortCount":0,"publicOutputPortCount":0,"parameterContext":{"id":"994938a5-0180-1000-0000-00007cbba46b","permissions":{"canRead":true,"canWrite":true},"component":{"id":"<PARAMETR Context UUID>","name":"param-test"}},"inputPortCount":0,"outputPortCount":0},{"revision":{"clientId":"edcad62f-0181-1000-2fc6-de0c25282a3b","version":2},"id":"edcb3ff7-0181-1000-0000-00004abfd1ed","position":{"x":-323.1760214048029,"y":-2454.121877860687},"permissions":{"canRead":true,"canWrite":true},"component":{"id":"edcb3ff7-0181-1000-0000-00004abfd1ed","parentGroupId":"7930f131-017b-1000-0000-00007ece6b9d","position":{"x":-323.1760214048029,"y":-2454.121877860687},"name":"param1","comments":"","variables":{},"parameterContext":{"id":"994938a5-0180-1000-0000-00007cbba46b","permissions":{"canRead":true,"canWrite":true},"component":{"id":"<PARAMETR Context UUID>","name":"param-test"}},"flowfileConcurrency":"UNBOUNDED","flowfileOutboundPolicy":"STREAM_WHEN_AVAILABLE","runningCount":2,"stoppedCount":0,"invalidCount":0,"disabledCount":0,"activeRemotePortCount":0,"inactiveRemotePortCount":0,"upToDateCount":0,"locallyModifiedCount":0,"staleCount":0,"locallyModifiedAndStaleCount":0,"syncFailureCount":0,"localInputPortCount":0,"localOutputPortCount":0,"publicInputPortCount":0,"publicOutputPortCount":0,"inputPortCount":0,"outputPortCount":0},"runningCount":2,"stoppedCount":0,"invalidCount":0,"disabledCount":0,"activeRemotePortCount":0,"inactiveRemotePortCount":0,"upToDateCount":0,"locallyModifiedCount":0,"staleCount":0,"locallyModifiedAndStaleCount":0,"syncFailureCount":0,"localInputPortCount":0,"localOutputPortCount":0,"publicInputPortCount":0,"publicOutputPortCount":0,"parameterContext":{"id":"994938a5-0180-1000-0000-00007cbba46b","permissions":{"canRead":true,"canWrite":true},"component":{"id":"<PARAMETR Context UUID>","name":"param-test"}},"inputPortCount":0,"outputPortCount":0},{"revision":{"version":0},"id":"7930f131-017b-1000-0000-00007ece6b9d","position":{"x":328,"y":400},"permissions":{"canRead":true,"canWrite":true},"component":{"id":"7930f131-017b-1000-0000-00007ece6b9d","versionedComponentId":"136b68f9-1621-366e-8e8a-1db651ad8808","parentGroupId":"e377355c-017a-1000-2658-01d1a778332f","position":{"x":328,"y":400},"name":"Matt\'s PG","comments":"","variables":{},"versionControlInformation":{"groupId":"7930f131-017b-1000-0000-00007ece6b9d","registryId":"e97b2503-017a-1000-0000-00000c0a8abc","registryName":"nifi-sme-75.novalocal","bucketId":"19f7633f-5c1d-4d80-9d0d-d95c7e4885f8","bucketName":"new-bucket","flowId":"6add76b8-e56b-4d36-99e2-8aba4f5a9c33","flowName":"Matts-PG","flowDescription":"","version":2,"state":"LOCALLY_MODIFIED","stateExplanation":"Local changes have been made"},"parameterContext":{"id":"<PARAMETR Context UUID>","permissions":{"canRead":true,"canWrite":true},"component":{"id":"994938a5-0180-1000-0000-00007cbba46b","name":"param-test"}},"flowfileConcurrency":"UNBOUNDED","flowfileOutboundPolicy":"STREAM_WHEN_AVAILABLE","runningCount":39,"stoppedCount":109,"invalidCount":74,"disabledCount":7,"activeRemotePortCount":0,"inactiveRemotePortCount":2,"upToDateCount":0,"locallyModifiedCount":0,"staleCount":0,"locallyModifiedAndStaleCount":0,"syncFailureCount":0,"localInputPortCount":0,"localOutputPortCount":0,"publicInputPortCount":0,"publicOutputPortCount":0,"inputPortCount":0,"outputPortCount":0},"runningCount":39,"stoppedCount":109,"invalidCount":74,"disabledCount":7,"activeRemotePortCount":0,"inactiveRemotePortCount":2,"versionedFlowState":"LOCALLY_MODIFIED","upToDateCount":0,"locallyModifiedCount":0,"staleCount":0,"locallyModifiedAndStaleCount":0,"syncFailureCount":0,"localInputPortCount":0,"localOutputPortCount":0,"publicInputPortCount":0,"publicOutputPortCount":0,"parameterContext":{"id":"<PARAMETR Context UUID>","permissions":{"canRead":true,"canWrite":true},"component":{"id":"994938a5-0180-1000-0000-00007cbba46b","name":"param-test"}},"inputPortCount":0,"outputPortCount":0},{"revision":{"clientId":"edcad62f-0181-1000-2fc6-de0c25282a3b","version":2},"id":"373a39ad-0443-10ec-9e85-69445fefe75e","position":{"x":-320,"y":-2216},"permissions":{"canRead":true,"canWrite":true},"component":{"id":"373a39ad-0443-10ec-9e85-69445fefe75e","parentGroupId":"7930f131-017b-1000-0000-00007ece6b9d","position":{"x":-320,"y":-2216},"name":"param3","comments":"","variables":{},"parameterContext":{"id":"994938a5-0180-1000-0000-00007cbba46b","permissions":{"canRead":true,"canWrite":true},"component":{"id":"<PARAMETR Context UUID>","name":"param-test"}},"flowfileConcurrency":"UNBOUNDED","flowfileOutboundPolicy":"STREAM_WHEN_AVAILABLE","runningCount":2,"stoppedCount":0,"invalidCount":0,"disabledCount":0,"activeRemotePortCount":0,"inactiveRemotePortCount":0,"upToDateCount":0,"locallyModifiedCount":0,"staleCount":0,"locallyModifiedAndStaleCount":0,"syncFailureCount":0,"localInputPortCount":0,"localOutputPortCount":0,"publicInputPortCount":0,"publicOutputPortCount":0,"inputPortCount":0,"outputPortCount":0},"runningCount":2,"stoppedCount":0,"invalidCount":0,"disabledCount":0,"activeRemotePortCount":0,"inactiveRemotePortCount":0,"upToDateCount":0,"locallyModifiedCount":0,"staleCount":0,"locallyModifiedAndStaleCount":0,"syncFailureCount":0,"localInputPortCount":0,"localOutputPortCount":0,"publicInputPortCount":0,"publicOutputPortCount":0,"parameterContext":{"id":"994938a5-0180-1000-0000-00007cbba46b","permissions":{"canRead":true,"canWrite":true},"component":{"id":"<PARAMETR Context UUID>","name":"param-test"}},"inputPortCount":0,"outputPortCount":0}],"id":"<PARAMETR Context UUID>"}}' --compressed
- This will return the uri for this new update request. A background process will take care of stopping changing, validating and starting all referenced components for the update parameter context. Assuming your NIFi is secured, your'll also need to include a method of authentication (client certificate, bearer token) in the above request.
3. Third you can execute a GET using the uri returned in step 2 to check progress of the request.
curl 'https://<hostname>:<port>/nifi-api/parameter-contexts/<PARAMETER CONTEXT UUID>/update-requests/<UPDATE REQUEST UUID form step 2 response>' -k --compressed
- This will return a json that will include within it the "percentCompleted". You'll need to check this endpoint until it reports 100% complete. Assuming your NIFi is secured, your'll also need to include a method of authentication (client certificate, bearer token) in the above request.
4. Final step is a DELETE to remove the update request that is now completed. Failing to do this leaves this request in NiFi Heap memory until a NiFi restart.
curl -X DELETE 'https://<hostname>:<port>/nifi-api/parameter-contexts/<PARAMETER CONTEXT UUID>/update-requests/<UPDATE_REQUEST UUID from step 2 response>' -k --compressed
- Assuming your NIFi is secured, your'll also need to include a method of authentication (client certificate, bearer token) in the above request.
An easy way to help understand the --data-raw input needed for your specific update-request is to use the developer tolls found in most browsers to inspect/capture that actual rest-api calls made when you execute the actual action via the NiFi UI. The browser developer tools will also allow you to right click on the triggering action and copy as curl. You can then paste that action as a curl command in a terminal window and execute it yourself.
Reference:
https://nifi.apache.org/docs/nifi-docs/rest-api/index.html
- specifically looking at the section for "Parameter Contexts"
If you found this response assisted with your query, please take a moment to login and click on "Accept as Solution" below this post.
Thank you,
Matt
Created 07-11-2022 09:41 AM
@Chakkara
Updating a parameter context is a multi command process.
1. Fist you must GET the current parameter context configuration:
curl -k -X GET https://<hostname>:<port>/nifi-api/parameter-contexts/<parameter context UUID> --compressed
- This will return a potentially large json which will include the current revision, all the parameter contexts from that parameter context and all the referencing components. Assuming your NIFi is secured, your'll also need to include a method of authentication (client certificate, bearer token) in the above request.
2. Next you will POST your update-request using detail from above json response in step 1.
curl -k 'https://<hostname>:<port>/nifi-api/parameter-contexts/<PARAMETR Context UUID>/update-requests' --data-raw $'{"revision":{"version":<num from step 1>},"id":"<PARAMETR Context UUID>","uri":"https://<hostname>:<port>/nifi-api/parameter-contexts/<PARAMETR Context UUID>","permissions":{"canRead":true,"canWrite":true},"component":{"name":"param-test","description":"","parameters":[{"parameter":{"name":"<Parameter name>","sensitive":false,"value":"<new parameter value>","description":""}}],"boundProcessGroups":[{"revision":{"clientId":"edcad62f-0181-1000-2fc6-de0c25282a3b","version":<num from step 1>},"id":"70b33f0a-e362-1c0b-8147-8fada18d56bd","position":{"x":136,"y":-2456},"permissions":{"canRead":true,"canWrite":true},"component":{"id":"70b33f0a-e362-1c0b-8147-8fada18d56bd","parentGroupId":"7930f131-017b-1000-0000-00007ece6b9d","position":{"x":136,"y":-2456},"name":"Param2","comments":"","variables":{},"parameterContext":{"id":"<PARAMETR Context UUID>","permissions":{"canRead":true,"canWrite":true},"component":{"id":"<PARAMETR Context UUID>","name":"param-test"}},"flowfileConcurrency":"UNBOUNDED","flowfileOutboundPolicy":"STREAM_WHEN_AVAILABLE","runningCount":2,"stoppedCount":0,"invalidCount":0,"disabledCount":0,"activeRemotePortCount":0,"inactiveRemotePortCount":0,"upToDateCount":0,"locallyModifiedCount":0,"staleCount":0,"locallyModifiedAndStaleCount":0,"syncFailureCount":0,"localInputPortCount":0,"localOutputPortCount":0,"publicInputPortCount":0,"publicOutputPortCount":0,"inputPortCount":0,"outputPortCount":0},"runningCount":2,"stoppedCount":0,"invalidCount":0,"disabledCount":0,"activeRemotePortCount":0,"inactiveRemotePortCount":0,"upToDateCount":0,"locallyModifiedCount":0,"staleCount":0,"locallyModifiedAndStaleCount":0,"syncFailureCount":0,"localInputPortCount":0,"localOutputPortCount":0,"publicInputPortCount":0,"publicOutputPortCount":0,"parameterContext":{"id":"994938a5-0180-1000-0000-00007cbba46b","permissions":{"canRead":true,"canWrite":true},"component":{"id":"<PARAMETR Context UUID>","name":"param-test"}},"inputPortCount":0,"outputPortCount":0},{"revision":{"clientId":"edcad62f-0181-1000-2fc6-de0c25282a3b","version":2},"id":"edcb3ff7-0181-1000-0000-00004abfd1ed","position":{"x":-323.1760214048029,"y":-2454.121877860687},"permissions":{"canRead":true,"canWrite":true},"component":{"id":"edcb3ff7-0181-1000-0000-00004abfd1ed","parentGroupId":"7930f131-017b-1000-0000-00007ece6b9d","position":{"x":-323.1760214048029,"y":-2454.121877860687},"name":"param1","comments":"","variables":{},"parameterContext":{"id":"994938a5-0180-1000-0000-00007cbba46b","permissions":{"canRead":true,"canWrite":true},"component":{"id":"<PARAMETR Context UUID>","name":"param-test"}},"flowfileConcurrency":"UNBOUNDED","flowfileOutboundPolicy":"STREAM_WHEN_AVAILABLE","runningCount":2,"stoppedCount":0,"invalidCount":0,"disabledCount":0,"activeRemotePortCount":0,"inactiveRemotePortCount":0,"upToDateCount":0,"locallyModifiedCount":0,"staleCount":0,"locallyModifiedAndStaleCount":0,"syncFailureCount":0,"localInputPortCount":0,"localOutputPortCount":0,"publicInputPortCount":0,"publicOutputPortCount":0,"inputPortCount":0,"outputPortCount":0},"runningCount":2,"stoppedCount":0,"invalidCount":0,"disabledCount":0,"activeRemotePortCount":0,"inactiveRemotePortCount":0,"upToDateCount":0,"locallyModifiedCount":0,"staleCount":0,"locallyModifiedAndStaleCount":0,"syncFailureCount":0,"localInputPortCount":0,"localOutputPortCount":0,"publicInputPortCount":0,"publicOutputPortCount":0,"parameterContext":{"id":"994938a5-0180-1000-0000-00007cbba46b","permissions":{"canRead":true,"canWrite":true},"component":{"id":"<PARAMETR Context UUID>","name":"param-test"}},"inputPortCount":0,"outputPortCount":0},{"revision":{"version":0},"id":"7930f131-017b-1000-0000-00007ece6b9d","position":{"x":328,"y":400},"permissions":{"canRead":true,"canWrite":true},"component":{"id":"7930f131-017b-1000-0000-00007ece6b9d","versionedComponentId":"136b68f9-1621-366e-8e8a-1db651ad8808","parentGroupId":"e377355c-017a-1000-2658-01d1a778332f","position":{"x":328,"y":400},"name":"Matt\'s PG","comments":"","variables":{},"versionControlInformation":{"groupId":"7930f131-017b-1000-0000-00007ece6b9d","registryId":"e97b2503-017a-1000-0000-00000c0a8abc","registryName":"nifi-sme-75.novalocal","bucketId":"19f7633f-5c1d-4d80-9d0d-d95c7e4885f8","bucketName":"new-bucket","flowId":"6add76b8-e56b-4d36-99e2-8aba4f5a9c33","flowName":"Matts-PG","flowDescription":"","version":2,"state":"LOCALLY_MODIFIED","stateExplanation":"Local changes have been made"},"parameterContext":{"id":"<PARAMETR Context UUID>","permissions":{"canRead":true,"canWrite":true},"component":{"id":"994938a5-0180-1000-0000-00007cbba46b","name":"param-test"}},"flowfileConcurrency":"UNBOUNDED","flowfileOutboundPolicy":"STREAM_WHEN_AVAILABLE","runningCount":39,"stoppedCount":109,"invalidCount":74,"disabledCount":7,"activeRemotePortCount":0,"inactiveRemotePortCount":2,"upToDateCount":0,"locallyModifiedCount":0,"staleCount":0,"locallyModifiedAndStaleCount":0,"syncFailureCount":0,"localInputPortCount":0,"localOutputPortCount":0,"publicInputPortCount":0,"publicOutputPortCount":0,"inputPortCount":0,"outputPortCount":0},"runningCount":39,"stoppedCount":109,"invalidCount":74,"disabledCount":7,"activeRemotePortCount":0,"inactiveRemotePortCount":2,"versionedFlowState":"LOCALLY_MODIFIED","upToDateCount":0,"locallyModifiedCount":0,"staleCount":0,"locallyModifiedAndStaleCount":0,"syncFailureCount":0,"localInputPortCount":0,"localOutputPortCount":0,"publicInputPortCount":0,"publicOutputPortCount":0,"parameterContext":{"id":"<PARAMETR Context UUID>","permissions":{"canRead":true,"canWrite":true},"component":{"id":"994938a5-0180-1000-0000-00007cbba46b","name":"param-test"}},"inputPortCount":0,"outputPortCount":0},{"revision":{"clientId":"edcad62f-0181-1000-2fc6-de0c25282a3b","version":2},"id":"373a39ad-0443-10ec-9e85-69445fefe75e","position":{"x":-320,"y":-2216},"permissions":{"canRead":true,"canWrite":true},"component":{"id":"373a39ad-0443-10ec-9e85-69445fefe75e","parentGroupId":"7930f131-017b-1000-0000-00007ece6b9d","position":{"x":-320,"y":-2216},"name":"param3","comments":"","variables":{},"parameterContext":{"id":"994938a5-0180-1000-0000-00007cbba46b","permissions":{"canRead":true,"canWrite":true},"component":{"id":"<PARAMETR Context UUID>","name":"param-test"}},"flowfileConcurrency":"UNBOUNDED","flowfileOutboundPolicy":"STREAM_WHEN_AVAILABLE","runningCount":2,"stoppedCount":0,"invalidCount":0,"disabledCount":0,"activeRemotePortCount":0,"inactiveRemotePortCount":0,"upToDateCount":0,"locallyModifiedCount":0,"staleCount":0,"locallyModifiedAndStaleCount":0,"syncFailureCount":0,"localInputPortCount":0,"localOutputPortCount":0,"publicInputPortCount":0,"publicOutputPortCount":0,"inputPortCount":0,"outputPortCount":0},"runningCount":2,"stoppedCount":0,"invalidCount":0,"disabledCount":0,"activeRemotePortCount":0,"inactiveRemotePortCount":0,"upToDateCount":0,"locallyModifiedCount":0,"staleCount":0,"locallyModifiedAndStaleCount":0,"syncFailureCount":0,"localInputPortCount":0,"localOutputPortCount":0,"publicInputPortCount":0,"publicOutputPortCount":0,"parameterContext":{"id":"994938a5-0180-1000-0000-00007cbba46b","permissions":{"canRead":true,"canWrite":true},"component":{"id":"<PARAMETR Context UUID>","name":"param-test"}},"inputPortCount":0,"outputPortCount":0}],"id":"<PARAMETR Context UUID>"}}' --compressed
- This will return the uri for this new update request. A background process will take care of stopping changing, validating and starting all referenced components for the update parameter context. Assuming your NIFi is secured, your'll also need to include a method of authentication (client certificate, bearer token) in the above request.
3. Third you can execute a GET using the uri returned in step 2 to check progress of the request.
curl 'https://<hostname>:<port>/nifi-api/parameter-contexts/<PARAMETER CONTEXT UUID>/update-requests/<UPDATE REQUEST UUID form step 2 response>' -k --compressed
- This will return a json that will include within it the "percentCompleted". You'll need to check this endpoint until it reports 100% complete. Assuming your NIFi is secured, your'll also need to include a method of authentication (client certificate, bearer token) in the above request.
4. Final step is a DELETE to remove the update request that is now completed. Failing to do this leaves this request in NiFi Heap memory until a NiFi restart.
curl -X DELETE 'https://<hostname>:<port>/nifi-api/parameter-contexts/<PARAMETER CONTEXT UUID>/update-requests/<UPDATE_REQUEST UUID from step 2 response>' -k --compressed
- Assuming your NIFi is secured, your'll also need to include a method of authentication (client certificate, bearer token) in the above request.
An easy way to help understand the --data-raw input needed for your specific update-request is to use the developer tolls found in most browsers to inspect/capture that actual rest-api calls made when you execute the actual action via the NiFi UI. The browser developer tools will also allow you to right click on the triggering action and copy as curl. You can then paste that action as a curl command in a terminal window and execute it yourself.
Reference:
https://nifi.apache.org/docs/nifi-docs/rest-api/index.html
- specifically looking at the section for "Parameter Contexts"
If you found this response assisted with your query, please take a moment to login and click on "Accept as Solution" below this post.
Thank you,
Matt
Created 07-14-2022 10:03 PM
@Chakkara, Has the reply helped resolve your issue? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future.
Regards,
Vidya Sargur,Created 05-22-2023 01:16 AM
Thanks @MattWho for the answer.
Does it also has an alternative with toolkit ?
or any other easier process as Nifi evolved recent days?
Created 05-22-2023 03:20 AM
When you write a website with some links to other pages and maybe a form or two, you've already done real REST. The client (i.e. a web browser) presents the current resource to a user, automatically discovers related resources and allows the user to create/edit their own resources.
Why people don't apply the same principles to the APIs they write is baffling.