Chaffelson / nipyapi

A convenient Python wrapper for Apache NiFi
Other
244 stars 76 forks source link

Is it possible to change parent of a child processor group ? #206

Closed guptasakshi01 closed 3 years ago

guptasakshi01 commented 4 years ago

Description

I am trying to move child processor from one parent processor group to another process.or group. is it possible to achieve it using nipyapi.canvas.update_processor ?

guptasakshi01 commented 4 years ago

I tried using update processor but its giving below error; Although Processor is present with ID

    dto = nipyapi.nifi.ProcessorConfigDTO()
    dto.parent_group_id = parent_id
    nipyapi.canvas.update_processor(processor, dto)

HTTP response headers: HTTPHeaderDict({'Date': 'Thu, 25 Jun 2020 12:53:58 GMT', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Security-Policy': "frame-ancestors 'self'", 'X-XSS-Protection': '1; mode=block', 'Strict-Transport-Security': 'max-age=31540000', 'Content-Type': 'text/plain', 'Vary': 'Accept-Encoding', 'Content-Length': '149', 'Server': 'Jetty(9.4.11.v20180605)'}) HTTP response body: ****:**** is unable to fulfill this request due to: Unable to find processor with id 'xxxxxxxxxxxxxxxxxxxxxxx'.

guptasakshi01 commented 4 years ago

Tried using below as well, it gets executed successfully but processor group is not getting updated.

processor = nipyapi.canvas.get_process_group("xxxxxxxxxxxxxxxxxxxxxxxxx", identifier_type='id')
nipyapi.canvas.update_process_group(processor, {"parent_group_id":"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"})
Chaffelson commented 4 years ago

Pretty sure this cannot be done. The server API service will drop or ignore fields it doesn't like silently sometimes, and I suspect that is why you are getting a valid response but not the change you expect.

If it works for your use case, I would create a new instance of the Processor in the destination area, then copy the configuration from the Processor in the Source area.

guptasakshi01 commented 4 years ago

How can I copy all configuration from processor in source to destination ?

Chaffelson commented 4 years ago

You would have to use get_processor, then extract the non-default parts of the configuration, then use that to update_processor on the Target. There is no wrapper function for this because there are too many variations to handle, such as sensitive properties and resolving UUIDs for dependent Controller Services, or Version Control. I suggest you make something for your specific usecase :)

guptasakshi01 commented 4 years ago

Let me give it a try Thanks @Chaffelson :)