I've done a search and the answer is pretty much no but in the spirit of the truly lazy programmer I will again ask!
I know you must hate this question but I'm interested in adding a set of nodes (mqtt topic and a button). I can build a json template file of the 3 nodes from an existing node set. Modify the json so it's easy to regexp but the tricky part is adding it to an existing flow (or a new flow if that's easier) then deploying it, all programmatically.
Are there any APIs for the node editor that would allow me do to this?
Perhaps just a way to programmatically add a new flow to the existing flows file and then manually deploy?
I can successfully gets the flows, there I see a flow with "id": "c5d7e07d.86e21". If I run the commands that follow, I get 404 (code not found - ???).
ID="c5d7e07d.86e21" # This is the "Flow 1" flow from the get /flows
API=flow/:${ID} ; echo ${API}
TOKEN=$(curl -s http://localhost:1880/auth/token --data 'client_id=node-red-admin&grant_type=password&scope=*&username=admin&password=Password' | jq -r '.access_token')
curl -v -H 'content-type: application/json' -H "Authorization: Bearer ${TOKEN}" http://localhost:1880/${API} -w '\nHTTP_RESPONSE: %{http_code}\n'
So what am I doing wrong? And before anyone asks, no Password isn't the actual password.
i dont know curl but 404 page not found means you are requesting to the wrong endpoint
is the colon : symbol included as part of the API variable ? if yes .. try to remove it
I'll work on figuring out the spacing and a few other details so I can later update the flow. I think there might also be a way to deploy the new flow via the API but I need to think about that.
Thanks
Initially, I got a whole lot of weird messages . I didn't see one that it was deployed. Just that it changed and I could review, merge or something else.
The fact that you got those messages means that it has been deployed. The editor notices that the flow it has is out of date and is asking you what to do about it.
Excellent! My evil plan to take over the world is now coming to fruition! Mwu-ha-ha-ha ...
Cool, I see that in the main flows is the information about various configurations (such as MQTT brokers) and I see the Tab ID, the node ID and the wires (next node ID). I found searching the forum how to create a new ID:
(1 + Math.random () * 4294967295) .toString (16)
As soon as I figure out the size of the nodes I can fit it to the x+y and add and delete as needed.