Skip to content

Latest commit

 

History

History
233 lines (138 loc) · 8.13 KB

File metadata and controls

233 lines (138 loc) · 8.13 KB

Using Notifier OpenAPI within the Flow Creator

Launch the Flow Creator

The Flow Creator, the Notifier and the custom app must be installed on the same Edge Device. Open and login to the Flow Creator. The following chapters describe how to execute the Notifier OpenAPI requests step by step. All OpenAPI commands are executed via a http request.

A ready-to-use flow, that contains all these steps, can be downloaded here and imported into the Flow Creator.

List all notifications

In case of passing the defined limits of the KPI value, the custom app sends notifications to the Notifier. These notifications can also be listet in the Flow Creator by using the corresponding API request.

flow_get_all

The following nodes are needed:

inject -- function -- http request -- debug

If you check the API documantation for this request, the parameter "notificationSource" is required. The function "set params" sets the mandatory parameter, which is later used in the URL of the http request:

msg.notificationSource = {}
msg.notificationSource = "KPI calculation app";
return msg;

The http request node implements the corresponding Notifier API call:

api_get_all

Therefore you need to configure a GET request with the following URL:

http://notifier:4201/notificationservice/notifications/ext/active?notificationSource={{{notificationSource}}}

Deprecated API request

The deprecated API request (V1.0) also works. Therefore no parameter is necessary to send the API request.

flow_get_all_old

The following nodes are needed:

inject -- http request -- debug

The http request node implements the corresponding Notifier API call:

api_old_get_all

Therefore you need to configure a GET request with the following URL:

http://notifier:4201/notificationservice/notifications

Testing the API request

To get all currently active notifications via these Flow Creator nodes, just trigger the inject node.

flow_get_all_result

List one notification

It is also possible to list just one specific notification which is active.

flow_get_one

The following nodes are needed:

inject -- function -- http request -- debug

If you check the API documantation for this request, the parameters "notificationId" and "notificationSource" are necessary. The function "set params" sets the mandatory parameters, which are later used in the URL of the http request:

msg.notificationId = {}
msg.notificationSource = {}
msg.notificationId = "36";
msg.notificationSource = "KPI calculation app";
return msg;

The http request node implements the corresponding Notifier API call:

api_get_one

Therefore you need to configure a GET request with the following URL:

http://notifier:4201/notificationservice/notifications/ext/active/{{{notificationId}}}?notificationSource={{{notificationSource}}}

Deprecated API request

The deprecated API request (V1.0) also works. Therefore only the parameter "notificationSource" is necessary.

flow_get_one_old

The following nodes are needed:

inject -- function -- http request -- debug

The http request node implements the corresponding Notifier API call:

api_old_get_all

Therefore you need to configure a GET request with the following URL:

http://notifier:4201/notificationservice/notifications/{{{notificationId}}}

Testing the API request

To get the defined notification via these Flow Creator nodes, just trigger the inject node.

flow_get_one_result

Accept one notification

It is possible to accept an active notification.

flow_accept

The following nodes are needed:

inject -- function -- http request -- debug

If you check the API documantation for this request, the parameters "notificationId", "userId" and "notificationSource" are necessary. The function "set params" sets the mandatory parameters, which are later used in the URL of the http request:

msg.notificationId = {}
msg.userId = {}
msg.notificationSource = {}
msg.notificationId = "39";
msg.userId = "test@siemens.com"
msg.notificationSource = "KPI calculation app";
return msg;

The http request node implements the corresponding Notifier API call:

api_accept

Therefore you need to configure a PUT request with the following URL:

http://notifier:4201/notificationservice/notifications/{{{notificationId}}}/ext/accept?userId={{{userId}}}&notificationSource={{{notificationSource}}}

Testing the API request

To accept a notification via these Flow Creator nodes, just trigger the inject node.

flow_accept_result

Clear one notification

It is possible to clear an active notification.

flow_clear

The following nodes are needed:

inject -- function -- http request -- debug

If you check the API documantation for this request, the parameter "notificationId" is necessary. The function "set params" sets the mandatory parameter, which is later used in the URL of the http request:

msg.notificationId = {}
msg.notificationId = "14";
return msg;

The http request node implements the corresponding Notifier API call:

api_clear

Therefore you need to configure a PUT request with the following URL:

http://notifier:4201/notificationservice/notifications/{{{notificationId}}}/ext/clear

Testing the API request

To clear the defined notification via these Flow Creator nodes, just trigger the inject node.

flow_clear_result

Raise one notification

It is possible to raise a further notification within the Flow Creator. The new notification gets an unique notificationId for identification.

flow_raise

The following nodes are needed:

inject -- function -- http request -- debug

If you check the API documantation for this request, a request body is necessary, containing "notificationTypeId", "eventText", "assetId" and "notificationSource". The function "set request body" sets the mandatory parameters within the request body for the http POST request.

msg.payload = {}
msg.payload={
  'notificationTypeId': '3',
  'eventText': 'INFO from Flow Creator',
  'assetId': '<YourAssetId>',
  'notificationSource': 'FlowCreator'
};
return msg;
  • notificationTypeId: 1 (alert) / 2 (warning) / 3 (information)
  • eventText: message text (can be any string)
  • assetId: id of asset in Data Service (looks like '549c3daa33cd4628b02c2e2745f54d80')
  • notificationSource: who sended the notification, e.g. "KPI calculation app" (can be any string)

AssetId: To get the assetId, either look up in Data Service > select asset > copy id from URL OR execute a http request to GET notification and copy the assetId from the response.

get_assetid_1 get_assetid_2

The http request node implements the corresponding Notifier API call:

api_raise

Therefore you need to configure a POST request with the following URL:

http://notifier:4201/notificationservice/notifications/ext/raise

Testing the API request

To send the defined notification via these Flow Creator nodes, just trigger the inject node.

flow_raise_result flow_raise_result_2