Obtaining a Service Task¶
Function¶
This API is used to obtain a service task.
URI¶
GET /v1/{project_id}/services/{service_id}/tasks/{task_id}
Parameter | Mandatory | Type | Description |
---|---|---|---|
project_id | Yes | String | Project ID. For details, see Obtaining a Project ID and Name. |
service_id | Yes | String | Service ID |
task_id | Yes | String | ID of a specified service task |
Request Parameters¶
None
Response Parameters¶
Status code: 200
Parameter | Type | Description |
---|---|---|
id | String | Task ID |
name | String | Task name |
service_name | String | Service name |
creator | String | Username of the task creator |
project_id | String | Project ID of the task creator |
description | String | Task description |
service_id | String | ID of the service corresponding to a task |
created_at | String | Task creation time |
updated_at | String | Time when the latest task 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 task status (for some statuses only) |
error | error object | Error information collected when the task fails to be executed |
schedule_status | String | Status of a scheduled task. The value can be ACTIVATED or INACTIVATED. |
schedule | TaskSchedule object | Configuration item of a scheduled task. This parameter is optional. Scheduled tasks do not support OBS input. URL input supports only RTMP and RTSP. |
input | TaskInput object | Input configuration of a task. This parameter is mandatory. |
output | TaskOutputForDisplay object | Output configuration of a task |
config | Object | Algorithm configuration parameters specified during task running. This parameter is mandatory for some services. The value must be in JSON format. For details about the configuration items, see the description of the corresponding algorithm service. This parameter applies only to IEF. It cannot be used in ModelArts Edge. |
Parameter | Type | Description |
---|---|---|
code | String | Error code for an algorithm |
message | String | Error information returned by an algorithm |
Parameter | Type | Description |
---|---|---|
type | String | Type of a scheduled task. This parameter is mandatory for scheduled tasks. The options are once (executed only once), daily (executed daily), weekly (executed weekly), and monthly (executed monthly). ModelArts Edge supports only once and daily. |
execution_mode | String | Execution mode of a scheduled task. This parameter is mandatory for scheduled tasks. The value can be period (execution by period) or frequency (execution by frequency). ModelArts Edge supports only execution by period. |
timezone | String | Time zone where a user is located. This parameter is mandatory for scheduled tasks. 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. |
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. |
periods | Array of periods objects | Period-based execution configuration. Use either this parameter or frequency. In this mode, at least one period must be specified. |
frequency | frequency object | Frequency-based execution configuration. Use either this parameter or periods. |
Parameter | Type | Description |
---|---|---|
begin_at | String | Start time of a period. This parameter is mandatory. If a scheduled task is of the once type, the value of the parameter is in the format of yyyy-MM-ddThh:mm:ss. For other scheduled task types, the value of the parameter is in the format of hh:mm:ss. |
end_at | String | End time of a period. This parameter is mandatory. If a scheduled task is of the once type, the value of the parameter is in the format of yyyy-MM-ddThh:mm:ss. For other scheduled task types, the value of the parameter is in the format of hh:mm:ss. |
Parameter | Type | Description |
---|---|---|
interval | Integer | Interval between two consecutive executions. This parameter is mandatory when execution_mode is set to frequency. The value ranges from 5 to 720, in minutes. |
duration | Integer | Duration for executing a single scheduled task. This parameter is mandatory when execution_mode is set to frequency. The value ranges from 5 to 720, in minutes. |
begin_at | String | Start time of executions in a day. This parameter is mandatory. If a scheduled task is of the once type, the value of the parameter is in the format of yyyy-MM-ddThh:mm:ss. For other scheduled task types, the value of the parameter is in the format of hh:mm:ss. |
end_at | String | End time of executions in a day. This parameter is mandatory. If a scheduled task is of the once type, the value of the parameter is in the format of yyyy-MM-ddThh:mm:ss. For other scheduled task types, the value of the parameter is in the format of hh:mm:ss. |
Parameter | Type | Description |
---|---|---|
type | String | Input type of a task. This parameter is mandatory. ModelArts Edge supports the following types: restful (obtains the stream request URL from the custom streaming media server through the RESTful API), url (specified file address or stream request URL), edgecamera (edge camera bound to IEF), and vcn (VCN device). IEF supports the following types: restful, url, edgecamera, vcn, obs (files stored in OBS), and vis (video streams of VIS) |
data | Array of TaskInputData objects | Input details of a task. This parameter is mandatory. The configuration varies according to the input type. Multiple inputs are allowed during creation, but only one input is allowed for update. |
vcn | TaskInputVcn object | VCN server. This parameter is mandatory only when the input type is vcn. |
Parameter | Type | Description |
---|---|---|
stream_name | String | Name of a VIS video stream. This parameter is mandatory when the input type is vis. |
bucket | String | OBS bucket name. This parameter is mandatory when the input type is obs. |
path | String | OBS path. This parameter is mandatory when the input type is obs. |
url | String | File URL or RESTful request URL for obtaining a video stream. This parameter is mandatory when the input type is url or restful. The value contains a maximum of 1000 characters. |
headers | Object | Headers carried in the RESTful request for obtaining a video stream. This parameter is optional when the input type is restful. 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 restful. 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 restful. The value contains a maximum of 1024 characters. |
node_id | String | Node ID. This parameter is required only for some services when the input type is restful or vcn. |
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. |
id | String | ID of the mounted edge device. This parameter is mandatory when the input type is edgecamera. |
camera_type | String | Camera type. This parameter is applicable to ModelArts Edge. When IPC cameras are used, set this parameter to ipc. |
tag | Array of Map<String,String> objects | Camera tag. This parameter is mandatory when camera_type is set to ipc. This parameter is applicable to ModelArts Edge. |
Parameter | Type | Description |
---|---|---|
ip | String | IP address of a VCN server. This parameter is mandatory only when the input type is vcn. |
port | Integer | Port number of a VCN server. This parameter is mandatory only when the input type is vcn. |
username | String | Username for logging in to a VCN server. This parameter is mandatory only when the input type is vcn. |
password | String | Password for logging in to a VCN server. This parameter is mandatory only when the input type is vcn. |
Parameter | Type | Description |
---|---|---|
obs | TaskOutputObs object | Configuration information when the output type is obs. This parameter cannot be used in ModelArts Edge. |
dis | TaskOutputDis object | Configuration information when the output type is dis |
webhook | TaskOutputWebhook object | Configuration information when the output type is webhook. |
Parameter | Type | Description |
---|---|---|
bucket | String | OBS bucket name. This parameter is mandatory when the obs type is used. |
path | String | OBS path. This parameter is mandatory when the obs type is used. |
data_category | Array of strings | List of task output types. This parameter is optional and is required only for some services. The output contains data in the dataCategory list. |
Parameter | Type | Description |
---|---|---|
stream_name | String | DIS stream name. This parameter is mandatory when the dis type is used. |
data_category | Array of strings | List of task output types. This parameter is optional and is required only for some services. The output contains data in the dataCategory list. |
stream_id | String | DIS stream ID. This parameter is applicable to ModelArts Edge. |
Parameter | Type | Description |
---|---|---|
url | String | Result callback address. This parameter is mandatory when the output type is webhook. |
headers | Object | Headers carried in the 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 task output types. This parameter is optional and is required only for some services. The output contains data in the dataCategory list. |
Status code: 400
Parameter | Type | Description |
---|---|---|
error_code | String | Internal service error code |
error_msg | String | Error message |
Status code: 404
Parameter | Type | Description |
---|---|---|
error_code | String | Internal service error code |
error_msg | String | Error message |
Example Requests¶
Obtain a specified task of a given service.
/v1/b722xxxxxxxxxxxxxxxxxxxxxxeb4674/services/88bbxxxx-xxxx-xxxx-xxxx-xxxxxxxxbcfe/tasks/53e4xxxxxxxxxxxxxxxxxxxxxxb55b3e
Example Responses¶
Status code: 200
The service task information is obtained.
{
"id" : "53e4xxxxxxxxxxxxxxxxxxxxxxb55b3e",
"name" : "task-test",
"creator" : "user_test",
"project_id" : "b722xxxxxxxxxxxxxxxxxxxxxxeb4674",
"description" : "hello world",
"service_id" : "88bbxxxx-xxxx-xxxx-xxxx-xxxxxxxxbcfe",
"created_at" : "2021-01-01T00:00:00Z",
"updated_at" : "2021-01-01T00:00:10Z",
"state" : "RUNNING",
"input" : {
"type" : "url",
"data" : [ {
"url" : "http://xxxx"
} ]
},
"output" : {
"dis" : {
"stream_name" : "dis-test"
}
},
"config" : {
"image_compression_ratio" : 90,
"render_result_sw" : 0,
"video_sampling_interval" : 1
}
}
Status code: 400
The request is invalid.
{
"error_code" : "ModelArts.0101",
"error_msg" : "Invalid argument. parameter [task_id] does not match ^[0-9a-f]{32}$."
}
Status code: 404
The specified service does not exist.
{
"error_code" : "ModelArts.3502",
"error_msg" : "Service 2a2db77f-xxxx-xxxx-xxxx-608a31865313 does not exist."
}
Status Codes¶
Status Code | Description |
---|---|
200 | The service task information is obtained. |
400 | The request is invalid. |
404 | The specified service does not exist. |
Error Codes¶
See Error Codes.