Jobs
A job is a single task that the system can do as part of a routine
View Available Jobs and Logics
A list of available job types can be requested for you to look at before you create, also, each job is ruled by 'logic' which is applied before execution and after execution of the job
List all Job types
Call to /job/manifest to get all jobs
Request Object
+ URL /api/v2/job/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 job type in the system.
+ Headers X-Powered-By: OpenDrives Access-Control-Allow-Origin: * Content-Type: application/json; charset=utf-8 + Body { "echo": { "enabled": true, "description": "Sends your String to the output in the system log", "config": { "output": { "specification": { "plurality": 1, "type": "string", "pattern": "none" }, "required": true, "description": "The output to be echoed to the terminal" } } }, "rsync": { "enabled": true, "description": "Starts an Rsync job on your system", "config": { "source": { "specification": { "plurality": "*", "type": "string", "pattern": "filesystem" }, "required": true, "description": "An array of the files or folders on your system to be rsync'd to your destination" }, "destination": { "specification": { "plurality": 1, "type": "string", "pattern": "filesystem" }, "required": true, "description": "The location on the system to send your sources to" } } } }
List all Job Logic types
Call to /job/logic to get all jobs
Request Object
+ URL /api/v2/job/logic + 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 job logic type in the system.
+ Headers X-Powered-By: OpenDrives Access-Control-Allow-Origin: * Content-Type: application/json; charset=utf-8 + Body { "conditions": { "immediate_previous_job_state": { "description": "The final state of the previous job, if one exists", "type": "before", "value": { "type": "enum", "pattern": "success||failure||skip" } }, "any_previous_job_state": { "description": "The final state of any of the previous jobs, if they exists", "type": "before", "value": { "type": "enum", "pattern": "success||failure||skip" } } } }
Basic Operations
Basic operations of Create, Read, Update, and Destroy are available
List all Jobs
Call to /job to get all jobs
Request Object
+ URL /api/v2/job/ + 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 job in the system.
+ Headers X-Powered-By: OpenDrives Access-Control-Allow-Origin: * Content-Type: application/json; charset=utf-8 + Body [{ "id": "b2ebdf7e-a3c9-42ab-9fab-e56dbc827085", "updatedAt": "2020-08-12T16:55:00.113Z", "createdAt": "2020-08-12T16:55:00.113Z", "hostid": "811fea00", "name": "Limit 64", "type": "bw_ctrl_create", "enabled": true, "config": { "ip": "192.168.7.64", "name": "LimitLiezel", "rate": 2097152, "device": "mgmt0" }, "logic": {} }, { "id": "ce5ab11f-5b54-470f-af52-bbfeb8c60fb5", "updatedAt": "2020-08-12T16:55:31.788Z", "createdAt": "2020-08-12T16:55:31.788Z", "hostid": "811fea00", "name": "TurnOff64", "type": "bw_ctrl_destroy", "enabled": true, "config": { "name": "LimitLiezel" }, "logic": {} }, ]
Get a specific Job
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/job/$JOB_ID/details + Method GET + Parameters job id (string, required, URL param) - the id of the job you'd like back + Headers Content-Type: application/json token: ThisIsNotARealTokenGenerateYourOwnToken + Body {}
Response Object
Sending this should get you back a valid response, an array of each routine in the system.
+ Headers X-Powered-By: OpenDrives Access-Control-Allow-Origin: * Content-Type: application/json; charset=utf-8 + Body [ { "id": "36608e21-4b6b-4cf6-87df-257d7fc64beb", "updatedAt": "2020-08-12T17:00:07.512Z", "createdAt": "2020-08-12T16:55:31.877Z", "hostid": "811fea00", "name": "BwCtrlOff", "enabled": true, "data": { "jobs": [ "ce5ab11f-5b54-470f-af52-bbfeb8c60fb5" ], "triggers": [ "94227782-0662-4ae1-bcc1-57d5766b681c" ] } } ]
Create a new Job
Creating a job through the API looks messy, but it’s pretty easy.
Request Object
+ URL /api/v2/job/create + Method POST + Parameters name (string, required, BODY) - the name you'd like to give to the job type (string, required, BODY) - the type of job enabled (boolean, required, BODY) - if a job should be utilized or not config (JSON object, required, BODY) - a valid configuration for the job type logic (JSON object, required, BODY) - any desired logic configuration for the job + Headers Content-Type: application/json token: ThisIsNotARealTokenGenerateYourOwnToken + Body { "name": "myFirstJob", "type": "echo", "enabled": "true", "config": { "output": "Hello First Job!" }, "logic":{ } }
Response Object
Sending this should get you back a valid response, an echo of your new job
+ Headers X-Powered-By: OpenDrives Access-Control-Allow-Origin: * Content-Type: application/json; charset=utf-8 + Body [{ "id": "79740591-5ff9-4e9f-abd8-50bcfebb3524", "updatedAt": "2020-08-17T16:19:33.982Z", "createdAt": "2020-08-17T16:19:33.982Z", "hostid": "811fea00", "name": "myFirstJob", "type": "echo", "enabled": true, "config": { "output": "Hello First Job!" }, "logic": {} }]
Update a Job
To update a job, simply call the route with the job’s ID and updated fields
Request Object
+ URL /api/v2/job/$JOB_ID/update + Method POST + Parameters job id (string, required, URL params) - the id of the job to update name (string, optional, BODY) - the name you'd like to give to the job type (string, optional, BODY) - the type of job enabled (boolean, optional, BODY) - if a job should be utilized or not config (JSON object, optional, BODY) - a valid configuration for the job type logic (JSON object, optional, BODY) - any desired logic configuration for the job + Headers Content-Type: application/json token: ThisIsNotARealTokenGenerateYourOwnToken + Body { "name": "helloWorld", "config": { "output": "Hello World!" } }
Response Object
Sending this should get you back a valid response, an echo of your updated job
+ Headers X-Powered-By: OpenDrives Access-Control-Allow-Origin: * Content-Type: application/json; charset=utf-8 + Body { "id": "79740591-5ff9-4e9f-abd8-50bcfebb3524", "updatedAt": "2020-08-17T16:36:05.708Z", "createdAt": "2020-08-17T16:19:33.982Z", "hostid": "811fea00", "name": "helloWorld", "type": "echo", "enabled": true, "config": { "output": "Hello World!" }, "logic": {} }
Destroy a Job
To destroy a job, call the route with the job’s ID
Logs
All jobs generate an unique log whenever they are run.
List or view Job logs
Call to /job/$JOB_ID/log to get all job logs, or, call /job/$JOB_ID/log/$LOG_ID for a single log
Request Object
+ URL /api/v2/job/$JOB_ID/log/$LOG_ID + Method POST + Parameters job id (string, required, URL params) - the id of the job 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 jobs 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 jobs 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 job 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": "8eecc4fb-fa93-44a6-8ff3-4937614fb849", "pid": 15803, "job_id": "b2ebdf7e-a3c9-42ab-9fab-e56dbc827085", "routine_run_id": "6926cb71-eca0-4540-a1da-381486ba9a1e", "updatedAt": "2020-08-17T16:05:24.683Z", "createdAt": "2020-08-17T16:05:24.683Z", "hostid": "811fea00", "status": "ready", "log": { "1597680324679": "Job [b2ebdf7e:bw_ctrl_create - Limit 64] Initializes\nJob [b2ebdf7e:bw_ctrl_create - Limit 64] \tStatus:ready\nJob [b2ebdf7e:bw_ctrl_create - Limit 64] \tRRID:6926cb71-eca0-4540-a1da-381486ba9a1e" } }, { "id": "cd43cffd-74e9-44cf-87b5-651e6d6738cd", "pid": 15803, "job_id": "b2ebdf7e-a3c9-42ab-9fab-e56dbc827085", "routine_run_id": "66ce66ea-8a5a-4b23-97ce-ff6063a976d7", "updatedAt": "2020-08-17T16:05:04.562Z", "createdAt": "2020-08-17T15:05:13.927Z", "hostid": "811fea00", "status": "failure", "log": { "1597676713925": "Job [b2ebdf7e:bw_ctrl_create - Limit 64] Initializes\nJob [b2ebdf7e:bw_ctrl_create - Limit 64] \tStatus:ready\nJob [b2ebdf7e:bw_ctrl_create - Limit 64] \tRRID:66ce66ea-8a5a-4b23-97ce-ff6063a976d7", "1597680304375": "Job [b2ebdf7e:bw_ctrl_create - Limit 64] Updates DB Status:in_progress", "1597680304380": "Job Limit 64 - bw_ctrl_create - Creating Bw Ctrl Rule", "1597680304562": "Job Limit 64 - bw_ctrl_create - ERROR\nA BWCtrl with the name LimitLiezel already exists!\nJob [b2ebdf7e:bw_ctrl_create - Limit 64] Updates DB Status:failure" } } ]