Back to top

Flow

Resource Group

Flows

Get the current configured flows
GET/v1/flow

Returns all currently configured flows

Example URI

GET /v1/flow
Request
HideShow
Headers
Content-Type: application/json; charset=utf-8
Authorization: Bearer JWT
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "flows": [
    {
      "name": "firstflow",
      "enabled": true,
      "id": "123456",
      "flow": [],
      "created": 1538070858845,
      "updated": 1538070858845
    }
  ]
}
Response  500
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "message": "Failed to list flows"
}

Configure a new flow
POST/v1/flow

Adds a new flow.

Example URI

POST /v1/flow
Request
HideShow
Headers
Content-Type: application/json; charset=utf-8
Authorization: Bearer JWT
Body
{
  "flow": [],
  "enabled": true,
  "name": "secondflow"
}
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "message": "ok",
  "flow": {
    "name": "secondflow",
    "enabled": true,
    "id": "123457",
    "flow": [],
    "created": 1538070858845,
    "updated": 1538070858845
  }
}
Response  400
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "message": "Missing mandatory field"
}
Response  500
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "message": "failed to create flow"
}

Removes all flows
DELETE/v1/flow

Removes all flows and their configurations.

Example URI

DELETE /v1/flow
Request
HideShow
Headers
Content-Type: application/json; charset=utf-8
Authorization: Bearer JWT
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "message": "All flows removed"
}
Response  500
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "message": "failed to remove flows"
}

Specific Flow

Get the current configured flow
GET/v1/flow/{id}

Returns the configuration of a particular flow

Example URI

GET /v1/flow/123456
URI Parameters
HideShow
id
string (required) Example: 123456

The identifier associated to the flow

Request
HideShow
Headers
Content-Type: application/json; charset=utf-8
Authorization: Bearer JWT
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "message": "ok",
  "flow": {
    "name": "firstflow",
    "enabled": true,
    "id": "123456",
    "flow": [],
    "created": 1538070858845,
    "updated": 1538070858845
  }
}
Response  500
HideShow
Body
{
  "msg": "failed to retrieve data"
}
Response  404
HideShow
Body
{
  "message": "Unknown flow: 777777",
  "flow": "777777"
}

Reconfigure a specific flow
PUT/v1/flow/{id}

Reconfigure a particular flow - the old config will be removed and the new one will be deployed.

Example URI

PUT /v1/flow/123456
URI Parameters
HideShow
id
string (required) Example: 123456

The identifier associated to the flow

Request
HideShow
Headers
Content-Type: application/json; charset=utf-8
Authorization: Bearer JWT
Body
{
  "name": "newflowname",
  "enabled": true,
  "flow": []
}
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "message": "ok",
  "flow": {
    "name": "newflowname",
    "enabled": true,
    "id": "123456",
    "flow": [],
    "created": 1538070858845,
    "updated": 1538070858845
  }
}
Response  404
HideShow
Body
{
  "message": "Unknown flow: 777777",
  "flow": "777777"
}
Response  500
HideShow
Body
{
  "msg": "failed to remove flow"
}

Remove the flow
DELETE/v1/flow/{id}

Removes the flow and its configuration.

Example URI

DELETE /v1/flow/123456
URI Parameters
HideShow
id
string (required) Example: 123456

The identifier associated to the flow

Request
HideShow
Headers
Content-Type: application/json; charset=utf-8
Authorization: Bearer JWT
Response  200
HideShow
Body
{
  "message": "flow removed",
  "flow": {
    "name": "firstflow",
    "enabled": true,
    "id": "123456",
    "flow": [],
    "created": 1538070858845,
    "updated": 1538070858845
  }
}
Response  500
HideShow
Body
{
  "msg": "failed to remove flow"
}
Response  404
HideShow
Body
{
  "message": "Unknown flow: 777777",
  "flow": "777777"
}

Nodes

Add a remote node
POST/v1/node

Adds a remote node

Example URI

POST /v1/node
Request
HideShow
Headers
Content-Type: application/json; charset=utf-8
Authorization: Bearer JWT
Body
{
  "image": "dojot/kelvin-example:3.0.0-alpha2",
  "id": "kelvin"
}
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "message": "ok"
}
Response  400
HideShow
Body
{
  "message": "Missing mandatory field"
}
Response  500
HideShow
Body
{
  "message": "Failed to add node"
}

