Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

How can find a nifi process group id by Nifi rest api

avatar
New Member

I have a project that try to connect nifi-api and import-export templates programatically. I can upload and delete templates succesfully but when i tried to delete related connections and controller services i realise that i don't have target process group id.

I need make some belowed calls:

  • /process-groups/{id}/controller-services
  • /process-groups/{id}/connections
  • /flow/controller/controller-services
  • /process-groups/{id} (delete)

and some other calls.

I have just xml template at first and i dont know how i can find process group {id}.

Any idea please?

1 ACCEPTED SOLUTION

avatar
Guru

hi @nzr ytmn

When you are creating a process group, you usually provide a name for it. In the API results that come back from the /process-groups/root/ call, you could look for your name, and that would provide you with the process group ID associated with it. I just created a process group in NiFi and named it "TestTemplate". I then uploaded a template from my hard drive into the process group, and made the API call. The API results show this snippet:

{"id":"e6318a1e-015c-1000-ffff-ffffe7e2554b","name":"TestTemplate", .... }

As extra validation, if I go to the NiFi UI, I can see my process group and validate that the ID matches. Therefore I think you can use the API call I suggested above if I've understood your scenario correctly.

screen-shot-2017-08-10-at-94635-am.png

View solution in original post

9 REPLIES 9

avatar
Guru

Hi @nzr ytmn

Is it not in the information returned when you call the root? Something along the lines of: http://127.0.0.1:19090/nifi-api/flow/process-groups/root/status?recursive=true

avatar
New Member

@Sonu Sahi thanks for information, but still i am not sure how i can relate my template with process groups. I can use name of template file and compare with name of process group; but i am not sure this is good idea.

avatar
New Contributor

This will work

https://localhost:8080/nifi-api/process-groups/root/process-groups

 

This will print all the groups found in the main canvas

avatar
New Contributor

Use Case 1

How to get all the groups in the main canvas programmatically?

Answer:

url="https://localhost:8080/nifi-api/"

content_type="Content-Type: application/json"
curl -k "${url}${end_point}" -H "${content_type}" -H "${bearer}"
 
Use Case 2
How to get the groups after finding the root and it's child groups ?
For example
From the Root --> Karthik Playground ==> Csv_2_Kafka,  JSON_2_KAFKA
Karthik Playground consists of 2 process group csv_2_kafka and json_2_kafka
Root. (uuid "aaaa-bbbb"
    ==> Karthik Playground.  (uuid "cccc-dddd")
       ==> csv_2_kafka.  (uid "eeee-fff")
       ==> json_2_kafka.  (uid "gggg-hhhh")
 
  From the use case 1, we get all the UUid under Component for all the process groups in root.
  Get the uuid for karthik playground and pass like this
 

url="https://localhost:8080/nifi-api/"

content_type="Content-Type: application/json"
curl -k "${url}${end_point}" -H "${content_type}" -H "${bearer}"
 This will fetch csv_2_kafka and json_2_kafka
 
Do the same process to get the information from csv_2_kafka and json_2_kafka
 

avatar
Frequent Visitor

Is there a single rest api call to get all process groups across all canvases?

avatar
Frequent Visitor

avatar
New Member

process-group-id.png

When you select a processor group, the "Operate Palette" is populated with the process-group id. I've highlighted the location in the attached png.

,

process-group-id.png

When you clickon a process-group, the "Operate Palette" will populate the process-group id. I've highlighted it in the attached png.

avatar
New Member

@khadijah celestine i mean find a process group id of a template programmatically with nifi api requests.

avatar
Guru

hi @nzr ytmn

When you are creating a process group, you usually provide a name for it. In the API results that come back from the /process-groups/root/ call, you could look for your name, and that would provide you with the process group ID associated with it. I just created a process group in NiFi and named it "TestTemplate". I then uploaded a template from my hard drive into the process group, and made the API call. The API results show this snippet:

{"id":"e6318a1e-015c-1000-ffff-ffffe7e2554b","name":"TestTemplate", .... }

As extra validation, if I go to the NiFi UI, I can see my process group and validate that the ID matches. Therefore I think you can use the API call I suggested above if I've understood your scenario correctly.

screen-shot-2017-08-10-at-94635-am.png