vFlow Developer Guide - SAP

30
INTERNAL 2019-03-27 vFlow Developer Guide © 2019 SAP SE or an SAP affiliate company. All rights reserved. THE BEST RUN

Transcript of vFlow Developer Guide - SAP

INTERNAL2019-03-27

vFlow Developer Guide

© 2

019

SAP

SE o

r an

SAP affi

liate

com

pany

. All

right

s re

serv

ed.

THE BEST RUN

Content

1 Document History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

3 List of Abbreviations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

4 Prerequisites. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

5 vFlow Content. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7

5.1 Overview of Pre-delivered vFlow Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

5.2 Pre-delivered DH vFlow Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Write Time Series. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Read Time Series – Measurements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Read Time Series - Aggregates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11

Read Thing Details by Query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Thing Configuration Reader. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15

Time Series Data Simulator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16

5.3 Debug Output in all Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

5.4 Pre-delivered Sample Graphs using vFlow Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Pipeline with Paging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Integrate Modify Time Filter Read Write Time Series. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Read Timeseries Performance Test. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

Thing Configuration by ID. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Data Simulator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21

Write Time Series. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

Integrate Read Configuration Read Aggregates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23

5.5 How to Run the Sample Graphs in SAP Data Hub Modeler. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23

5.6 How to Build a Graph in SAP Data Hub Modeler. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

5.7 How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls. . . . . . . . . . . . . .26

5.8 How to Get Various End Points for SAP Leonardo IoT API Calls. . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

5.9 How to Model Things in SAP Leonardo IoT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

2 I N T E R N A LvFlow Developer Guide

Content

1 Document History

View the list of changes to the document

Product Version Document Version Date Comments

SAP Leonardo IoT 1.0.0 March 27, 2019 Version release

vFlow Developer GuideDocument History I N T E R N A L 3

2 Introduction

SAP Leonardo IoT offers a comprehensive set of business services for customers to leverage the Internet of Things (IoT) technology to build new IoT applications or extend their existing core business scenarios.

The SAP Leonardo IoT content for SAP Data Hub provides operators for customers to consume select IoT business services in their SAP Data Hub pipelines, in combination with other operators. The content contains vFlow operators and sample vFlow graphs that can be imported to any SAP Data Hub environment.

These operators and sample graphs are tested in SAP Data Hub 2.4 environment.

Related Information

SAP Data Hub

4 I N T E R N A LvFlow Developer Guide

Introduction

3 List of Abbreviations

The following abbreviations are used in this guide.

Abbreviation Product Name

DH Data Hub

PST Property Set Type

TT Thing Type

vFlow Developer GuideList of Abbreviations I N T E R N A L 5

4 Prerequisites

The following are prerequisites for implementing SAP Leonardo IoT Content Guide for the SAP Data Hub Modeler.

In order to use the operators from the IoT {vSolution}, it is prerequisite that you have purchased a SAP Leonardo IoT license as well as a SAP Data Hub license. Both solutions need to be configured and operational.

● Download the SAP Leonardo IoT {vSolution} Package from the SAP Content Hub.Go to https://api.sap.com/ and navigate to the content type section Data Hub. Locate the SAP Leonardo IoT solution and the containing solution archive {tarball name}. Download the solution archive.

● Import the solution 'tarball' into your SAP Data Hub cluster.○ Follow the procedure described in the provided link to incorporate the downloaded solution into your

tenant strategy.○ See https://help.sap.com/doc/9ccfed19cabf4c46b4f6e5fb450a4670/2.4.latest/en-US/

70c7622a03da41efbe2013b141a082ed.html.● Setup your SAP Leonardo IoT Account.

○ The operators described below in this document require connectivity parameters. Follow the procedure described here to retrieve the service keys.

○ https://help.sap.com/viewer/9dfedbe95cbe4a9f9a5ceddbef7f88e5/1.70.0.0/en-US/afe265bcb4ba4c63bcab16f94ffbb34d.html

This package contains a list of vFlow operators and sample graphs using these operators. These sample graphs are provided only as a template. Customers should build their own graphs.

Once the package is imported as a solution in DH, the operators can be seen under IoT Business Services category. The sample graphs are in IoT Business Services Test Graphs category.

6 I N T E R N A LvFlow Developer Guide

Prerequisites

5 vFlow Content

The content is divided into two areas, vFlow operators and sample graphs which uses the vFlow operators.

5.1 Overview of Pre-delivered vFlow Operators

The following table lists all the pre-delivered vFlow operators. For more details about these vFlow operators, see Pre-delivered DH vFlow Operators [page 8].

You can locate this in the SAP Data Hub Modeler in the left hand toolbar under the section Operators.

Operator Description

Write Time series This operator creates time series data or derived data for a thing.

Measurements This operator reads time series measurements data for a property set type.

Aggregates This operator reads time series aggregates data for a prop­erty set type.

Thing Details by Query This operator returns a list output array which also includes the Thing Type. The input is a list of thing IDs.

Thing Configuration Reader This operator returns a list output array with the thing con­figuration (list of PSTs or detailed property level configura-tion). The input is a list which is the output of Thing Details by query operator.

Data Simulator This operator simulates test data based on the user configu-ration for a given thing and named_property_set.

vFlow Developer GuidevFlow Content I N T E R N A L 7

5.2 Pre-delivered DH vFlow Operators

The following sections list and explain all the DH vFlow operators that have been delivered. You can use them in your own pipeline graphs. You must create your own graphs based on your own system setup. These operators are available and visible within the IoT Business Services category.

NoteEven though the input ports of operators can receive an array containing a list of items, it will only process the first item in the array.

For example, in an input list as below, the operator will only process ‘_thingId1’.

[{‘_thingId1’:’<THING ID 1>}, {’_thingId2’:’<THING ID 2>}’, ………………{’_thingIdn’:’<THING ID n}’]

The script/operator which provides the list to the pre-delivered operators should take care of passing one by one, from the list, to the operator.

Example:

list_of_thing_ids = [{‘_thingId1’:’<THING ID 1},{’_thingId2’:’<THING ID 2}’,………………{’_thingIdn’:’<THING ID n}>’ ], for thing_id in list_of_thing_ids: api.send("dataout", [thing_id])

5.2.1 Write Time Series

Description

● This operator writes time series data or derived data for a thing.● You can find an example graph under Graphs tab in the left panel under com.sap.iot.writets.

8 I N T E R N A LvFlow Developer Guide

vFlow Content

Configuration Parameters

Parameter Description

Client ID Authentication Client ID retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Client Secret Authentication Client Secret retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Time Series Host URL Host URL for SAP Leonardo IoT retrieved from Service Keys (See How to Get Various End Points for SAP Leonardo IoT API Calls [page 26].)

OAuth2 Bearer Token URL OAuth URL for getting access token retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Inports:

● input (type python36):○ This operator accepts a python36 list of objects with a specified format.○ Every object in the list should possess the following fields:

○ thingId: Internal identifier for a thing○ thing_type_name: Name of a thing type○ named_pst (propertySetID): Unique identifier of the property type (that belongs to the property

set type) defined in a thing type○ values: A list of time series objects with the property values

○ Every object under 'values' list should have _time key to specify the timestamp.○ Timestamp values for _time key should follow yyyy-MM-dd’T’HH:mm:ss.SSS’Z’ format.○ Example: 2015-08-01T09:00:00.000Z

○ Input format[ { “_thingId”: “”, “_thing_type_name”: “”, “_named_pst”: “”, “values”: [ { “_time”: “”, “other properties…”: “” } ] } ]Example

[{ "_thingId": "FBF6E4E……..D6812F13BFFCE4EBF9","_thing_type_name": "{package name:thing type name}","_named_pst": "{named property set type}","values": [ { "_time": "2019-01-30T13:33:24.000Z", "property1": 0, "property2": 37, "temp2": 76 }, { "_time": "2019-01-30T13:33:23.000Z", "val1": 0, "temppcb": 184, "temp2": 36 }]}]

● config (type-string): Not applicable

Outports:

vFlow Developer GuidevFlow Content I N T E R N A L 9

● output (type-python36): Writes results in the form of HTTP status or error● debug (type string): Used for output of message throughput

5.2.2 Read Time Series – Measurements

Description

This operator reads time series measurements data for a given Thing ID and set of property set types entered in the configuration and also through the input message.

Configuration Parameters

Parameter Description

Client ID Authentication Client ID retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Client Secret Authentication Client Secret retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Time Series Host URL Host URL for SAP Leonardo IoT retrieved from Service Keys (See How to Get Various End Points for SAP Leonardo IoT API Calls [page 26].)

OAuth2 Bearer Token URL OAuth URL for getting access token retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Date Time Filter Date range as filter

