
# 子任务查询 - ListItaSubJobs
#### 功能介绍
该接口用于查询异步任务执行情况，比如查询创建桌面的执行状态。
#### 调试
您可以在[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/Workspace/doc?api=ListItaSubJobs)中调试该接口，支持自动认证鉴权。API Explorer可以自动生成SDK代码示例，并提供SDK代码示例调试功能。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-workspace/workspace_09_0128.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
  
  | 授权项                        | 访问级别 | 资源类型（\*为必须） | 条件键 | 别名 | 依赖的授权项 |
  |:---|:---|:---|:---|:---|:---|
  | workspace:jobs:listSubJobs | List | -           | -   | -  | -      |
     
  
 
#### URI
GET /v2/{project_id}/workspace-sub-jobs
表1路径参数 
| 参数         | 是否必选 | 参数类型   | 描述    |
|:---|:---|:---|:---|
| project_id | 是    | String | 项目id。 |
   
表2Query参数 
| 参数              | 是否必选 | 参数类型    | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
|:---|:---|:---|:---|
| status          | 否    | String  | 任务状态 - SUCCESS：成功。   - RUNNING：运行中。   - FAILED：失败。   - WAITING：等待。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| job_id          | 否    | String  | 任务ID。 "job_type"与"job_id"建议至少填写一个。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| job_type        | 否    | String  | 任务类型。 "job_type"与"job_id"建议至少填写一个 - createDesktops：创建桌面任务。   - applyWorkspace：开通云桌面服务。   - cancelWorkspace：注销云桌面服务。   - expandVolumes: 扩容磁盘。   - addVolumes: 添加磁盘。   - rebuildDesktops：重建桌面系统盘。   - createSnapshot：创建磁盘快照。   - deleteSnapshot：删除磁盘快照。   - deleteDesktops：删除桌面。   - desktopRejoinDomain：桌面重新加域。   - operateDesktops：操作桌面。   - restoreDesktopBySnapshot：使用快照恢复桌面。   - desktopToImage：桌面转镜像。   - attachDesktops：分配桌面。   - deleteVolumes：删除桌面磁盘（数据盘）。   - createWksSnapshot：创建快照。   - deleteWksSnapshot：删除快照。   - createDesktopPool：创建桌面池。   - expandDesktopPool：扩容桌面池。   - deleteDesktopPoolVolumes：桌面池删除桌面磁盘（数据盘）。   - rebuildDesktopPool：桌面池重建系统盘。   - addDesktopPoolVolumes：桌面池添加磁盘。   - detachDesktops：解绑桌面池桌面。   - attachDesktopPool：分配桌面池桌面。   - batchDetachDesktops：批量解绑桌面用户。   - executeDesktopsAction：桌面操作。   - changeDesktopNetwork：桌面切换网络。   - batchChangeDesktopNetwork：桌面切换网络。    |
| desktop_pool_id | 否    | String  | 桌面池ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| limit           | 否    | Integer | 用于分页查询，取值范围0\~1000，默认1000。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| offset          | 否    | Integer | 用于分页查询，查询的起始记录序号，从0开始。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
   
#### 请求参数
无
#### 响应参数
**状态码：200**
表3响应Body参数 
| 参数          | 参数类型                                                                      | 描述      |
|:---|:---|:---|
| total_count | Integer                                                                   | 任务列表总数。 |
| jobs        | Array of [JobDetailInfo] objects | 任务列表。   |
   
 表4JobDetailInfo 
| 参数          | 参数类型                                                        | 描述           |
|:---|:---|:---|
| id          | String                                                      | 子任务ID。       |
| job_type    | String                                                      | 任务类型。        |
| entities    | [JobEntities] object | 任务。          |
| begin_time  | String                                                      | 任务创建时间。      |
| end_time    | String                                                      | 任务结束时间。      |
| status      | String                                                      | 任务状态。        |
| error_code  | String                                                      | 任务执行失败时的错误码。 |
| fail_reason | String                                                      | 任务失败原因。      |
| host        | String                                                      | 任务执行的服务器IP。  |
| project_id  | String                                                      | 项目ID。        |
| job_id      | String                                                      | 任务ID。        |
| process     | Integer                                                     | 任务进度。        |
| attach_user | String                                                      | 关联用户。        |
| entity      | String                                                      | 操作对象。        |
| ip_address  | String                                                      | ip地址。        |
   
 表5JobEntities 
| 参数           | 参数类型   | 描述    |
|:---|:---|:---|
| desktop_id   | String | 桌面ID。 |
| product_id   | String | 套餐ID。 |
| user_name    | String | 用户名。  |
| desktop_name | String | 桌面名称。 |
| ip_address   | String | ip地址。 |
   
**状态码：400**
表6响应Body参数 
| 参数                            | 参数类型   | 描述                                                           |
|:---|:---|:---|
| error_code                    | String | 错误码。                                                         |
| error_msg                     | String | 错误描述。                                                        |
| error_detail                  | String | 错误详情。                                                        |
| encoded_authorization_message | String | 加密后的详细拒绝原因，用户可以自行调用STS服务的decode-authorization-message接口进行解密。 |
   
