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 is normal. Load balancer distributes validation tasks between available probes according to the priority order—from immediate to low.

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 one initial_task_id value is equal to the task_id value of the first task itself. If there were no restarts, the initial_task_id value matches the task_id value of the task itself. More details on how the restart chain works and how the initial_task_id parameter 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

Request by the 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 to the request #1
 {
   "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 to the request #2
 {
   "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 to the request #3
 {
   "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"
         }
       ]
     }
   ]
 }