Example: time gt datetime'2017-01-01T00:00:00' and time lt datetime'2019-03-01T00:00:00'

Property Set Type Property Set Type

Thing ID Thing ID

Inports:

● input (type python36):○ This operator accepts a python36 list of objects with a specified format.

10 I N T E R N A LvFlow Developer Guide

vFlow Content

○ This operator takes 3 types of input format (also in below priority based on what is entered/supplied):1. Using Configuration Parameters: If thing ID is entered as a configuration parameter, the priority

will be given to the entered thing ID and the other input format supplied will be not considered. This operator can be used for stand alone scenario where Time Series based on thing ID is required.

2. Specific Input Payload (as below) - If payload is sent to the input port in the below format, the time series data specific to the property set type entered in the configuration parameter will be validated and the respective property set measurement values will be retrieved.[{”_thingType”: “”, “_id”: “”, “_externalId”: “”, “_alternateId”: “”, “_name”: “”, “meta”: [{ “Description”: “”, “Name”: “”, “PropertySetType”: “”, “DataCategory”: ““ }, { “Description”: “”, “Name”: “”, “PropertySetType”: “”, “DataCategory”: “”}]}]Measurement values for only one of the incoming PropertySetType which matches the entered configuration parameter will be retrieved by the operator.

3. Next URL Payload - If there is a "Next_URL" available in the API output, this Next URL can be refered in as an input in the below format for retrieval of the same.

If the Next URL call results in a subsequent Next URL, the same can be sent again to the input port for subsequent retrieval of measurement.[{‘next_url’:”“,’_thing_type_name’: ‘’,’_named_pst’:’<NAMED PST’}]When you send message to the inport with the "Next_URL" schema, attach the thing type name and named pst which can be retrieved from the originating output message.

● config (type-string): Not applicable

Outports:

● output (type-python36): Output for all the respective input formats will always be in the below format:[{’_thingId’: ‘’, ‘_pst_ID’: ‘’, ‘_thing_type_name’: ‘’, ‘_named_pst’: ‘’, ‘values’: [{}]}]If Next URL is present, then the output will have the next url link in the output payload.[{’_thingId’: ‘’, ‘_pst_ID’: ‘’, ‘_thing_type_name’: ‘’, ‘_named_pst’: ‘’, “_next_url”:{ “endpoint”: “”, “thing_type_name”:”” , “_named_pst”:}, ‘values’: [{}]}]

● debug (type string): Used for output of message throughput

5.2.3 Read Time Series - Aggregates

Description

This operator reads time series aggregates data for a given Thing ID and set of property set type entered in the configuration or through the input message.

vFlow Developer GuidevFlow Content I N T E R N A L 11

Configuration Parameters

Parameter Description

Client ID Authentication Client ID retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Client Secret Authentication Client Secret retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Time Series Host URL Host URL for SAP Leonardo IoT retrieved from Service Keys (See How to Get Various End Points for SAP Leonardo IoT API Calls [page 26].)

OAuth2 Bearer Token URL OAuth URL for getting access token retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Date Time Filter Date range as filter

Example: time gt datetime'2017-01-01T00:00:00' and time lt datetime'2019-03-01T00:00:00'

Property Set Type Property Set Type

Thing ID Thing ID

Inports:

● input (type python36):○ This operator accepts a python36 list of objects with a specified format.○ This operator takes 3 types of input format (also in below priority based on what is entered/supplied):

1. Using Configuration Parameters: If thing ID is entered as a configuration parameter, the priority will be given to the entered thing ID and the other input format supplied will be not considered. This operator can be used for stand alone scenario where Time Series based on thing ID is required.

2. Specific Input Payload (as below): If payload is sent to the input port in the below format, the time series data specific to the property set type entered in the configuration parameter will be validated and the respective property set measurement values will be retrieved.[{”_thingType”: “”, “_id”: “”, “_externalId”: “”, “_alternateId”: “”, “_name”: “”, “meta”: [{ “Description”: “”, “Name”: “”, “PropertySetType”: “”, “DataCategory”: ““ }, { “Description”: “”, “Name”: “”, “PropertySetType”: “”, “DataCategory”: “”}]}]Measurement values for only one of the incoming PropertySetType which matches with the entered configuration parameter will be retrieved by the operator.

