Ashish,
I don't have the 0.7 docs in front of me so I'm not sure if/how it is
possible there, but it is definitely possible via the 1.0 REST API
[1]. Procedure is as follows:
If the process group already exists in the flow (and you know its ID),
here are some REST API calls that should create a template from it:
1) Determine the parent process group ID. If the process group is at
the top level, I believe you can use "root". In any case you could get
the parentGroupId by doing a GET
nifi-api/process-groups/<process_group_id>, the parentGroupId is
available in the response, as is "clientId" and "version" which you
can use below.
2) Create a snippet by POST'ing something similar to the following to
nifi-api/snippet:
{"snippet":{"parentGroupId":"48b93e09-0157-1000-9e3a-f95fffd1a69e","processors":{},"funnels":{},"inputPorts":{},"outputPorts":{},"remoteProcessGroups":{},"processGroups":{"70c6ac33-0157-1000-ecd5-a2680dd6e8ad":{"clientId":"70c56ee6-0157-1000-b298-89976e64b8a5","version":2}},"connections":{},"labels":{}}}
here "parentGroupId" is the id of the parent process group, and
"processGroups" contains only the ID of the process group you want to
create a template from. Also "version" should be the latest version of
the process group, which I believe should be one greater than the
version you retrieved in Step 1 (but equal might work too, can't
remember).
The POST returns a JSON payload with (among other things) a snippet ID.
3) Use the snippet ID in a POST
nifi-api/process-groups/<parentGroupId>/templates:
{"name":"<your_template_name>","description":"<your_template_description>","snippetId":"<snippet_id>"}
This returns a JSON payload with (among other things) a template ID.
4) Use the template ID in a GET
nifi-api/templates/<template_id>/download, the payload will be the
contents of the template.
Maybe someone with the 0.7 REST API docs handy can check for similar
API calls that would create a snippet, create a template, then export
the template.
Regards,
Matt
[1] https://nifi.apache.org/docs/nifi-docs/rest-api/index.html
On Wed, Sep 28, 2016 at 8:02 AM, Oleg Zhurakousky
<[email protected]> wrote:
> Ashish
>
> As Joe pointed out, while “possible”, at the moment we don’t expose a direct
> public API to accomplish that. When I say “possible” I am of course referring
> to the internal API that is used by NIFi (NIFI UI that is) to wire up flows,
> but at the moment it is neither public nor it is the preferred approach.
> That said, I am still wondering as to “what" is the issue you are
> experiencing? I mean you are clearly describing what you want to do, but I am
> missing the “why” part.
> Please don’t take it the wrong way. . . You may very well have legitimate
> reasons to do what you need to do. All we are trying to do is to understand
> those reasons so we in the NiFi community can determine if it is indeed a
> missing yet valuable feature we can/should put on the road map.
>
> Cheers
> Oleg
>
>
>> On Sep 28, 2016, at 7:49 AM, Ashish Agarwal 10 <[email protected]>
>> wrote:
>>
>> Hello,
>>
>> I am using Nifi 0.7.0.
>> I want to create the template of the processor groups.
>> Instead of creating it from UI. I want to design a flow that creates a
>> processor group template based on its id, download it and store it somewhere
>> locally.
>> Is it possible ? If yes, Is there any method/api available for the same?
>>
>> Thanks You
>> Ashish Agarwal
>>
>> -----Original Message-----
>> From: Joe Witt [mailto:[email protected]]
>> Sent: Tuesday, September 27, 2016 6:06 PM
>> To: [email protected]
>> Subject: Re: Create NiFi Templates
>>
>> Ashish,
>>
>> If the question is 'at runtime what are the ways I could trigger the
>> creation of a NiFI template?'
>>
>> You could call the REST API endpoint using some mechanism other than
>> the NiFi UI or you could use the NiFi UI.
>>
>> If the question is 'can I programmatically create a template during
>> development time?'
>>
>> We don't have any direct public API's to accomplish this that I am
>> aware of though it is an interesting idea.
>>
>> Can you help direct us to where you're more interested right now so we
>> can help most effectively.
>>
>> Thanks
>> Joe
>>
>> On Tue, Sep 27, 2016 at 8:31 AM, Oleg Zhurakousky
>> <[email protected]> wrote:
>>> Ashish
>>>
>>> I am not sure I fully understand the question. . .
>>> Templates represented as an XML file and therefore if you “type everything
>>> correctly” you’ll get a working template, but it would be simpler to use
>>> NIFI UI as a design tool to do the same.
>>> Could you please clarify more as to what exactly are you trying to
>>> accomplish?
>>>
>>> Cheers
>>> Oleg
>>>
>>> On Sep 27, 2016, at 3:06 AM, Ashish Agarwal 10 <[email protected]>
>>> wrote:
>>>
>>> Hello,
>>>
>>> Is there a way to create a template of a process group other than the button
>>> present on UI ?
>>>
>>> Regards,
>>> Ashish Agarwal
>>>
>>>
>