Chaffelson / nipyapi

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

Unable to move a processor in the canvas (changing its position field) without deleting and creating it anew in the new position #328

Open noamg1911 opened 11 months ago

noamg1911 commented 11 months ago

Description

I have tried excessively to change a processor's position on the canvas, but to no avail. The update_processor function won't accept the position field, and according to your documentation I can't change it manually. I'd like to know if there's a way of moving the processor without the obvious workaround of deleting it and creating it in the new position (i.e. while it's still working).

What I Did

Unfortunately I don't have the output because I work in a private network environment. The error it gave was something about the version of the processor. If you'd like me to write it in a more accurate manner I can do that but I don't really see how this will help.

Urgency

Somewhat urgent, it's stopping the expected update to the prod environment. Thanks!

Chaffelson commented 11 months ago

So I had a bunch of trouble with this when I first implemented it, because NiFi wants the location to be supplied in a very specific manner. If you look at the create_processor function within canvas.py, it wants a LocationDTO object with x and y as Floats, but it also looks like that's a separate field to the update that we usually pass into the update_processor function.

body=nipyapi.nifi.ProcessorEntity(
              revision={'version': 0},
              component=nipyapi.nifi.ProcessorDTO(
                  position=nipyapi.nifi.PositionDTO(
                      x=float(location[0]),
                      y=float(location[1])
                  ),
                  type=processor.type,
                  name=processor_name,
                  config=target_config
              )
          )

Where config=target_config in the create function, we apply the update in the update function.

Probably what needs to be done is the ProcessorEntity object needs to be inspected by someone to see where the location change is applied. I usually do this by examining the payload of the update request in dev tools when doing it in the browser, then that will need to be added as an option in the update_processor function here