3. Next URL Payload: If there is a "Next_URL" available in the API output, this Next URL can be refered in as an input in the below format for retrieval of the same. If the Next URL call results in a subsequent Next URL, the same can be fed again to the input port for subsequent retrieval of measurement.

[{‘next_url’:”“,’_thing_type_name’: ‘’,’_named_pst’:’<NAMED PST’}]Since the API does not retrieve Thing Type Name and Named PST, values need to be supplied in the input payload so that it can be used for further operator integration with other operators.

● config (type-string): Not utilized

12 I N T E R N A LvFlow Developer Guide

vFlow Content

Outports:

● output (type-python36): Outputs for all the respective input formats will always be in the below format:[{’_thingId’: ‘’, ‘_pst_ID’: ‘’, ‘_thing_type_name’: ‘’, ‘_named_pst’: ‘’, ‘values’: [{}]}]If Next URL is present, then the output will have the next url link in the output payload.[{’_thingId’: ‘’, ‘_pst_ID’: ‘’, ‘_thing_type_name’: ‘’, ‘_named_pst’: ‘’, “_next_url”:{ “endpoint”: “”, “thing_type_name”:”” , “_named_pst”:}, ‘values’: [{}]}]

● debug (type string): Used for output of message throughput

5.2.4 Read Thing Details by Query

Description

For a given list of Thing IDs, this operator returns a list which contains Thing ID, External ID, Name, Description, Alternate ID and Thing Type.

Configuration Parameters

Parameter Description

Client ID Authentication Client ID retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Client Secret Authentication Client Secret retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Thing Configuration URL Host URL for SAP Leonardo IoT retrieved from Service Keys (See How to Get Various End Points for SAP Leonardo IoT API Calls [page 26].)

OAuth2 Bearer Token URL OAuth URL for getting access token retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Inports:

● input (type python36): Input list which is a Python 3 list of objects, which have a mandatory attribute thing id "_id".See the sample input below.

[ {

vFlow Developer GuidevFlow Content I N T E R N A L 13

"_id": "{thing_id1}", },{ "_id": "{thng_id2}", },{ "_id": "{thing_id3}", }]

NoteThe attribute thing id "_id" is mandatory.

Additional custom attributes may be passed, which will be passed down to the output list as is. However, there are some considerations to be noted which are described in the output section below.

● config (type-string): Not applicable

Outports:

● output (type python36): Output list which contains Thing ID, External ID, Name, Description, Alternate ID and Thing Type for each of the inputs providedSee the sample output below.

