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

This API is used to obtain tasks.

Function

Obtaining 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 TaskInfoDto objects

Obtained tasks

page

Integer

Current page number

page_size

Integer

Maximum number of records displayed on a page

Table 5 TaskInfoDto

Parameter

Type

Description

id

String

Job ID

name

String

Job name

creator

String

Username of the job creator

project_id

String

Project ID of the job creator

description

String

Job description

Minimum: 0

Maximum: 500

release_id

String

ID of the service corresponding to a job

service_id

String

ID of the service corresponding to a task

created_at

String

Job creation time

updated_at

String

Time when the latest job status was updated

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.

status

String

Details about a job status (for some statuses only)

Minimum: 0

Maximum: 4096

error

error object

Error information

schedule_status

String

Status of a scheduled task. The value can be ACTIVATED or INACTIVATED.

schedule

TaskSchedule object

Task schedule. Only the weekly mode is supported.

input

TaskInput object

Input configuration of a job

output

TaskOutputForDisplay object

Output configuration of a job

config

TaskServiceConfig object

Job runtime parameters customized by the service publisher

video_source_name

String

Video source name

title

String

Algorithm name

group_name

String

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

company

String

Vendor name

task_config

String

Job algorithm configuration

type

String

Cloud or edge

resource_order_id

String

Resource order ID

package_id

String

Algorithm package ID

device_id

String

Device ID

access_address

String

Access address

algorithm_publish_id

String

Algorithm ID

Table 6 error

Parameter

Type

Description

code

String

Error code

Minimum: 8

Maximum: 36

message

String

Error description

Minimum: 2

Maximum: 512

Table 7 TaskSchedule

Parameter

Type

Description

type

String

Type of a scheduled task. This parameter is mandatory for scheduled tasks. The options are weekly and monthly.

timezone

String

Time zone where a user is located. This parameter is mandatory for scheduled jobs. The value is accurate to the minute.

days_of_week

Array of integers

Days in a week when a task is executed. This parameter is mandatory only for weekly tasks. The values 1 to 7 indicate Monday to Sunday respectively.

Minimum: 1

Maximum: 7

Array Length: 1 - 7

days_of_month

Array of integers

Days in a month when a task is executed. This parameter is mandatory only for monthly tasks. The values 1 to 31 indicate the first day to the 31st day of a month.

Minimum: 1

Maximum: 31

periods

Array<Array<>>

Time segment configuration. Select at least one time segment for executing a weekly or monthly job.

Table 8 TaskInput

Parameter

Type

Description

type

String

Task input type, which is mandatory when you create a task. The video_source type cannot be changed to other types. The following types are supported: obs (files stored in OBS, supported only by cloud tasks), url (specified file URL or stream request URL, supported only by cloud tasks), edgecamera (edge camera bound to IEF, supported only by edge tasks), restful (stream request URL obtained from a user-specified streaming server through a RESTful API, supported by both cloud and edge tasks), vcn (VCN device, supported only by edge tasks), and video_source (video sources managed in VIAS, supported by both cloud and edge tasks). You are advised to use the video_source type. Other types will be discontinued in the future. Options:

  • video_source

  • obs (not recommended and will be discontinued)

  • url (not recommended and will be discontinued)

  • edgecamera (not recommended and will be discontinued)

  • restful (not recommended and will be discontinued)

  • vcn (not recommended and will be discontinued)

data

Array of TaskInputData objects

Input details of a task, which is mandatory. The configuration varies according to the input type. Multiple inputs are allowed during creation, but only one input is allowed for update.

  • If the input type is obs, you must configure bucket, path, and index. Example: bucket: aicam, path: 3rdpartylicenses.txt, index: 0

  • If the input type is url, you must configure url and index. Example: url: https://xxx-xxx.com, index: 0

  • If the input type is restful, you must configure certificate_check, rtsp_path_in_response, url, index, and headers. Example: certificate_check: true, url: https://hsaij-dasahbi.com, rtsp_path_in_response: data/url, index: 0, headers: { AAA: AAA }

  • If the input type is vcn, you must configure device_id, stream_type, and index. Example: device_id: 21356478954612546874#gdhjkiushdgdksjhslmhscjsckjhdbnk, stream_type: 1, index: 0

  • If the input type is EdgeCamera, you must configure id and index. Example: id: 007cdafc-6000-47ce-b0e3-870b4a0db65e, index: 0.

Array Length: 1 - 50

vcn

TaskInputVcn object

