Flows Manager
14 min
the flows module manages node red flow instances on litmus edge note for reading or modifying the internal content of a flow (nodes, wires, tabs), use the node red api https //nodered org/docs/api/ directly the sdk only covers the flows manager service (lifecycle management) imports from litmussdk import flows common operations (3 x and 4 0 x) listing flows all flows = flows list flows() # list\[dict] \# each entry {id, name, memory limit, secret, tabs \[ ]} \# find a flow by name flow = next((f for f in flows list flows() if f\["name"] == "my flow"), none) creating a flow creates a stopped, empty flow fails if a flow with the same name already exists flow = flows create flow( name="my flow", secret="my secret", memory limit=256, ) flow id = flow\["id"] starting and stopping flows start flow(flow id) flows stop flow(flow id) calling start flow on a running flow (or stop flow on a stopped flow) will raise an error updating a flow flows update flow( flow id=flow id, name="renamed flow", memory limit=512, ) removing a flow destroys the flow and all its internal tabs flows remove flow(flow id) 4 0 x only operations these functions raise unsupportedversionerror when called against a 3 x device download flow file returns the raw json flow definition as bytes content bytes = flows download flow file(flow id) \# save to disk with open("my flow\ json", "wb") as f f write(content) 2 6 0 fix prior versions of the sdk silently utf 8 decoded the response, which corrupted binary content as of 2 6 0, download flow file and download flow logs route through a binary safe code path and return real bytes upgrade if you saw mangled output or the literal string "none" before download flow logs logs bytes = flows download flow logs(flow id) delete flow artifacts clean up individual flow artifacts without deleting the flow itself flows delete flow flows json(flow id) # removes flows json flows delete flow credentials(flow id) # removes credentials file flows delete flow logs(flow id) # removes log files flows delete flow node modules(flow id) # removes node modules license copyright (c) litmus automation inc