[ { "_thingType": "{thing type1}", "_id": "{thing_id1}", "_externalId": "{external_id1}", "_alternateId": "{alternate_id1}, "_name": "{name1}" }, { "_thingType": "{thing type2}", "_id": "{thing_id2}", "_externalId": "{external_id2}", "_alternateId": "{alternate_id2}, "_name": "{name1}" }, { "_thingType": "{thing type3}", "_id": "{thing_id3}", "_externalId": "{external_id3}", "_alternateId": "{alternate_id3}, "_name": "{name3}" } ]

NoteAny further attributes sent in the object within the input list will be passed to the output as is.

For example, if the following input is provided:

[ { "_id": "{thing_id}", "custom_attr1" : "abc", "custom_attr2" : "pqr" } ]

14 I N T E R N A LvFlow Developer Guide

vFlow Content

The output will be as shown below:

[ { "_thingType": "{thing_type}", "_id": "{thing_id}", "_externalId": "{external_id", "_alternateId": "{alternate_id}", "_name": "{name}", "custom_attr1" : "abc", "custom_attr2" : "pqr" } ]

● debug (type string): Used for output of message throughput

5.2.5 Thing Configuration Reader

Description

This operator returns a list of PSTs or detailed property level configurations for a Thing ID. The input is a list which is also the output of "Thing Details by query" operator.

Configuration Parameters

Parameter Description

Client ID Authentication Client ID retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Client Secret Authentication Client Secret retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Thing Configuration URL Host URL for SAP Leonardo IoT retrieved from Service Keys (See How to Get Various End Points for SAP Leonardo IoT API Calls [page 26].)

OAuth2 Bearer Token URL OAuth URL for getting access token retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Summary or Detailed Config ‘X’ or spaces X for detailed property level and spaces for summarized PST level configuration

Inports:

vFlow Developer GuidevFlow Content I N T E R N A L 15

● input (type python36): Input list which contains Thing ID, External ID, Name, Description, Alternate ID and Thing Type for each of the inputs provided. Only the thing type is mandatory among these fields. The rest is just passed through to the output. The input structure is the output returned by the operator com.sap.iot.thingdetailsbyquery.

● config (type-string): Not applicable

Outports:

● output (type python36): Output list which contains Thing ID, External ID, Name, Description, Alternate ID and Thing Type for each of the inputs provided, along with additional metadata. If summarized information is requested, then the PST list for each thing is provided. If the detailed configuration is requested, then the detailed hierarchical property level information is provided for each property set.See the sample output below:

[ { "_thingType": "{thing type1}", "_id": "{thing_id1}", "_externalId": "{external_id1}", "_alternateId": "{alternate_id1}, "_name": "{name1}" }, { "_thingType": "{thing type2}", "_id": "{thing_id2}", "_externalId": "{external_id2}", "_alternateId": "{alternate_id2}, "_name": "{name1}" }, { "_thingType": "{thing type3}", "_id": "{thing_id3}", "_externalId": "{external_id3}", "_alternateId": "{alternate_id3}, "_name": "{name3}" } ]

NoteThe attribute thing id "_id" and thing type "_thingType" is mandatory.

Additional custom attributes may be passed, which will be passed down to the output list as is. However, there are some considerations to be noted which are described in the output section.

● debug (type string): Used for output of message throughput

5.2.6 Time Series Data Simulator

16 I N T E R N A LvFlow Developer Guide

vFlow Content

Description

This operator simulates and outputs time series data for a given thing and named_property_set based on the configuration.

Configuration Parameters

Parameter Description

Client ID Authentication Client ID retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Client Secret Authentication Client Secret retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Thing URL Host URL to get Things for SAP Leonardo IoT retrieved from Service Keys (See How to Get Various End Points for SAP Leonardo IoT API Calls [page 26].)

Thing Configuration URL Host URL to get Thing Configurations for SAP Leonardo IoT retrieved from Service Keys (See How to Get Various End Points for SAP Leonardo IoT API Calls [page 26].)

OAuth2 Bearer Token URL OAuth URL for getting access token retrieved from Service Keys (See How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls [page 26].)

Thing ID Thing ID

Named Property Set Named Property Set

Start Time ● Data type: string● Format: YYYY-MM-DD hh:mm:ss● Sample value: 2018-09-09 05:30:46

Duration ● Data type: string● Format: number unit

○ number - any positive integer○ unit - seconds/minutes/hours

● Sample value: 180 seconds

Interval Value ● Data type: string● Sample value: 120

Interval Type ● Data type: string● Sample value: seconds● Legal values: seconds/minutes/hours

Records per Interval ● Data type: string

Property Data Range ● Data type: object● Sample: [{“name”: “Temperature”,

“specs”: {“max”: 25,“min”: 15,“valueType”: “Continuous”,“values”: null}}]

Inports:

vFlow Developer GuidevFlow Content I N T E R N A L 17

None

Outports:

● output (type python36): Outputs a random data stream● debug (type string): Used for output of message throughput

5.3 Debug Output in all Operators

All operators have an outport called "Debug". This provides the message throughput details for individual operators. The message throughput contains message rate (messages processed per second) and data points rate (data points processed per second). This information may be helpful to understand the performance of the individual operator.

5.4 Pre-delivered Sample Graphs using vFlow Operators

The following DH graphs are delivered as sample graphs using the delivered vFlow operators. You can use them as samples. You must create your own vFlows based on your own system setup.

These graphs are within the "IoT Business Services Test Graphs" category.

5.4.1 Pipeline with Paging

The Read operators retrieve a set of records (1000) per call of the Business Service. This is the limitation of the underlying business services when there is huge volume of rows to read. After the first read, the business

18 I N T E R N A LvFlow Developer Guide

vFlow Content

services output a pointer (Next URL) as part of the response. This pointer can be used to retrieve the next set of rows.

The graph below demonstrates the usage of "Next URL" along with Time Series Reader and Time Series Writer Operator combination.

Some key aspects of this graph are:

1. Start: Custom operator which prepares the payload for the message which is needed for "TS Measurements Reader" operator

2. Read TS measurements based on the input message and output to a custom operator3. Paging can inspect a message and in case the payload contains "nextURL" property, it can make a decision

to retrieve the next set of records (1000). The message is formulated containing "nextURL" and using the loop back port pipes the message back to TS Reader through the "Start" operator. In another out port, the message is also sent to "Write TS" operator. The data which is sent to #4 can also be manipulated here.

4. Write Time Series step writes the message back to the TS Store using the "Write TS" operator.

5.4.2 Integrate Modify Time Filter Read Write Time Series

Description

The graph below demonstrates the usage of multiple operators like Thing Configuration Reader, Timeseries transform the data and write time series data. After reading the Time Series data, the step "Update Time Series" modifies the data and using the Time Series Writer, the graph writes back the time series data. The step "Modify Time Filter" provides the time filter to the Time Series Reader rather than getting it from the configuration.

vFlow Developer GuidevFlow Content I N T E R N A L 19

Some key aspects of this graph are:

1. Send Thing IDs using a custom Python Operator.2. Retrieve additional properties for the Thing ID like Thing Type for a Thing.3. Enrich with additional metadata information like list of PSTs and/or get PST along with properties.4. Enrich a message with time filter (python script), based on customer decision.5. Read measurements based on Thing ID and PST and time filter.6. Custom python operator to manipulate a property within the PST (like inspecting one property and if it

exceeds some threshold value, then set some value for another property of names PST).7. Forward the message to a Write TS operator to write to timeseries.

5.4.3 Read Timeseries Performance Test

Description

The graph below demonstrates the usage of debug port in an operator which outputs the throughput data through an operator. In this example, Read Time Series operator is used which has two outputs, one outputs the times series data in a terminal and another outputs the through put in a terminal.

Some key aspects of this graph are:

1. Start is a custom python script which prepares the input for Read Measurements.2. Read Measurements calls the SAP Leonardo IoT Business Service.3. The terminal operator output displays the time series data.4. The terminal operator throughput displays the through put.

○ The message throughput contains message rate (messages processed per second) and data points rate (data points processed per second). This information may be helpful to understand the performance of the individual operator.

20 I N T E R N A LvFlow Developer Guide

vFlow Content

○ The sample output is as follows:

5.4.4 Thing Configuration by ID

Description

The graph below demonstrates the usage of combination of Thing details by Query and Thing Configuration Reader.

Some key aspects of this graph are:

1. Send Thing IDs is a custom python script which prepares the input for Thing details by query operator.2. Thing details by Query and Thing Configuration Reader operators are chained together.3. The output is written to a file using a Write File operator.

5.4.5 Data Simulator

Description

vFlow Developer GuidevFlow Content I N T E R N A L 21

The graph below demonstrates the usage of Data Simulator operator.

Some key aspects of this graph are:

1. Data Simulator operator produces the simulated time series data based on the operator configuration.2. The output is written to a terminal.

5.4.6 Write Time Series

Description

The graph below demonstrates the usage of Write Time Series operator.

Some key aspects of this graph are:

1. Input Time Series is a custom python script which prepares the input for Write Measurements.2. Write Time Series calls the SAP Leonardo IoT Business Service and writes the time series data.3. The Terminal operator output displays the results.

22 I N T E R N A LvFlow Developer Guide

vFlow Content

5.4.7 Integrate Read Configuration Read Aggregates

Description

The graph below demonstrates the usage of Read Aggregates operator along with reading the configurations.

Some key aspects of this graph are:

1. Sending Thing IDs is a custom python script which prepares the input for the graph.2. Thing details by Query and Thing Configuration Reader read the configuration for the Thing ID.3. Read Aggregates reads the aggregate details for the Thing ID based on the configuration.4. Write File writes the output to a file.

5.5 How to Run the Sample Graphs in SAP Data Hub Modeler

Context

Perform the below steps to run the sample graphs.

Procedure

1. Select the Graphs tab in the left panel and navigate to the specific graph.2. Set the initial starting point.

1. If there is a python script as the first script, then modify the script to suit your environment.2. If there is configuration (see the operator documentation section Pre-delivered DH vFlow Operators

[page 8]) in the starting operator, then provide the configuration parameters as per your environment.

vFlow Developer GuidevFlow Content I N T E R N A L 23

3. Click Save icon to save the graph.4. Select Run (play button) in the tool bar.5. The Status panel (at the bottom of the screen) indicates whether the graph is running.6. Use the context menu Open UI of the terminal node to open the terminal to see the results. If the graph is

writing to a file, then open the file in the File Management cockpit in the launch pad.7. To view a file, go to System Management in the datahub-app-launchpad. You can see the file in the tmp

folder depending upon your configuration.

5.6 How to Build a Graph in SAP Data Hub Modeler

Context

Perform the below steps to build a graph in the SAP Data Hub Modeler.

Procedure

1. Log in to SAP Data Hub Modeler.2. Select the Graphs pane.

24 I N T E R N A LvFlow Developer Guide

vFlow Content

3. Select the + in the pane.

You will get a blank page on the right-side pane.4. In the blank page, you can drag and drop the operators in the empty pane and build the graph.5. Click Save after the graph is completed.

6. Enter the name of the graph, description and category and click OK to save the graph.

7. Click the below icon to run the graph after it is saved.

vFlow Developer GuidevFlow Content I N T E R N A L 25

You can also refer the Modeling Guide for SAP Data Hub in SAP Help at the following URL:

https://help.sap.com/viewer/29ff74dc606c41acad117003f6034ac7/2.4.latest/en-US

5.7 How to Retrieve Client ID, Client Secret, Token URL for SAP Leonardo IoT API Calls

Context

Refer SAP Help documentation available at the following URL:

https://help.sap.com/viewer/195126f4601945cba0886cbbcbf3d364/1903a/en-US/a41c28db0cf449059d48c23fa5f7b24b.html

5.8 How to Get Various End Points for SAP Leonardo IoT API Calls

Context

Refer SAP Help documentation available at the following URL:

https://help.sap.com/viewer/080fabc6cae6423fb45fca7752adb61e/1903a/en-US/dcaa38dda9e14fbc887a3ebda36aec98.html

26 I N T E R N A LvFlow Developer Guide

vFlow Content

5.9 How to Model Things in SAP Leonardo IoT

Context

Refer SAP Help documentation available at the following URL:

https://help.sap.com/viewer/df885ae4541341c483433dc025f5521e/1.70.0.0/en-US

vFlow Developer GuidevFlow Content I N T E R N A L 27

Important Disclaimers and Legal Information

HyperlinksSome links are classified by an icon and/or a mouseover text. These links provide additional information.About the icons:

● Links with the icon : You are entering a Web site that is not hosted by SAP. By using such links, you agree (unless expressly stated otherwise in your agreements with SAP) to this:

● The content of the linked-to site is not SAP documentation. You may not infer any product claims against SAP based on this information.● SAP does not agree or disagree with the content on the linked-to site, nor does SAP warrant the availability and correctness. SAP shall not be liable for any

damages caused by the use of such content unless damages have been caused by SAP's gross negligence or willful misconduct.

● Links with the icon : You are leaving the documentation for that particular SAP product or service and are entering a SAP-hosted Web site. By using such links, you agree that (unless expressly stated otherwise in your agreements with SAP) you may not infer any product claims against SAP based on this information.

Beta and Other Experimental FeaturesExperimental features are not part of the officially delivered scope that SAP guarantees for future releases. This means that experimental features may be changed by SAP at any time for any reason without notice. Experimental features are not for productive use. You may not demonstrate, test, examine, evaluate or otherwise use the experimental features in a live operating environment or with data that has not been sufficiently backed up.The purpose of experimental features is to get feedback early on, allowing customers and partners to influence the future product accordingly. By providing your feedback (e.g. in the SAP Community), you accept that intellectual property rights of the contributions or derivative works shall remain the exclusive property of SAP.

Example CodeAny software coding and/or code snippets are examples. They are not for productive use. The example code is only intended to better explain and visualize the syntax and phrasing rules. SAP does not warrant the correctness and completeness of the example code. SAP shall not be liable for errors or damages caused by the use of example code unless damages have been caused by SAP's gross negligence or willful misconduct.

Gender-Related LanguageWe try not to use gender-specific word forms and formulations. As appropriate for context and readability, SAP may use masculine word forms to refer to all genders.

28 I N T E R N A LvFlow Developer Guide

Important Disclaimers and Legal Information

vFlow Developer GuideImportant Disclaimers and Legal Information I N T E R N A L 29

www.sap.com/contactsap

© 2019 SAP SE or an SAP affiliate company. All rights reserved.

No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an SAP affiliate company. The information contained herein may be changed without prior notice.

Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors. National product specifications may vary.

These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.

SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names mentioned are the trademarks of their respective companies.

Please see https://www.sap.com/about/legal/trademark.html for additional trademark information and notices.

THE BEST RUN