**状态码：401**
表7响应Body参数 
| 参数                            | 参数类型   | 描述                                                           |
|:---|:---|:---|
| error_code                    | String | 错误码。                                                         |
| error_msg                     | String | 错误描述。                                                        |
| error_detail                  | String | 错误详情。                                                        |
| encoded_authorization_message | String | 加密后的详细拒绝原因，用户可以自行调用STS服务的decode-authorization-message接口进行解密。 |
   
**状态码：403**
表8响应Body参数 
| 参数                            | 参数类型   | 描述                                                           |
|:---|:---|:---|
| error_code                    | String | 错误码。                                                         |
| error_msg                     | String | 错误描述。                                                        |
| error_detail                  | String | 错误详情。                                                        |
| encoded_authorization_message | String | 加密后的详细拒绝原因，用户可以自行调用STS服务的decode-authorization-message接口进行解密。 |
   
**状态码：404**
表9响应Body参数 
| 参数                            | 参数类型   | 描述                                                           |
|:---|:---|:---|
| error_code                    | String | 错误码。                                                         |
| error_msg                     | String | 错误描述。                                                        |
| error_detail                  | String | 错误详情。                                                        |
| encoded_authorization_message | String | 加密后的详细拒绝原因，用户可以自行调用STS服务的decode-authorization-message接口进行解密。 |
   
**状态码：405**
表10响应Body参数 
| 参数                            | 参数类型   | 描述                                                           |
|:---|:---|:---|
| error_code                    | String | 错误码。                                                         |
| error_msg                     | String | 错误描述。                                                        |
| error_detail                  | String | 错误详情。                                                        |
| encoded_authorization_message | String | 加密后的详细拒绝原因，用户可以自行调用STS服务的decode-authorization-message接口进行解密。 |
   
**状态码：500**
表11响应Body参数 
| 参数                            | 参数类型   | 描述                                                           |
|:---|:---|:---|
| error_code                    | String | 错误码。                                                         |
| error_msg                     | String | 错误描述。                                                        |
| error_detail                  | String | 错误详情。                                                        |
| encoded_authorization_message | String | 加密后的详细拒绝原因，用户可以自行调用STS服务的decode-authorization-message接口进行解密。 |
   
**状态码：503**
表12响应Body参数 
| 参数                            | 参数类型   | 描述                                                           |
|:---|:---|:---|
| error_code                    | String | 错误码。                                                         |
| error_msg                     | String | 错误描述。                                                        |
| error_detail                  | String | 错误详情。                                                        |
| encoded_authorization_message | String | 加密后的详细拒绝原因，用户可以自行调用STS服务的decode-authorization-message接口进行解密。 |
   
#### 请求示例
```
GET /v2/ac234de25c6741d2b1273da49eea1b9e/workspace-sub-jobs?status=FAILED&status=RUNNING&job_type=createDesktops
null
```
#### 响应示例
**状态码：200**
任务明细响应。
```
{
  "total_count" : 2,
  "jobs" : [ {
    "status" : "RUNNING",
    "entities" : {
      "user_name" : "user-test-01",
      "product_id" : "workspace.c2.large.windows",
      "desktop_id" : "9d30c8ac-77b5-4453-80da-8f027223ee99"
    },
    "job_id" : "0e2dae94-23ff-449a-bb9c-1b808cf2106d",
    "job_type" : "createDesktops",
    "begin_time" : "2020-04-10 06:45:14",
    "end_time" : "2020-04-10 07:06:10",
    "id" : "e43caef5-e478-4624-9e8c-b0b636331cbc"
  }, {
    "status" : "RUNNING",
    "entities" : {
      "user_name" : "user-test-01",
      "product_id" : "workspace.c2.large.windows",
      "desktop_id" : "14cccba0-12a6-4b66-9fd9-57290328f8da"
    },
    "job_id" : "0e2dae94-23ff-449a-bb9c-1b808cf2106d",
    "job_type" : "createDesktops",
    "begin_time" : "2020-04-10 06:45:14",
    "end_time" : "2020-04-10 07:05:49",
    "id" : "cf5043e9-dd94-43be-9c07-6dba5d43c4d2"
  } ]
}
```
#### 状态码
| 状态码 | 描述                      |
|:---|:---|
| 200 | 任务明细响应。                 |
| 400 | 由于包含语法错误，当前请求无法被服务器理解。  |
| 401 | 鉴权失败。                   |
| 403 | 没有操作权限。                 |
| 404 | 找不到资源。                  |
| 405 | 请求中指定的方法不被允许。           |
| 500 | 服务内部错误，具体返回错误码请参见错误码说明。 |
| 503 | 服务不可用。                  |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-workspace/ErrorCode.html)。
