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:  <[email protected]>
Reply-To:  <[email protected]>
Date:  Friday, January 22, 2016 at 3:39 AM
To:  "[email protected]" <[email protected]>
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.

Reply via email to