Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.09 KB | None | 0 0
  1. * Endpoints
  2. * [Get All Triggers For Organization](#GetAllTriggersForOrganization)
  3. * [Get Trigger By ID](#GetTriggerByID)
  4. * [Create Trigger](#CreateTrigger)
  5. * [Update Trigger](#UpdateTrigger)
  6. * [Add Action](#AddAction)
  7. * [Remove Action](#RemoveAction)
  8. * [Start Trigger](#StartTrigger)
  9. * [Stop Trigger](#StopTrigger)
  10. * [Delete Trigger](#DeleteTrigger)
  11. * [Add Watcher](#AddWatcher)
  12. * [Delete Watcher](#DeleteWatcher)
  13. * Topics
  14. * [Trigger Updates For Organization](#TriggerUpdatesForOrganization)
  15.  
  16. # ENDPOINTS
  17.  
  18. ## Get All Triggers For Organization
  19. ```text
  20. REQUEST /triggers/getAllForOrganization/{organizationId}
  21. ```
  22.  
  23. ### Response payload
  24. ```json
  25. [
  26. {
  27. "id":"8c227e3b-a13a-40fb-a9d7-8d8fd05e1a9a",
  28. "queryId":"59b9ad97-5eb1-4d5b-b34a-09efdcce5a60",
  29. "watchers":[
  30. "6fdf59c4-2f6a-471f-afc0-4666ead68ad4",
  31. "88d261a8-b442-4838-9251-2197ab3222ea"
  32. ],
  33. "ownerOrganizationId":"b6f204fb-e95d-48a9-a5ea-a6188074510e",
  34. "name":"trigger name",
  35. "description":"trigger description",
  36. "actions":[
  37. {
  38. "id":"a4e6cc29-17a4-431f-8009-4bef09471caf",
  39. "type":"rest",
  40. "url":"http://test.com",
  41. "method":"GET",
  42. "contentType":"application/json",
  43. "bodyTemplate":"test body"
  44. }
  45. ],
  46. "running":true,
  47. "matchDelay":1000,
  48. "matchInterval":2000,
  49. "minTriggerInterval":3000,
  50. "minMatchDuration":4000,
  51. "maxMatchDuration":12000
  52. }
  53. ]
  54. ```
  55. * **id** - Trigger ID
  56. * **queryId** - pattern query to listen
  57. * **watchers** - list of users who will receive notifications for this trigger
  58. * **ownerOrganizationId** - UUID. Organization ID.
  59. * **name** - user friendly trigger name
  60. * **description (optional)** - human readable trigger description
  61. * **actions** - additional actions that will execute on trigger fire. Fields depends on *type*
  62. * **running** - Trigger run status (false is stopped)
  63. ##### Conditions to match: below values describes conditions that should match for trigger to fire
  64. * **matchDelay** - time to wait before first check
  65. * **matchInterval** - time between checks
  66. * **minTriggerInterval (optional)** - min time between consecutive action triggering
  67. * **minMatchDuration (optional)** - min match duration to triggerAction action
  68. * **maxMatchDuration (optional)** - max match duration to triggerAction action
  69.  
  70. ## Get Trigger By ID
  71. ```text
  72. REQUEST /triggers/getById/{triggerId}
  73.  
  74. ```
  75. ### Response payload
  76. ```json
  77. {
  78. "id":"8c227e3b-a13a-40fb-a9d7-8d8fd05e1a9a",
  79. "queryId":"59b9ad97-5eb1-4d5b-b34a-09efdcce5a60",
  80. "watchers":[
  81. "6fdf59c4-2f6a-471f-afc0-4666ead68ad4",
  82. "88d261a8-b442-4838-9251-2197ab3222ea"
  83. ],
  84. "ownerOrganizationId":"b6f204fb- e95d-48a9-a5ea-a6188074510e",
  85. "name":"trigger name",
  86. "description":"trigger description",
  87. "actions":[
  88. {
  89. "id":"a4e6cc29-17a4-431f-8009-4bef09471caf",
  90. "type":"REST",
  91. "url":"http://test.com",
  92. "method":"GET",
  93. "contentType":"application/json",
  94. "bodyTemplate":"test body"
  95. }
  96. ],
  97. "running":true,
  98. "matchDelay":1000,
  99. "matchInterval":2000,
  100. "minTriggerInterval":3000,
  101. "minMatchDuration":4000,
  102. "maxMatchDuration":12000
  103. }
  104. ```
  105. * **id** - Trigger ID
  106. * **queryId** - pattern query to listen
  107. * **watchers** - list of users who will receive notifications for this trigger
  108. * **ownerOrganizationId** - UUID. Organization ID.
  109. * **name** - user friendly trigger name
  110. * **description (optional)** - human readable trigger description
  111. * **actions** - additional actions that will execute on trigger fire. Fields depends on *type*
  112. * **running** - Trigger run status (false is stopped)
  113. ##### Conditions to match: below values describes conditions that should match for trigger to fire
  114. * **matchDelay** - time to wait before first check
  115. * **matchInterval** - time between checks
  116. * **minTriggerInterval (optional)** - min time between consecutive action triggering
  117. * **minMatchDuration (optional)** - min match duration to triggerAction action
  118. * **maxMatchDuration (optional)** - max match duration to triggerAction action
  119.  
  120. ## Create Trigger
  121. ```text
  122. REQUEST /triggers/create
  123. ```
  124. ### Request payload
  125. ```json
  126. {
  127. "queryId":"59b9ad97-5eb1-4d5b-b34a-09efdcce5a60",
  128. "ownerOrganizationId":"b6f204fb-e95d-48a9-a5ea-a6188074510e",
  129. "name":"trigger name",
  130. "description":"trigger description",
  131. "matchDelay":1000,
  132. "matchInterval":2000,
  133. "minTriggerInterval":3000,
  134. "minMatchDuration":4000,
  135. "maxMatchDuration":12000
  136. }
  137. ```
  138. User, who created trigger will be automatically added to watchers for this trigger
  139. * **queryId** - pattern query to listen
  140. * **ownerOrganizationId** - UUID. Organization ID.
  141. * **name** - user friendly trigger name
  142. * **description (optional)** - human readable trigger description
  143. ##### Conditions to match: below values describes conditions that should match for trigger to fire
  144. * **matchDelay** - time to wait before first check
  145. * **matchInterval** - time between checks
  146. * **minTriggerInterval (optional)** - min time between consecutive action triggering
  147. * **minMatchDuration (optional)** - min match duration to triggerAction action
  148. * **maxMatchDuration (optional)** - max match duration to triggerAction action
  149.  
  150. ### Response payload
  151. ```json
  152. "8c227e3b-a13a-40fb-a9d7-8d8fd05e1a9a"
  153. ```
  154.  
  155. ## Update Trigger
  156. ```text
  157. REQUEST /triggers/update
  158. ```
  159.  
  160. ### Request payload
  161. ```json
  162. {
  163. "id":"8c227e3b-a13a-40fb-a9d7-8d8fd05e1a9a",
  164. "name":"trigger name",
  165. "description":"trigger description"
  166. }
  167. ```
  168. * **id** - Trigger ID
  169. * **name** - user friendly trigger name
  170. * **description (optional)** - human readable trigger description
  171.  
  172. ## Add action
  173. ```text
  174. REQUEST /triggers/action/add/{triggerId}
  175. ```
  176. ## Request payload
  177. For REST action :
  178. ```json
  179. {
  180. "type":"REST",
  181. "url":"http://test.com",
  182. "method":"POST",
  183. "contentType":"application/json",
  184. "bodyTemplate":"body"
  185. }
  186. ```
  187. * **type** - action type
  188. * **url** - full path for request
  189. * **method** - HTTP request method
  190. * **contentType** - body content type
  191. * **bodyTemplate** - request body template. can have placeholders for information from trigger event.
  192. Example:
  193. ```text
  194. {
  195. "device": "$event.groupKey",
  196. "timestamp": $event.timestamp
  197. }
  198. ```
  199.  
  200. For EMAIL action :
  201. ```json
  202. {
  203. "type":"EMAIL",
  204. "from":"from@test.com",
  205. "targetEmails":[
  206. "test@test.com"
  207. ],
  208. "subject":"test",
  209. "bodyTemplate":"test body"
  210. }
  211. ```
  212. * **type** - action type
  213. * **from** - sender email address
  214. * **targetEmails** - list of email to send to
  215. * **subject** - email subject
  216. * **bodyTemplate** - request body template. can have placeholders for information from trigger event
  217. Example:
  218. ```text
  219. {
  220. "device": "$event.groupKey",
  221. "timestamp": $event.timestamp
  222. }
  223. ```
  224.  
  225. ### Response payload
  226. ```json
  227. "8c227e3b-a13a-40fb-a9d7-8d8fd05e1a9a"
  228.  
  229. ```
  230.  
  231. ## Remove action
  232. ```text
  233. REQUEST /triggers/action/remove/{triggerId}/{actionId}
  234. ```
  235.  
  236. ## Start Trigger
  237. ```text
  238. REQUEST /triggers/start/{triggerId}
  239.  
  240. ```
  241.  
  242. ## Stop Trigger
  243. ```text
  244. REQUEST /triggers/stop/{triggerId}
  245.  
  246. ```
  247.  
  248. ## Delete Trigger
  249. ```text
  250. REQUEST /triggers/delete/{triggerId}
  251.  
  252. ```
  253.  
  254. ## Add Watcher
  255. ```text
  256. REQUEST /triggers/watchers/add/{triggerId}/{userId}
  257.  
  258. ```
  259.  
  260. ## Delete Watcher
  261. ```text
  262. REQUEST/triggers/watchers/delete/{triggerId}/{userId}
  263.  
  264. ```
  265.  
  266. ## Get Trigger History
  267. ```text
  268. REQUEST/triggers/history/{triggerId}
  269.  
  270. ```
  271. ### Request payload
  272. ```json
  273. {
  274. "startId": 0,
  275. "reverseOrder": true,
  276. "limit": 100
  277. }
  278. ```
  279. * **startId** - offset for building page
  280. * **reverseOrder** - boolean that indicates the sorting order. If TRUE will return next X - *limit*
  281. or less OLDER records. If FALSE return next X - *limit* or less NEWER record
  282. * **limit** - records page limit
  283.  
  284. ### Response payload
  285. ```json
  286. {
  287. "count":125,
  288. "payload":[
  289. {
  290. "id":"0f4b8354-0cf4-4009-997e-696ad1e1e973",
  291. "sequenceId":1,
  292. "timestamp":1545132410639,
  293. "queryId":"3169400e-134e-44ca-9e6b-b9c415de0e2e",
  294. "triggerId":"361457d4-36b7-40ca-9677-c481f944fb36",
  295. "groupKey":"23614ee8-f147-4ab4-a782-1b47ad03fb79",
  296. "groupType":"device",
  297. "actions":[
  298. {
  299. "id":"a4e6cc29-17a4-431f-8009-4bef09471caf",
  300. "activatedSuccessfully":false,
  301. "errorMessage":"HTTP 404 Not Found"
  302. },
  303. {
  304. "id":"88d261a8-b442-4838-9251-2197ab3222ea",
  305. "activatedSuccessfully":true,
  306. "errorMessage":null
  307. }
  308. ]
  309. },
  310. {
  311. "id":"0f4b8354-0cf4-4009-997e-696a51e1e973",
  312. "sequenceId":3,
  313. "timestamp":1545132410659,
  314. "queryId":"3169400e-134e-44ca-9e6b-b9c415de0e2e",
  315. "triggerId":"361457d4-36b7-40ca-9677-c481f944fb36",
  316. "groupKey":"23614ee8-f147-4ab4-a782-1b49ad03fb79",
  317. "groupType":"device",
  318. "actions":[
  319. {
  320. "id":"a4e6cc29-17a4-431f-8009-4bef09471caf",
  321. "activatedSuccessfully":false,
  322. "errorMessage":"HTTP 404 Not Found"
  323. },
  324. {
  325. "id":"88d261a8-b442-4838-9251-2197ab3222ea",
  326. "activatedSuccessfully":true,
  327. "errorMessage":null
  328. }
  329. ]
  330. }
  331. ]
  332. }
  333. ```
  334. * **count** - total count of request result (not in a page)
  335. * **payload** - trigger fire events
  336. * **id** - trigger history activation ID
  337. * **sequenceId** - id for pagination
  338. * **timestamp** - actual time of trigger activation
  339. * **queryId** - id of attached query
  340. * **triggerId** - id of fired trigger
  341. * **groupKey** - event group key that lead to trigger fire
  342. * **groupType** - event group type
  343. * **actions** - actions results
  344. * **id** - action id
  345. * **activatedSuccessfully** - activation result
  346. * **errorMessage** - if action activation was unsuccessful describes error and error reason (if possible)
  347.  
  348. # TOPICS
  349. ## Trigger Updates
  350. ```text
  351. SUBSCRIPTION_REQUEST /triggers/updatesForOrganization/{organizationId}
  352.  
  353. ```
  354. * **organizationId** - UUID. Organization ID.
  355. ### Message payload
  356. ```json
  357. {
  358. "type":"NEW",
  359. "metadata":{
  360. "id":"8c227e3b-a13a-40fb-a9d7-8d8fd05e1a9a",
  361. "watchers":[
  362. "6fdf59c4-2f6a-471f-afc0-4666ead68ad4",
  363. "88d261a8-b442-4838-9251-2197ab3222ea"
  364. ],
  365. "queryId":"59b9ad97-5eb1-4d5b-b34a-09efdcce5a60",
  366. "ownerOrganizationId":"b6f204fb- e95d-48a9-a5ea-a6188074510e",
  367. "name":"trigger name",
  368. "description":"trigger description",
  369. "actions":[
  370. {
  371. "id":"a4e6cc29-17a4-431f-8009-4bef09471caf",
  372. "type":"rest",
  373. "url":"http://test.com",
  374. "method":"GET",
  375. "contentType":"application/json",
  376. "bodyTemplate":"test body"
  377. }
  378. ],
  379. "running":true,
  380. "matchDelay":1000,
  381. "matchInterval":2000,
  382. "minTriggerInterval":3000,
  383. "minMatchDuration":4000,
  384. "maxMatchDuration":12000
  385. }
  386. }
  387. ```
  388. * **type** - update type (NEW, UPDATE, DELETE)
  389. * **metadata** - Trigger metadata
  390. * **queryId** - pattern query to listen
  391. * **watchers** - list of users who will receive notifications for this trigger
  392. * **ownerOrganizationId** - UUID. Organization ID.
  393. * **name** - user friendly trigger name
  394. * **description (optional)** - human readable trigger description
  395. * **actions** - additional actions that will execute on trigger fire. Fields depends on *type*
  396. ##### Conditions to match: below values describes conditions that should match for trigger to fire
  397. * **matchDelay** - time to wait before first check
  398. * **matchInterval** - time between checks
  399. * **minTriggerInterval (optional)** - min time between consecutive action triggering
  400. * **minMatchDuration (optional)** - min match duration to triggerAction action
  401. * **maxMatchDuration (optional)** - max match duration to triggerAction action
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement