How to make sense of the returned list of Flows from the `/flows` API?

So I am writing an ansible collection for node-red so that one can control multiple node-red instances without writing complicated code.

For the initial test case I developed a Lookup Plugin that will provide me the current list of flows on an instance:

This makes the ansible playbook:

- name: localhost
  tasks:
    - name: Get all flows from an instance
      set_fact:
         nodered_flows: "{{ lookup('nodered_flow', 'nodered_url=http://localhost/nodered nodered_user=admin nodered_password=admin') }}"

    - name: flows 
      debug: var=nodered_flows

Which works really nicely at the moment:

ok: [localhost] => 
  msg:
  - disabled: false
    env: []
    id: 44a1586775b5aa07
    info: ''
    label: tester_flow
    type: tab
  - crontab: ''
    id: c8695be143cd18a3
    name: ''
    once: false
    onceDelay: '5'
    payload: ''
    payloadType: date
    props:
    - p: payload
    - p: topic
      vt: str
    repeat: '10'
    topic: ''
    type: inject
    wires:
    - - 6225429b84c5b433
    x: 290
    y: 100
    z: 44a1586775b5aa07
  - active: true
    complete: 'false'
    console: false
    id: 6225429b84c5b433
    name: debug 1
    statusType: auto
    statusVal: ''
    tosidebar: true
    tostatus: false
    type: debug
    wires: []
    x: 660
    y: 120
    z: 44a1586775b5aa07

This essentially is the value when Node-RED-API-Version: v2 on HTTP API /flows and the plugin returns flows list. This is nice and all, but for an end-user the resultant is not very intuitive. All the elements in the list do not give a lot of intuitive information about the flows and neither does it state which element actually provides the list a better overview of what the current state is.

What were you hoping to get out?

I was hoping of getting a better summary for the flow e.g. which nodes, configs, subflows etc. are available in each flow.

That method, as I understand it, effectively just gives you the whole flows file contents.

I guess it is what it is. I tried using /flow/global but all it ever returns is:

{
  "id": "global"
}

Anyways I guess there is nothing too much I can do but either show the response of save the flow locally which can serve as download flows option.

All of the information you want is in the response. You just have to do some work to extract it.

  1. Look for all entries with type tab. These are the tabs/flows in the editor. Similarly, entries with type subflow are the subflows.
  2. For every other node, it's z property corresponds to the id of the tab (or subflow) that it is on.

If it doesn't have a z property, then it is a "global" config node.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.