Updated on 2024-04-22 GMT+08:00

Obtaining Tasks

Function

This API is used to obtain tasks.

URI

GET /v2/{project_id}/tasks

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details, see Obtaining a Project ID and Name.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

source_data_type

No

String

Task type, which is used for filtering. Only async_task and sync_task are supported.

title

No

String

Algorithm name, which must match the regular expression ^[a-zA-Z0-9\u4e00-\u9fa5-_,]{2,64}$.

camera_name

No

String

Camera name

Maximum: 255

task_state

No

String

Task status. Options: PENDING, RECOVERING, STARTING, UPGRADING, CREATE_FAILED, START_FAILED, RUNNING, STOPPING, STOPPED, ABNORMAL, SUCCEEDED, FAILED, DELETING, FREEZING, FROZEN, SCHEDULING, and LACK_OF_RESOURCES.

task_name

No

String

Task name

Maximum: 1024

page_size

No

Integer

Number of records displayed on each page

Minimum: 5

Maximum: 1000

Default: 10

page

No

Integer

Offset

Default: 1

sort_dir

No

String

Sorting rule for displaying service tasks

Default: desc

batch_id

No

String

Batch configuration ID, which must match the regular expression ^[a-z0-9-_]{4,36}$.

video_group_id

No

String

Video group ID. Multiple IDs are separated by commas (,). The value length must be [4,2048].

company

No

String

Vendor name. Multiple values are separated by commas (,).

alg_id

No

String

Algorithm ID, which must match the regular expression ^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. For details about how to obtain a user token, see Authentication.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

count

Integer

Number of records displayed on the current page

tasks

Array of TaskInfo objects

Obtained tasks

page

Integer

Current page number

page_size

Integer

Maximum number of records displayed on a page

Table 5 TaskInfo

Parameter

Type

Description

id

String

Task ID

name

String

Task name

service_id

String

ID of the service corresponding to a task

created_at

String

Task creation time

state

String

Task status. The value can be PENDING, RECOVERING, STARTING, UPGRADING, CREATE_FAILED, START_FAILED, RUNNING, STOPPING, STOPPED, ABNORMAL, SUCCEEDED, FAILED, DELETING, FREEZING, or FROZEN.

video_source_name

String

Video source name

title

String

Algorithm name

type

String

Task type (0: cloud task; 1: edge task)

algorithm_publish_id

String

Algorithm ID

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code

error_msg

String

Error description

detail

String

Error details

params

Array of strings

Error parameters

Array Length: 0 - 1

reason

String

Error cause

advice

String

Suggestion

Status code: 500

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code

error_msg

String

Error description

detail

String

Error details

params

Array of strings

Error parameters

Array Length: 0 - 1

reason

String

Error cause

advice

String

Suggestion

Example Requests

This request is used to obtain the tasks in the Running, Succeeded, Stopped, Pending, Failed, or Abnormal state.

/v2/{project_id}/tasks

https://{endpoint}/v2/{project_id}/tasks?page=1&page_size=10

Example Responses

Status code: 200

Response body for obtaining tasks

{
  "count" : 2,
  "tasks" : [ {
    "id" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "name" : "qqqq_task",
    "service_id" : "xxxxxxx-xxxxxxx-xxxxxxx-xxxxx-xxxxxx",
    "created_at" : "1686034773024",
    "state" : "PENDING",
    "video_source_name" : "url_test",
    "title" : "testwjh",
    "type" : "0",
    "algorithm_publish_id" : "xxxxxxx-xxxxxxx-xxxxxxx-xxxxx-xxxxxx"
  }, {
    "id" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "name" : "task_test1",
    "service_id" : "xxxxxxx-xxxxxxx-xxxxxxx-xxxxx-xxxxxx",
    "created_at" : "1686027880205",
    "state" : "STOPPED",
    "video_source_name" : "test_g11",
    "title" : "alg_test",
    "type" : "0",
    "algorithm_publish_id" : "xxxxxxx-xxxxxxx-xxxxxxx-xxxxx-xxxxxx"
  } ],
  "page" : 1,
  "page_size" : 10
}

Status Codes

Status Code

Description

200

Response body for obtaining tasks

400

Request error

500

Internal error

Error Codes

See Error Codes.