Create rules
Create rules to capture messages sent to a topic and add actions to perform various other actions.
Prerequisites:
- Activate a group in Trimble IoT using the Groups API.
- Activate a device in Trimble IoT using the Devices API.
Create a rule using the Rules API. For more information refer to the API documentation.
Configure Data Ocean action
Messages captured in a rule can be uploaded to a Data Ocean directory as files. This can be done by adding a Data Ocean action.
Steps to configure Data Ocean action:
-
Create a directory in Data Ocean and provide write permissions to the below IoT Application using ACL using the Create Directory API.
Environment IoT Application Id Stage 2642d8bb-04f3-47d6-b367-8b4ea2374fee Production 957483ec-62e2-41ad-8aa9-5861be08b4fd -
Create/Update a rule with Data Ocean action. Refer to the Rules API.
Sample request
"dataocean": {"bufferSeconds": 60,"directoryId": "28233f73-eb79-4411-aaea-9b33691217a0"}Sample response
"dataocean": {"path": "7ecbd2a4-9ab9-4085-be24-ce80c0279cbd:/messages","directoryId": "28233f73-eb79-4411-aaea-9b33691217a0"} -
Send inbound messages to the topic defined in the rule. Messages will be captured every given bufferSeconds interval and uploaded as files. The files will be uploaded to the following directory format {Year}/{Month}/{Date}/{Hour}/ (Example: 2023/06/23/10).
-
Use the List files in a directory API to get the list of files. Append the path from the response and the directory format mentioned in the above step to get the file path. (Example: 7ecbd2a4-9ab9-4085-be24-ce80c0279cbd:/messages/2023/06/23/10).