VCN server information. This parameter is mandatory only when the input type is vcn.

Table 9 TaskInputData

Parameter

Type

Description

video_source_id

String

Video source ID. This parameter is mandatory when the input type is video_source.

stream_name

String

Name of a video stream.

bucket

String

OBS bucket name. This parameter is mandatory when the input type is obs.

Maximum: 63

path

String

OBS path. This parameter is mandatory when the input type is obs.

Maximum: 1023

url

String

File URL or RESTful request URL for obtaining a video stream. This parameter is mandatory when the input type is url or edgerestful. The value contains a maximum of 1000 characters.

Maximum: 1000

headers

Object

Headers carried in the RESTful request for obtaining a video stream. This parameter is optional when the input type is edgerestful. The value is key-value pairs in JSON format. A maximum of 10 key-value pairs are allowed.

certificate_check

Boolean

Whether to verify the certificate of the HTTPS request. This parameter is mandatory when the input type is edgerestful. The value can be true or false.

rtsp_path_in_response

String

Video stream address in the response body for the RESTful request. This parameter is mandatory when the input type is edgerestful. The value contains a maximum of 1024 characters.

Maximum: 1024

device_id

String

VCN ID. This parameter is mandatory when the input type is vcn.

stream_type

Integer

Stream type used for analysis. This parameter is optional when the input type is vcn. The value ranges from 1 to 3. The value 1 indicates primary stream, the value 2 indicates secondary stream 1, and the value 3 indicates secondary stream 2.

Minimum: 1

Maximum: 3

id

String

ID of the edge device mounted to IEF. This parameter is mandatory when the input type is edgecamera.

Maximum: 63

Table 10 TaskInputVcn

Parameter

Type

Description

ip

String

IP address of the VCN server. This parameter is mandatory only when the input type is vcn.

port

Integer

Port number of the VCN server. This parameter is mandatory only when the input type is vcn.

Minimum: 0

Maximum: 65535

username

String

Account name of a VCN server. This parameter is mandatory only when the input type is vcn. The value must match the regular expression ^.{1,100}$.

password

String

Password of a VCN server account. This parameter is mandatory only when the input type is vcn. The value must match the regular expression ^.{1,1000}$.

Table 11 TaskOutputForDisplay

Parameter

Type

Description

obs

TaskOutputObs object

Configuration information when the output type is obs.

dis

TaskOutputDis object

Configuration information when the output type is dis.

webhook

TaskOutputWebhook object

Configuration information when the output type is webhook.

event_center

Boolean

Default: false

Table 12 TaskOutputObs

Parameter

Type

Description

bucket

String

OBS bucket name. This parameter is mandatory when the OBS output type is used. The verification rule is (pattern: " ^[a-z0-9](?!.[-.][-.].)([a-z0-9-.]{1,61})[a-z0-9]$ ").

Maximum: 63

path

String

OBS path. This parameter is mandatory when the OBS output type is used. The verification rule is ^(?![/.\s])(?!.//.)([^:*?"<>|]{0,1023})(?<![.\s])$.

Maximum: 1023

data_category

Array of strings

List of job output types. This parameter is optional and is required only for some services. The output contains data in the dataCategory list.

Array Length: 0 - 10

Table 13 TaskOutputDis

Parameter

Type

Description

stream_name

String

DIS stream name. This parameter is mandatory when the dis type is used.

Maximum: 64

data_category

Array of strings

List of job output types. This parameter is optional and is required only for some services. The output contains data in the dataCategory list.

Array Length: 0 - 10

Table 14 TaskOutputWebhook

Parameter

Type

Description

url

String

Result callback address. This parameter is mandatory when the output type is webhook.

Maximum: 1000

headers

Object

Headers carried in result callback. This parameter is mandatory when the output type is webhook. The value is key-value pairs in JSON format. A maximum of 10 key-value pairs are allowed, and a minimum of 1 key-value pair is allowed.

data_category

Array of strings

List of job output types. This parameter is optional and is required only for some services. The output contains data in the dataCategory list.

Array Length: 0 - 10

Table 15 TaskServiceConfig

Parameter

Type

Description

common

Object

Job runtime configuration items customized by the service publisher. The value must be in JSON format. For details about the configuration items, see the description of the corresponding algorithm service.

Status code: 400

Table 16 Response body parameters

Parameter

Type

Description

error_code

String

Error code

error_msg

String

Error information

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 17 Response body parameters

Parameter

Type

Description

error_code

String

Error code

error_msg

String

Error information

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.