4.3.7. TaskStart¶
Description¶
The method allows you to create and run verification tasks, and returns the task identifier task_id, which allows you to manage the task, track its status, and request a report.
Request¶
{
"user_id":(number),
"methods":[
{
"method":"TaskStart",
"params":{
"project_id":(number),
"tasks":[
{
"template_id":(number),
"uri":(string),
"name":(string),
"priority":(string)
}
]
}
}
]
}
where:
user_id— an integer value, a user identifier;project_id— an integer value, a user project identifier;template_id— an integer value, a template identifier;uri— a string, a path to an analyzed media file;name(optional field) — a string, a media file name;priority(optional field) — a string, task priority:low,normal,high,urgent,immediate. Default priority isnormal. Load balancer distributes validation tasks between available probes according to the priority order—fromimmediatetolow.
Reply¶
{
"reply":[
{
"method":"TaskStart",
"result":[
{
"task_id":(number),
"initial_task_id":(number),
"template_id":(number),
"uri":(string),
"name":(string),
"priority":(string),
"errors":[(string)
]
}
]
}
]
}
where:
task_id— an integer value, a user identifier;initial_task_id— an integer value, the identifier of a task group within a restart chain. For any task in the group including the first oneinitial_task_idvalue is equal to thetask_idvalue of the first task itself. If there were no restarts, theinitial_task_idvalue matches thetask_idvalue of the task itself. More details on how the restart chain works and how theinitial_task_idparameter is applied are given in the description of the TaskStatus method;template_id— an integer value, a template identifier;uri— a string, a path to an analyzed media file;name— a string, a media file name;priority— a string, task priority;errors— an array of strings that returns a list of errors that occurred during a task start.
Example¶
cURL utility¶#1. A simple request to create and run a single task
curl http://172.16.1.41/ctrl_api/v1/json \
-H "Content-Type: application/json" \
--data '{"user_id":1,"methods":[{"method":"TaskStart","params":{"project_id":2,"tasks":[{"template_id":63,"uri":"file:///mnt/VoD_storage/sample1.mp4"}]}}]}'
#2. An example in which the name and priority fields are additionally specified
curl http://172.16.1.41/ctrl_api/v1/json \
-H "Content-Type: application/json" \
--data '{"user_id":1,"methods":[{"method":"TaskStart","params":{"project_id":2,"tasks":[{"template_id":63,"uri":"file:///mnt/VoD_storage/sample1.mp4","name":"Test","priority":"normal"}]}}]}'
#3. A request to create and run multiple tasks. The third task has a deliberately non-existent value specified in the template_id field
curl http://172.16.1.41/ctrl_api/v1/json \
-H "Content-Type: application/json" \
--data '{"user_id":1,"methods":[{"method":"TaskStart","params":{"project_id":2,"tasks":[{"template_id":63,"uri":"file:///mnt/VoD_storage/sample1.mp4","name":"Test1","priority":"low"},{"template_id":63,"uri":"file:///mnt/VoD_storage/sample2.mp4","name":"Test2","priority":"normal"},{"template_id":46,"uri":"file:///mnt/VoD_storage/sample3.mp4","name":"Test3","priority":"high"}]}}]}'
{
"reply": [
{
"method": "TaskStart",
"result": [
{
"task_id": 2213,
"initial_task_id": 2213,
"uri": "file:///mnt/VoD_storage/sample1.mp4",
"name": "",
"template_id": 63,
"priority": "normal"
}
]
}
]
}
{
"reply": [
{
"method": "TaskStart",
"result": [
{
"task_id": 2218,
"initial_task_id": 2218,
"uri": "file:///mnt/VoD_storage/sample1.mp4",
"name": "Test",
"template_id": 63,
"priority": "normal"
}
]
}
]
}
{
"reply": [
{
"method": "TaskStart",
"result": [
{
"uri": "file:///mnt/VoD_storage/sample3.mp4",
"name": "Test3",
"template_id": 46,
"priority": "high",
"errors": [
"'template_id' with id '46' doesn't exist"
]
},
{
"task_id": 2221,
"initial_task_id": 2221,
"uri": "file:///mnt/VoD_storage/sample1.mp4",
"name": "Test1",
"template_id": 63,
"priority": "low"
},
{
"task_id": 2222,
"initial_task_id": 2222,
"uri": "file:///mnt/VoD_storage/sample2.mp4",
"name": "Test2",
"template_id": 63,
"priority": "normal"
}
]
}
]
}