Updated on 2022-08-16 GMT+08:00

Querying Task Execution Status

Function

This API is used to query the execution status of an asynchronous request task.

After an asynchronous request task is issued, for example, creating or deleting an ECS, performing operations on ECSs in a batch, or performing operations on ECS NICs, a task ID will be returned, based on which you can query the execution status of the task.

For details about how to obtain the task ID, see Responses (Task).

URI

GET /v1/{project_id}/jobs/{job_id}

Table 1 describes the parameters in the URI.
Table 1 Parameter description

Parameter

Mandatory

Description

project_id

Yes

Specifies the project ID.

For details about how to obtain the ID, see Obtaining a Project ID.

job_id

Yes

Specifies the ID of an asynchronous request task.

Request

None

Response

Table 2 describes the response parameters.
Table 2 Response parameters

Parameter

Type

Description

status

String

Specifies the task status.

  • SUCCESS: indicates the task is successfully executed.
  • RUNNING: indicates that the task is in progress.
  • FAIL: indicates that the task failed.
  • INIT: indicates that the task is being initialized.

entities

Object

Specifies the object of the task.

The value of this parameter varies depending on the type of the task. If the task is an ECS-related operation, the value is server_id. If the task is a NIC operation, the value is nic_id. If a sub-Job is available, details about the sub-job are displayed.

For details, see Table 3.

job_id

String

Specifies the ID of an asynchronous request task.

job_type

String

Specifies the type of an asynchronous request task.

begin_time

String

Specifies the time when the task started.

end_time

String

Specifies the time when the task finished.

error_code

String

Specifies the returned error code when the task execution fails.

After the task is executed successfully, the value of this parameter is null.

fail_reason

String

Specifies the cause of the task execution failure.

After the task is executed successfully, the value of this parameter is null.

message

String

Specifies the error message returned when an error occurs in the request to query a task.

code

String

Specifies the error code returned when an error occurs in the request to query a task.

For details about the error code, see Returned Values for General Requests.

Table 3 entities field description

Parameter

Type

Description

sub_jobs_total

Integer

Specifies the number of subtasks.

sub_jobs

Array of objects

Specifies the execution information of a subtask.

For details, see Table 4.

Table 4 sub_jobs field description

Parameter

Type

Description

status

String

Specifies the task status.

  • SUCCESS: indicates the task is successfully executed.
  • RUNNING: indicates that the task is in progress.
  • FAIL: indicates that the task failed.
  • INIT: indicates that the task is being initialized.

entities

Object

Specifies the object of the task. The value of this parameter varies depending on the type of the task. If the task is an ECS-related operation, the value is server_id. If the task is a NIC operation, the value is nic_id. For details, see Table 5.

job_id

String

Specifies the subtask ID.

job_type

String

Specify the subtask type.

begin_time

String

Specifies the time when the task started.

end_time

String

Specifies the time when the task finished.

error_code

String

Specifies the returned error code when the task execution fails.

After the task is executed successfully, the value of this parameter is null.

fail_reason

String

Specifies the cause of the task execution failure.

After the task is executed successfully, the value of this parameter is null.

Table 5 entities field description

Parameter

Type

Description

server_id

String

If the task is an ECS-related operation, the value is server_id.

nic_id

String

If the task is a NIC-related operation, the value is nic_id.

errorcode_message

String

Indicates the cause of a subtask execution failure.

Example Request

GET https://{endpoint}/v1/{project_id}/jobs/{job_id}

Example Response

{
    "status": "SUCCESS",
    "entities": {
        "sub_jobs_total": 1,
        "sub_jobs": [
            {
                "status": "SUCCESS",
                "entities": {
                    "server_id": "bae51750-0089-41a1-9b18-5c777978ff6d"
                },
                "job_id": "2c9eb2c5544cbf6101544f0635672b60",
                "job_type": "createSingleServer",
                "begin_time": "2016-04-25T20:04:47.591Z",
                "end_time": "2016-04-25T20:08:21.328Z",
                "error_code": null,
                "fail_reason": null
            }
        ]
    },
    "job_id": "2c9eb2c5544cbf6101544f0602af2b4f",
    "job_type": "createServer",
    "begin_time": "2016-04-25T20:04:34.604Z",
    "end_time": "2016-04-25T20:08:41.593Z",
    "error_code": null,
    "fail_reason": null
}

Error Codes

See Error Codes.