Chaffelson / nipyapi

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

processor to RPG connection #165

Closed ekovacs closed 11 months ago

ekovacs commented 4 years ago

Description

I'd like to propose a feature request.

The new feature would be, to allow creating a connection between a processor and a RemoteProcessGroup.

When using the web UI, drawing a connection between the two, causes a popup to appear, and there the user must select which input port the RPG would be transmitting to.

Currently, in canvas there exists a method which handles the creation of the connection, but when i am trying to supply an RPG as target,

nipyapi.canvas.create_connection(source=get_file_processor_entity, target=remote_process_group_entity)

it fails at infer_object_label_from_class for the target object.

Chaffelson commented 4 years ago

I have started to investigate this. It will require additional test harness to support properly, as I will need to test connecting between two separate NiFi instances and validating that objects passed are behaving correctly. I'll also need to work up the logic to handle up/down stream referencing of the ports.

hamzabekkouri commented 4 years ago

from my side, I tried to do this from a low level, I could do it using this function that I create myself

from nipyapi import canvas,nifi,config
from nipyapi.nifi import models

def create_remote_conenction(pg_id,id_rpg,source,available_rel,selected_rel):
    # get RPG information

    # id RPG
    # RPG object
    rpg = canvas.get_remote_process_group(rpg_id=rpg__id,summary=False)
    # Configure RPG remotly
    canvas.set_remote_process_group_transmission(rpg_exec, enable=True, refresh=True)
    # Remote input Port
    input_exec_port = rpg.component.contents.input_ports[0]
    # Create connection between processor and Remote nifi instance (RPG) 
    rev_conn_gin = models.RevisionDTO(version=0)
    local_source = models.connectable_dto.ConnectableDTO(id=source.id, type="PROCESSOR", group_id=pg_id)
    remote_destination = models.connectable_dto.ConnectableDTO(id=input_exec_port.id,type="REMOTE_INPUT_PORT", group_id=rpg.id)
    connection_dto = models.connection_dto.ConnectionDTO(source=local_source,destination=remote_destination,available_relationships=available_rel,selected_relationships=selected_rel)
    connection_entity = models.connection_entity.ConnectionEntity(revision=rev_conn_gin,component=connection_dto,source_type="PROCESSOR",destination_type="REMOTE_INPUT_PORT")
    PgApi = nifi.apis.process_groups_api.ProcessGroupsApi(api_client=None)
    PgApi.create_connection(id=pg_id,body=connection_entity)
Chaffelson commented 11 months ago

Closing as old, please reopen if the issue persists