Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- * Endpoints
- * [Get All Triggers For Organization](#GetAllTriggersForOrganization)
- * [Get Trigger By ID](#GetTriggerByID)
- * [Create Trigger](#CreateTrigger)
- * [Update Trigger](#UpdateTrigger)
- * [Add Action](#AddAction)
- * [Remove Action](#RemoveAction)
- * [Start Trigger](#StartTrigger)
- * [Stop Trigger](#StopTrigger)
- * [Delete Trigger](#DeleteTrigger)
- * [Add Watcher](#AddWatcher)
- * [Delete Watcher](#DeleteWatcher)
- * Topics
- * [Trigger Updates For Organization](#TriggerUpdatesForOrganization)
- # ENDPOINTS
- ## Get All Triggers For Organization
- ```text
- REQUEST /triggers/getAllForOrganization/{organizationId}
- ```
- ### Response payload
- ```json
- [
- {
- "id":"8c227e3b-a13a-40fb-a9d7-8d8fd05e1a9a",
- "queryId":"59b9ad97-5eb1-4d5b-b34a-09efdcce5a60",
- "watchers":[
- "6fdf59c4-2f6a-471f-afc0-4666ead68ad4",
- "88d261a8-b442-4838-9251-2197ab3222ea"
- ],
- "ownerOrganizationId":"b6f204fb-e95d-48a9-a5ea-a6188074510e",
- "name":"trigger name",
- "description":"trigger description",
- "actions":[
- {
- "id":"a4e6cc29-17a4-431f-8009-4bef09471caf",
- "type":"rest",
- "url":"http://test.com",
- "method":"GET",
- "contentType":"application/json",
- "bodyTemplate":"test body"
- }
- ],
- "running":true,
- "matchDelay":1000,
- "matchInterval":2000,
- "minTriggerInterval":3000,
- "minMatchDuration":4000,
- "maxMatchDuration":12000
- }
- ]
- ```
- * **id** - Trigger ID
- * **queryId** - pattern query to listen
- * **watchers** - list of users who will receive notifications for this trigger
- * **ownerOrganizationId** - UUID. Organization ID.
- * **name** - user friendly trigger name
- * **description (optional)** - human readable trigger description
- * **actions** - additional actions that will execute on trigger fire. Fields depends on *type*
- * **running** - Trigger run status (false is stopped)
- ##### Conditions to match: below values describes conditions that should match for trigger to fire
- * **matchDelay** - time to wait before first check
- * **matchInterval** - time between checks
- * **minTriggerInterval (optional)** - min time between consecutive action triggering
- * **minMatchDuration (optional)** - min match duration to triggerAction action
- * **maxMatchDuration (optional)** - max match duration to triggerAction action
- ## Get Trigger By ID
- ```text
- REQUEST /triggers/getById/{triggerId}
- ```
- ### Response payload
- ```json
- {
- "id":"8c227e3b-a13a-40fb-a9d7-8d8fd05e1a9a",
- "queryId":"59b9ad97-5eb1-4d5b-b34a-09efdcce5a60",
- "watchers":[
- "6fdf59c4-2f6a-471f-afc0-4666ead68ad4",
- "88d261a8-b442-4838-9251-2197ab3222ea"
- ],
- "ownerOrganizationId":"b6f204fb- e95d-48a9-a5ea-a6188074510e",
- "name":"trigger name",
- "description":"trigger description",
- "actions":[
- {
- "id":"a4e6cc29-17a4-431f-8009-4bef09471caf",
- "type":"REST",
- "url":"http://test.com",
- "method":"GET",
- "contentType":"application/json",
- "bodyTemplate":"test body"
- }
- ],
- "running":true,
- "matchDelay":1000,
- "matchInterval":2000,
- "minTriggerInterval":3000,
- "minMatchDuration":4000,
- "maxMatchDuration":12000
- }
- ```
- * **id** - Trigger ID
- * **queryId** - pattern query to listen
- * **watchers** - list of users who will receive notifications for this trigger
- * **ownerOrganizationId** - UUID. Organization ID.
- * **name** - user friendly trigger name
- * **description (optional)** - human readable trigger description
- * **actions** - additional actions that will execute on trigger fire. Fields depends on *type*
- * **running** - Trigger run status (false is stopped)
- ##### Conditions to match: below values describes conditions that should match for trigger to fire
- * **matchDelay** - time to wait before first check
- * **matchInterval** - time between checks
- * **minTriggerInterval (optional)** - min time between consecutive action triggering
- * **minMatchDuration (optional)** - min match duration to triggerAction action
- * **maxMatchDuration (optional)** - max match duration to triggerAction action
- ## Create Trigger
- ```text
- REQUEST /triggers/create
- ```
- ### Request payload
- ```json
- {
- "queryId":"59b9ad97-5eb1-4d5b-b34a-09efdcce5a60",
- "ownerOrganizationId":"b6f204fb-e95d-48a9-a5ea-a6188074510e",
- "name":"trigger name",
- "description":"trigger description",
- "matchDelay":1000,
- "matchInterval":2000,
- "minTriggerInterval":3000,
- "minMatchDuration":4000,
- "maxMatchDuration":12000
- }
- ```
- User, who created trigger will be automatically added to watchers for this trigger
- * **queryId** - pattern query to listen
- * **ownerOrganizationId** - UUID. Organization ID.
- * **name** - user friendly trigger name
- * **description (optional)** - human readable trigger description
- ##### Conditions to match: below values describes conditions that should match for trigger to fire
- * **matchDelay** - time to wait before first check
- * **matchInterval** - time between checks
- * **minTriggerInterval (optional)** - min time between consecutive action triggering
- * **minMatchDuration (optional)** - min match duration to triggerAction action
- * **maxMatchDuration (optional)** - max match duration to triggerAction action
- ### Response payload
- ```json
- "8c227e3b-a13a-40fb-a9d7-8d8fd05e1a9a"
- ```
- ## Update Trigger
- ```text
- REQUEST /triggers/update
- ```
- ### Request payload
- ```json
- {
- "id":"8c227e3b-a13a-40fb-a9d7-8d8fd05e1a9a",
- "name":"trigger name",
- "description":"trigger description"
- }
- ```
- * **id** - Trigger ID
- * **name** - user friendly trigger name
- * **description (optional)** - human readable trigger description
- ## Add action
- ```text
- REQUEST /triggers/action/add/{triggerId}
- ```
- ## Request payload
- For REST action :
- ```json
- {
- "type":"REST",
- "url":"http://test.com",
- "method":"POST",
- "contentType":"application/json",
- "bodyTemplate":"body"
- }
- ```
- * **type** - action type
- * **url** - full path for request
- * **method** - HTTP request method
- * **contentType** - body content type
- * **bodyTemplate** - request body template. can have placeholders for information from trigger event.
- Example:
- ```text
- {
- "device": "$event.groupKey",
- "timestamp": $event.timestamp
- }
- ```
- For EMAIL action :
- ```json
- {
- "type":"EMAIL",
- "from":"from@test.com",
- "targetEmails":[
- "test@test.com"
- ],
- "subject":"test",
- "bodyTemplate":"test body"
- }
- ```
- * **type** - action type
- * **from** - sender email address
- * **targetEmails** - list of email to send to
- * **subject** - email subject
- * **bodyTemplate** - request body template. can have placeholders for information from trigger event
- Example:
- ```text
- {
- "device": "$event.groupKey",
- "timestamp": $event.timestamp
- }
- ```
- ### Response payload
- ```json
- "8c227e3b-a13a-40fb-a9d7-8d8fd05e1a9a"
- ```
- ## Remove action
- ```text
- REQUEST /triggers/action/remove/{triggerId}/{actionId}
- ```
- ## Start Trigger
- ```text
- REQUEST /triggers/start/{triggerId}
- ```
- ## Stop Trigger
- ```text
- REQUEST /triggers/stop/{triggerId}
- ```
- ## Delete Trigger
- ```text
- REQUEST /triggers/delete/{triggerId}
- ```
- ## Add Watcher
- ```text
- REQUEST /triggers/watchers/add/{triggerId}/{userId}
- ```
- ## Delete Watcher
- ```text
- REQUEST/triggers/watchers/delete/{triggerId}/{userId}
- ```
- ## Get Trigger History
- ```text
- REQUEST/triggers/history/{triggerId}
- ```
- ### Request payload
- ```json
- {
- "startId": 0,
- "reverseOrder": true,
- "limit": 100
- }
- ```
- * **startId** - offset for building page
- * **reverseOrder** - boolean that indicates the sorting order. If TRUE will return next X - *limit*
- or less OLDER records. If FALSE return next X - *limit* or less NEWER record
- * **limit** - records page limit
- ### Response payload
- ```json
- {
- "count":125,
- "payload":[
- {
- "id":"0f4b8354-0cf4-4009-997e-696ad1e1e973",
- "sequenceId":1,
- "timestamp":1545132410639,
- "queryId":"3169400e-134e-44ca-9e6b-b9c415de0e2e",
- "triggerId":"361457d4-36b7-40ca-9677-c481f944fb36",
- "groupKey":"23614ee8-f147-4ab4-a782-1b47ad03fb79",
- "groupType":"device",
- "actions":[
- {
- "id":"a4e6cc29-17a4-431f-8009-4bef09471caf",
- "activatedSuccessfully":false,
- "errorMessage":"HTTP 404 Not Found"
- },
- {
- "id":"88d261a8-b442-4838-9251-2197ab3222ea",
- "activatedSuccessfully":true,
- "errorMessage":null
- }
- ]
- },
- {
- "id":"0f4b8354-0cf4-4009-997e-696a51e1e973",
- "sequenceId":3,
- "timestamp":1545132410659,
- "queryId":"3169400e-134e-44ca-9e6b-b9c415de0e2e",
- "triggerId":"361457d4-36b7-40ca-9677-c481f944fb36",
- "groupKey":"23614ee8-f147-4ab4-a782-1b49ad03fb79",
- "groupType":"device",
- "actions":[
- {
- "id":"a4e6cc29-17a4-431f-8009-4bef09471caf",
- "activatedSuccessfully":false,
- "errorMessage":"HTTP 404 Not Found"
- },
- {
- "id":"88d261a8-b442-4838-9251-2197ab3222ea",
- "activatedSuccessfully":true,
- "errorMessage":null
- }
- ]
- }
- ]
- }
- ```
- * **count** - total count of request result (not in a page)
- * **payload** - trigger fire events
- * **id** - trigger history activation ID
- * **sequenceId** - id for pagination
- * **timestamp** - actual time of trigger activation
- * **queryId** - id of attached query
- * **triggerId** - id of fired trigger
- * **groupKey** - event group key that lead to trigger fire
- * **groupType** - event group type
- * **actions** - actions results
- * **id** - action id
- * **activatedSuccessfully** - activation result
- * **errorMessage** - if action activation was unsuccessful describes error and error reason (if possible)
- # TOPICS
- ## Trigger Updates
- ```text
- SUBSCRIPTION_REQUEST /triggers/updatesForOrganization/{organizationId}
- ```
- * **organizationId** - UUID. Organization ID.
- ### Message payload
- ```json
- {
- "type":"NEW",
- "metadata":{
- "id":"8c227e3b-a13a-40fb-a9d7-8d8fd05e1a9a",
- "watchers":[
- "6fdf59c4-2f6a-471f-afc0-4666ead68ad4",
- "88d261a8-b442-4838-9251-2197ab3222ea"
- ],
- "queryId":"59b9ad97-5eb1-4d5b-b34a-09efdcce5a60",
- "ownerOrganizationId":"b6f204fb- e95d-48a9-a5ea-a6188074510e",
- "name":"trigger name",
- "description":"trigger description",
- "actions":[
- {
- "id":"a4e6cc29-17a4-431f-8009-4bef09471caf",
- "type":"rest",
- "url":"http://test.com",
- "method":"GET",
- "contentType":"application/json",
- "bodyTemplate":"test body"
- }
- ],
- "running":true,
- "matchDelay":1000,
- "matchInterval":2000,
- "minTriggerInterval":3000,
- "minMatchDuration":4000,
- "maxMatchDuration":12000
- }
- }
- ```
- * **type** - update type (NEW, UPDATE, DELETE)
- * **metadata** - Trigger metadata
- * **queryId** - pattern query to listen
- * **watchers** - list of users who will receive notifications for this trigger
- * **ownerOrganizationId** - UUID. Organization ID.
- * **name** - user friendly trigger name
- * **description (optional)** - human readable trigger description
- * **actions** - additional actions that will execute on trigger fire. Fields depends on *type*
- ##### Conditions to match: below values describes conditions that should match for trigger to fire
- * **matchDelay** - time to wait before first check
- * **matchInterval** - time between checks
- * **minTriggerInterval (optional)** - min time between consecutive action triggering
- * **minMatchDuration (optional)** - min match duration to triggerAction action
- * **maxMatchDuration (optional)** - max match duration to triggerAction action
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement