Updated on 2022-09-20 GMT+08:00

Creating a Rule Engine Source

Function

This API is used to create the source of a rule engine on ROMA Connect.

URI

POST /v1/{project_id}/link/instances/{instance_id}/rules/sources

Table 1 Parameter description

Parameter

Type

Mandatory

Description

project_id

string

Yes

Project ID of each region of a tenant.

instance_id

string

Yes

ID of the ROMA Connect instance used by the tenant.

Request

Request parameters

Table 2 Body parameter description

Parameter

Type

Mandatory

Description

app_id

string

No

Application ID. This parameter is mandatory when no rule exists in the system.

rule_name

string

Yes

Name of a rule that has been created. If the rule does not exist, it will be created by default.

level

string

Yes

Rule level. The value product indicates that a rule of the product level. The value device indicates that a rule is of the device level.

product_name

string

Yes

Name of a product that has been created.

device_name

string

No

Name of a device that has been created. If the rule level is product, the device_name parameter is not transferred.

topic

string

No

Name of the topic corresponding to a device. Only topics with the pub permission can be used. Topics of each device can be added to only one rule. Topic parameters do not need to be transmitted if the rule level is product.

is_base64

boolean

Yes

Whether to perform Base64 encoding on forwarded messages. If this parameter is set to true, Base64 encoding is performed on messages.

contain_deviceinfo

boolean

No

Whether the forwarded message contains device information. If this parameter is set to true, additional device information is added to the original message.

Example request

https://example.cloud.com/v1/80e2b******f4a398d6409a50932d917/link/instances/fb3b24ab-5d87-473d-9c57-fc6******6a1/rules/sources 
{
    "app_id" : "app01",
    "rule_name" : "rule01",
    "product_name" : "product01",
    "device_name" : "device01",
    "topic" : "7aANi9569518/out/ device01",
    "is_base64" : false,
    "contain_deviceinfo" : false,
    "level" : "device"
}

Response

Response parameters

Table 3 Response parameter description

Parameter

Type

Description

clientId

string

Client ID of a device.

dataFormatTrans

string

Data transmission format of the forwarded message. If is_base64 is set to true, the transmission format is base64/raw. If is_base64 is set to false, the transmission format is json/raw.

deviceOid

integer

Device ID.

instanceNo

integer

ID of a data source instance.

productOid

integer

Product ID.

ruleOid

integer

Rule ID.

ruleSrcLevel

integer

Rule level. The value 0 indicates product-level and the value 1 indicates device-level.

ruleSrcOid

integer

Rule source ID.

topicName

string

Topic name.

Example response

{
    "clientId": "D5695180f67c7200",
    "topicName": "7aANi9569518/out/ device01",
    "ruleSrcOid": 38,
    "ruleOid": 600004,
    "ruleSrcLevel": 1,
    "productOid": 569518,
    "deviceOid": 354769,
    "instanceNo": 1212,
    "dataFormatTrans": "json/raw"
}