• Elastic Cloud Server

ecs
  1. Help Center
  2. Elastic Cloud Server
  3. API Reference
  4. Extension ECS APIs
  5. Task Status Management
  6. Querying Task Execution Status

Querying Task Execution Status

Function Description

This interface is used to query the execution status of a task, such as ECS creation, ECS deletion, ECS batch operation, and NIC operation.

After a task is issued, a task ID is 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.

job_id

Yes

Specifies the task ID.

Request

N/A

Response

Response parameters

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

For the dictionary data structure, see Table 3.

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.

job_id

String

Specifies the task ID.

job_type

String

Specifies the task 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.

fail_reason

String

Specifies the cause of the task execution failure.

message

String

Specifies the returned error message when an error occurs.

code

String

Specifies the returned error code when an error occurs.

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

sub_jobs_total

Integer

Specifies the number of subtasks. When no subtask exists, the value of this parameter is 0.

sub_jobs

For the list data structure, see Table 4.

Specifies the execution information of a subtask. When no subtask exists, the value of this parameter is left blank.

Table 3 entities field description

Parameter

Type

Description

sub_jobs_total

Integer

Specifies the number of subtasks. When no subtask exists, the value of this parameter is 0.

sub_jobs

For the list data structure, see Table 4.

Specifies the execution information of a subtask. When no subtask exists, the value of this parameter is left blank.

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

Dictionary data structure (See Table 5.)

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.

job_id

String

Specifies the task ID.

job_type

String

Specifies the task 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.

fail_reason

String

Specifies the cause of the task execution failure.

message

String

Specifies the returned error message when an error occurs.

code

String

Specifies the returned error code when an error occurs.

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

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.

Examples

  • 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
    }

Returned Values

See General Request Returned Values.

Error Code

See Error Code Description.