Triggers
A trigger is a single task that the system can do as part of a routine
View Available Triggers and Logics
A list of available trigger types can be requested for you to look at before you create.
List all Trigger types
Call to /trigger/manifest to get all triggers
Request Object
+ URL /api/v2/trigger/manifest + Method GET + Headers Content-Type: application/json token: ThisIsNotARealTokenGenerateYourOwnToken + Body {}
Response Object
Sending this should get you back a valid response, an object with each trigger type in the system.
+ Headers X-Powered-By: OpenDrives Access-Control-Allow-Origin: * Content-Type: application/json; charset=utf-8 + Body { "manual": { "enabled": true, "description": "Manually set the trigger to fire.", "config": { "trigger": { "specification": { "plurality": 1, "type": "boolean", "pattern": "none" }, "required": true, "description": "The boolean setting of if we should trigger a routine to run jobs or not" } } }, "cron": { "enabled": true, "description": "Fire your trigger automatically at a CRON interval", "config": { "expression": { "specification": { "plurality": 1, "type": "string", "pattern": "cron" }, "required": true, "description": "The valid cron string of when we sould trigger this routine." } } } }
Basic Operations
Basic operations of Create, Read, Update, and Destroy are available
List all Triggers
Call to /trigger to get all triggers
Request Object
+ URL /api/v2/trigger/ + Method GET + Headers Content-Type: application/json token: ThisIsNotARealTokenGenerateYourOwnToken + Body {}
Response Object
Sending this should get you back a valid response, an array of each trigger in the system.
+ Headers X-Powered-By: OpenDrives Access-Control-Allow-Origin: * Content-Type: application/json; charset=utf-8 + Body [{ "id": "94227782-0662-4ae1-bcc1-57d5766b681c", "updatedAt": "2020-08-12T17:00:07.411Z", "createdAt": "2020-08-12T16:55:31.687Z", "hostid": "811fea00", "name": "TurnOffLimit", "type": "manual", "enabled": true, "config": { "trigger": false }, "logic": {} }, { "id": "900a031e-bea9-4e84-987b-1abb1ddb4c1b", "updatedAt": "2020-08-12T17:36:47.271Z", "createdAt": "2020-08-12T17:36:47.271Z", "hostid": "811fea00", "name": "Every Hour plus 5", "type": "cron", "enabled": true, "config": { "expression": "5 */1 * * *" }, "logic": {} } ]
Get a specific Trigger
Like many other places in the API, we have a route for if you only want info on one specific routine
Request Object
+ URL /api/v2/trigger/$TRIGGER_ID/details + Method GET + Parameters trigger id (string, required, URL param) - the id of the trigger you'd like back + Headers Content-Type: application/json token: ThisIsNotARealTokenGenerateYourOwnToken + Body {}
Response Object
Sending this should get you back a valid response, the trigger you requested.
+ Headers X-Powered-By: OpenDrives Access-Control-Allow-Origin: * Content-Type: application/json; charset=utf-8 + Body [{ "id": "dc47cc24-5abb-4f9a-b806-ba0b4b1b7e1e", "updatedAt": "2020-08-12T17:42:17.104Z", "createdAt": "2020-08-12T17:42:17.104Z", "hostid": "811fea00", "name": "It is 9pm", "type": "cron", "enabled": true, "config": { "expression": "0 21 */1 * *" }, "logic": {} }]
Create a new Trigger
Creating a trigger through the API looks messy, but it’s pretty easy.
Request Object
+ URL /api/v2/trigger/create + Method POST + Parameters name (string, required, BODY) - the name you'd like to give to the trigger type (string, required, BODY) - the type of trigger enabled (boolean, required, BODY) - if a trigger should be utilized or not config (JSON object, required, BODY) - a valid configuration for the trigger type logic (JSON object, required, BODY) - any desired logic configuration for the trigger (Note: This is a placeholder for triggers at this moment, and not implemented) + Headers Content-Type: application/json token: ThisIsNotARealTokenGenerateYourOwnToken + Body { "name": "myFirstTrigger", "type": "cron", "enabled": "true", "config": { "expression": "20 4 * * *" }, "logic":{} }
Response Object
Sending this should get you back a valid response, an echo of your new trigger
+ Headers X-Powered-By: OpenDrives Access-Control-Allow-Origin: * Content-Type: application/json; charset=utf-8 + Body [{ "id": "582e0f31-ad75-4cab-af94-f7715051ca2c", "updatedAt": "2020-08-17T16:55:08.999Z", "createdAt": "2020-08-17T16:55:08.999Z", "hostid": "811fea00", "name": "myFirstTrigger", "type": "cron", "enabled": true, "config": { "expression": "20 4 * * *" }, "logic": {} }]
Update a Trigger
To update a trigger, simply call the route with the trigger’s ID and updated fields
Request Object
+ URL /api/v2/trigger/$TRIGGER_ID/update + Method POST + Parameters trigger id (string, required, URL params) - the id of the trigger to update name (string, optional, BODY) - the name you'd like to give to the trigger type (string, optional, BODY) - the type of trigger enabled (boolean, optional, BODY) - if a trigger should be utilized or not config (JSON object, optional, BODY) - a valid configuration for the trigger type logic (JSON object, required, BODY) - any desired logic configuration for the trigger (Note: This is a placeholder for triggers at this moment, and not implemented) + Headers Content-Type: application/json token: ThisIsNotARealTokenGenerateYourOwnToken + Body { "name": "Hello Triggers", "config": { "expression": "5,10,15 * * * *" } }
Response Object
Sending this should get you back a valid response, an echo of your updated trigger
+ Headers X-Powered-By: OpenDrives Access-Control-Allow-Origin: * Content-Type: application/json; charset=utf-8 + Body { "id": "582e0f31-ad75-4cab-af94-f7715051ca2c", "updatedAt": "2020-08-17T16:57:09.678Z", "createdAt": "2020-08-17T16:55:08.999Z", "hostid": "811fea00", "name": "Hello Triggers", "type": "cron", "enabled": true, "config": { "expression": "5,10,15 * * * *" }, "logic": {} }
Destroy a Trigger
To destroy a trigger, call the route with the trigger’s ID
Logs
All triggers generate an unique log whenever they are run.
List or view Trigger logs
Call to /trigger/$TRIGGER_ID/log to get all trigger logs, or, call /trigger/$TRIGGER_ID/log/$LOG_ID for a single log
Request Object
+ URL /api/v2/trigger/$TRIGGER_ID/log/$LOG_ID + Method POST + Parameters trigger id (string, required, URL params) - the id of the trigger to view logs log id (string, optional, URL params) - the id of the log to view limit (number, optional, BODY) - the maxiumum number of logs to get from the DB startMoment (string of zulu time, optional, BODY) - the moment to use as the start time for getting triggers from the db. In this format "2020-08-17T16:05:24.683Z" endMoment (string of zulu time, optional, BODY) - the moment to use as the stop time for getting triggers from the db. In this format "2020-08-17T16:05:24.683Z" + Headers Content-Type: application/json token: ThisIsNotARealTokenGenerateYourOwnToken + Body {}
Response Object
Sending this should get you back a valid response, an array of each trigger log in the system matching your query.
+ Headers X-Powered-By: OpenDrives Access-Control-Allow-Origin: * Content-Type: application/json; charset=utf-8 + Body [{ "id": "0bed79a7-5c26-4aab-a3b7-1b7f2b977917", "pid": 15823, "trigger_id": "900a031e-bea9-4e84-987b-1abb1ddb4c1b", "routine_run_id": "6926cb71-eca0-4540-a1da-381486ba9a1e", "updatedAt": "2020-08-17T16:05:34.684Z", "createdAt": "2020-08-17T16:05:24.682Z", "hostid": "811fea00", "status": "ready", "log": { "1597680324679": "Trg [900a031e:cron - Every Hour plus 5] Initializes\nTrg [900a031e:cron - Every Hour plus 5] \tStatus:ready\nTrg [900a031e:cron - Every Hour plus 5] \tRRID:6926cb71-eca0-4540-a1da-381486ba9a1e", "1597680324681": "Trg [900a031e:cron - Every Hour plus 5] has schedule expression of 5 */1 * * *" } }, { "id": "ce02b9bf-44ac-4910-a62c-041921f2c98a", "pid": 15823, "trigger_id": "900a031e-bea9-4e84-987b-1abb1ddb4c1b", "routine_run_id": "66ce66ea-8a5a-4b23-97ce-ff6063a976d7", "updatedAt": "2020-08-17T16:05:04.330Z", "createdAt": "2020-08-17T15:05:13.928Z", "hostid": "811fea00", "status": "detected", "log": { "1597676713925": "Trg [900a031e:cron - Every Hour plus 5] Initializes\nTrg [900a031e:cron - Every Hour plus 5] \tStatus:ready\nTrg [900a031e:cron - Every Hour plus 5] \tRRID:66ce66ea-8a5a-4b23-97ce-ff6063a976d7", "1597676713927": "Trg [900a031e:cron - Every Hour plus 5] has schedule expression of 5 */1 * * *", "1597680304327": "Trg [900a031e:cron - Every Hour plus 5] Status changes to detected" } } ]