You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by ph...@orange.com on 2016/01/22 09:39:03 UTC

control nifi from REST API

Hello
I would like to control Nifi  by program an implement this:


1.       find the right template in the templates repository --> result T1

2.       instantiate the Template (T1)

3.       set properties on different processors contained in the topology T1

4.       start  T1

5.       stop T1 ( or be alerted when finished - I know it depends on the semantic of the topology of T1)

6.       remove T1 from the Topology Manager

7.       be ready to  loop to  step 1)

Please, do you think this workflow as implementable from java or groovy scripts making REST API calls  :)


Best regards
Philippe







_________________________________________________________________________________________________________________________

Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.

This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.


RE: control nifi from REST API

Posted by ph...@orange.com.
Thanks a lot  Matt ☺
It works nicely …

‘.  I would love any contributions or collaborations on this project if you are interested.’
Sorry I am not an expert  with gradle + groovy  but If I can  help …

Philippe
Best regards


De : Matthew Burgess [mailto:mattyb149@gmail.com]
Envoyé : vendredi 22 janvier 2016 13:57
À : users@nifi.apache.org
Objet : Re: control nifi from REST API

Philippe,

This is certainly possible using the REST API and whichever language you prefer.  I have started work on a Groovy-based project to do exactly this. It is called nifi-client and is on GitHub:

https://github.com/mattyb149/nifi-client

You can use it as a library (JAR) or perhaps more helpful is the “NiFi shell” which is a Gradle task that starts groovysh with the library already loaded. From the GitHub project directory type:

gradle —no-daemon shell

Then to connect to your instance you can do:
nifi = NiFi.bind('http://127.0.0.1:8080')

To get a map of templates (the map is name -> properties):
nifi.templates

To upload a template from a file:
nifi.templates << '/Users/mburgess/datasets/GetUserData.xml’

To instantiate a template, fetch by name and call instantiate:
nifi.templates.'GetUserData'.instantiate()

To export a template:
nifi.templates.’GetUserData’ >> ‘/path/to/export.xml'

To delete a template:
nifi.templates.'GetUserData’.delete()

To get a map of processors (the map is name -> properties):
nifi.processors

To get a list of processor names:
nifi.processors*.key

To start a processor, fetch by name and call start:
nifi.processors.'Fetch User Data'.start()

The above also works for stop(), enable(), and disable()

To get the current state of a processor:
nifi.processors.'Fetch User Data'.state

I haven’t added the ability to change individual properties of a processor yet (just the state), but most of the other steps in your workflow should be covered.  I would love any contributions or collaborations on this project if you are interested.

Regards,
Matt

From: <ph...@orange.com>>
Reply-To: <us...@nifi.apache.org>>
Date: Friday, January 22, 2016 at 3:39 AM
To: "users@nifi.apache.org<ma...@nifi.apache.org>" <us...@nifi.apache.org>>
Subject: control nifi from REST API

Hello
I would like to control Nifi  by program an implement this:


1.       find the right template in the templates repository --> result T1

2.       instantiate the Template (T1)

3.       set properties on different processors contained in the topology T1

4.       start  T1

5.       stop T1 ( or be alerted when finished – I know it depends on the semantic of the topology of T1)

6.       remove T1 from the Topology Manager

7.       be ready to  loop to  step 1)

Please, do you think this workflow as implementable from java or groovy scripts making REST API calls  ☺


Best regards
Philippe







_________________________________________________________________________________________________________________________



Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc

pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler

a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,

Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.



This message and its attachments may contain confidential or privileged information that may be protected by law;

they should not be distributed, used or copied without authorisation.

If you have received this email in error, please notify the sender and delete this message and its attachments.

As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.

Thank you.

_________________________________________________________________________________________________________________________

Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.

This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.


Re: control nifi from REST API

Posted by Matthew Burgess <ma...@gmail.com>.
Philippe,

This is certainly possible using the REST API and whichever language you prefer.  I have started work on a Groovy-based project to do exactly this. It is called nifi-client and is on GitHub:

https://github.com/mattyb149/nifi-client

You can use it as a library (JAR) or perhaps more helpful is the “NiFi shell” which is a Gradle task that starts groovysh with the library already loaded. From the GitHub project directory type:

gradle —no-daemon shell

Then to connect to your instance you can do:
nifi = NiFi.bind('http://127.0.0.1:8080')

To get a map of templates (the map is name -> properties):
nifi.templates

To upload a template from a file:
nifi.templates << '/Users/mburgess/datasets/GetUserData.xml’

To instantiate a template, fetch by name and call instantiate:
nifi.templates.'GetUserData'.instantiate()

To export a template:
nifi.templates.’GetUserData’ >> ‘/path/to/export.xml'

To delete a template:
nifi.templates.'GetUserData’.delete()

To get a map of processors (the map is name -> properties):
nifi.processors

To get a list of processor names:
nifi.processors*.key

To start a processor, fetch by name and call start:
nifi.processors.'Fetch User Data'.start()

The above also works for stop(), enable(), and disable()

To get the current state of a processor:
nifi.processors.'Fetch User Data'.state

I haven’t added the ability to change individual properties of a processor yet (just the state), but most of the other steps in your workflow should be covered.  I would love any contributions or collaborations on this project if you are interested.

Regards,
Matt

From:  <ph...@orange.com>
Reply-To:  <us...@nifi.apache.org>
Date:  Friday, January 22, 2016 at 3:39 AM
To:  "users@nifi.apache.org" <us...@nifi.apache.org>
Subject:  control nifi from REST API

Hello 

I would like to control Nifi  by program an implement this:

 

1.      find the right template in the templates repository --> result T1

2.      instantiate the Template (T1)

3.      set properties on different processors contained in the topology T1

4.      start  T1

5.      stop T1 ( or be alerted when finished – I know it depends on the semantic of the topology of T1)

6.      remove T1 from the Topology Manager 

7.      be ready to  loop to  step 1)

 

Please, do you think this workflow as implementable from java or groovy scripts making REST API calls  J

 

 

Best regards

Philippe

 

 

 

 

 

 
_________________________________________________________________________________________________________________________

Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.

This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.