Retrieve all remote nodes
GET/v1/node

Retrieve all currently running remote nodes

Example URI

GET /v1/node
Request
HideShow
Headers
Content-Type: application/json; charset=utf-8
Authorization: Bearer JWT
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "nodes": [
    {
      "id": "kelvin",
      "image": "raulnegreiros/kelvin:latest"
    }
  ]
}
Response  500
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "message": "Failed list nodes",
}

Remove a remote node
DELETE/v1/node/{id}

Removes a remote node

Example URI

DELETE /v1/node/kelvin
URI Parameters
HideShow
id
string (required) Example: kelvin

The identifier associated to the node

Request
HideShow
Headers
Content-Type: application/json; charset=utf-8
Authorization: Bearer JWT
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "message": "ok"
}
Response  500
HideShow
Body
{
  "message": "Failed to remove node.",
}

Remove all remote nodes
DELETE/v1/node

Removes a remote node

Example URI

DELETE /v1/node
Request
HideShow
Headers
Content-Type: application/json; charset=utf-8
Authorization: Bearer JWT
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "message": "ok"
}
Response  500
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "message": "Failed to remove node.",
}

NodeRED nodes

Retrieve all nodes
GET/nodes

The request can be sent with “Accept: application/json” header, which will generate a JSON object with a list of all nodes currently configured in Flowbroker. It can also be set with “Accept: text/html”. In this case, a huge HTML file is returned with all nodes HTML description and associated scripts so that it can be rendered in a frontend application (it will be composed by all HTML files associated to each node).

Example URI

GET /nodes
Request  for node JSON description
HideShow
Headers
Authorization: Bearer JWT
Accept: application/json
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
[
  {
    "id": "dojot/change",
    "name": "change",
    "module": "dojot",
    "version": "1.0.0",
    "enabled": true,
    "local": true,
    "types": [
      "change"
    ]
  }
]
Request  for node HTML
HideShow
Headers
Authorization: Bearer JWT
Accept: text/html
Response  200
HideShow
Headers
Content-Type: text/html; charset=utf-8
Body
<script type="text/x-red" data-template-name="change">
        <div class="form-row">
            <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
            <input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
        </div>
        <div class="form-row" style="margin-bottom:0;">
            <label><i class="fa fa-list"></i> <span data-i18n="change.label.rules"></span></label>
        </div>
        <div class="form-row node-input-rule-container-row">
            <ol id="node-input-rule-container"></ol>
        </div>

    </script>

    <script type="text/x-red" data-help-name="change">
        <p>Set, change, delete or move properties of a message, flow context or global context.</p>
        <p>The node can specify multiple rules that will be applied in turn.</p>
        <p>The available operations are:</p>
        <ul>
            <li><b>Set</b> - set a property. The value can be a variety of different types, or
                can be taken from an existing message or context property.</li>
            <li><b>Change</b> - search &amp; replace parts of the property. If regular expressions
                are enabled, the <b>replace with</b> property can include capture groups, for
                example <code>$1</code>. Replace will only change the <b>type</b> if there
                is a complete match.</li>
            <li><b>Delete</b> - delete a property.</li>
            <li><b>Move</b> - move or rename a property.</li>
        </ul>

    </script>

    <script type="text/javascript">
        RED.nodes.registerType('change', {
            color: "#E2D96E",
            category: 'function',
            defaults: {
                name: {value: ""},
                rules: {value: [{t: "set", p: "payload", pt: "msg", to: "", tot: "str"}]},
                // legacy
                action: {value: ""},
                property: {value: ""},
                from: {value: ""},
                to: {value: ""},
                reg: {value: false}
            },
            ....
        });
    </script>

NodeRED localization strings

Retrieve localization strings for node-red nodes
GET/locales/node-red

Example URI

GET /locales/node-red
Request
HideShow
Headers
Authorization: Bearer JWT
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "common": {
    "label": {
      "payload": "Payload",
      "topic": "Topic",
      "name": "Name",
      "username": "Username"
    }
  }
}

Generated by aglio on 03 Sep 2019