Blueprint Editor, How do you connect nodes with Python?

I am working to create scripts to make some redundant tasks easier in Unreal.
For instance, replacing a BlueprintGeneratedClass in a Blueprint (e.g. a struct with 50-100 pins).
Having found examples of creating Material Instances, and plugging in textures, would think there are similar methods in Blueprints.

What is desired is to be able to select an existing node with its numerous connections, and then transfer them to the new node.

The request is to be pointed in a direction for a Python Editor Utility, or unreal class that may have these methods. OR documention or a tutorial that shows how to list the “pins” a node has available, and/or how to disconnect/connect them.

Assumption: It would require listing the arbitrary pins, returning their input connections, and then connection those to the same pins in the other node.

Thanks for any help or directions.

Hello, I am also interested in editing blueprints automatically. I have done a general research on engine’s source code. Briefly speaking, I think this is not an easy task and some C++ wrapper is necessary.

This is what I have found up to now:
The code about connecting nodes (actually it is connecting pins under nodes) is at “Engine/Source/Runtime/Engine/Classes/EdGraph/EdGraphPin.h”; and these 3 functions are especially relative:

void MakeLinkTo(UEdGraphPin* ToPin);
void BreakLinkTo(UEdGraphPin* ToPin);
void BreakAllPinLinks(bool bNotifyNodes = false);

Before really change the connections, to get the correct pins, it is necessary to navigate within graphs. There are tens of different node classes and several different pin classes for different types of graphs. It needs allow of work to handle different classes.
After the connections are changed, it is necessary to call NodeConnectionListChanged() to make everything fine.

Since UE’s python is fully based on UFUNCTION while these relative functions are not wrapped with UFUNCTION, it is impossible to manipulate graphs in python now. However, it is easy to write some c++ function library to expose these functions to python.

I don’t think I can make an elegant solution in a short time. But in the long term, I think I will work on this topics, because editing-refactoring large complex Blueprints is horribly more difficult than text-base programming language.

If someone is also working on this topic, please share what you have achieved. Suggestions and pointing out me mistakes are also welcomed.
Thanks in advance.