
# 查询资源任务列表 - QueryResourceTasks
#### 功能介绍
查询资源任务列表。
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-vpn/vpn_api_0008.html)。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-vpn/vpn_api_0044.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
| 授权项                                | 访问级别 | 资源类型（\*为必须） | 条件键 | 别名 | 依赖的授权项 |
|:---|:---|:---|:---|:---|:---|
| vpn:p2cVpnGateway:listResourceJobs | list | -           | -   | -  | -      |
   
#### URI
GET /v5/{project_id}/p2c-vpn-gateways/jobs
表1参数说明 
| 名称         | 类型     | 是否必选 | 说明                                                                                  |
|:---|:---|:---|:---|
| project_id | String | 是    | 项目ID，可以通过[获取项目ID](https://support.huaweicloud.com/api-vpn/vpn_api_0051.html)获取项目ID。 |
   
表2请求Query参数列表 
| 名称          | 类型      | 是否必选 | 描述                                                                                                                                                                                                                                                                                                                                               |
|:---|:---|:---|:---|
| resource_id | String  | 否    | 资源ID。                                                                                                                                                                                                                                                                                                                                            |
| limit       | Integer | 否    | 分页查询时每页返回的记录数量。                                                                                                                                                                                                                                                                                                                                  |
| marker      | String  | 否    | - 功能说明：查询本页的起始标记位，为空时为查询第一页。查询下一页的marker可以根据上一页响应的page_info对象中的next_marker填写。  - 约束：必须与limit一起使用。   |
   
#### 请求消息
- 请求参数 无。
  
- 请求样例
  1. 查询所有资源任务。
     ```
     GET https://{Endpoint}/v5/{project_id}/p2c-vpn-gateways/jobs
     ```
     
  
  2. 根据resource_id查询资源任务。
     ```
     GET https://{Endpoint}/v5/{project_id}/p2c-vpn-gateways/jobs?resource_id={resource_id}
     ```
     
   
 
#### 响应消息
- 响应参数 返回状态码为 200: 查询成功。
  表3响应Body参数列表 
  | 名称          | 类型                                                                                                                         | 描述        |
  |:---|:---|:---|
  | jobs        | Array of [Job](https://support.huaweicloud.com/api-vpn/vpn_api_0154.html#ZH-CN_TOPIC_0000002303712002__table92141) objects | 任务信息。     |
  | total_count | Integer                                                                                                                    | 网关总数。     |
  | page_info   | [PageInfo] object                                                      | 分页查询页的信息。 |
  | request_id  | String                                                                                                                     | 请求ID。     |
     
  表4Job 
  | 名称                    | 类型                                                                                                                            | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
  |:---|:---|:---|
  | id                    | String                                                                                                                        | - 功能说明：任务ID。  - 格式：36位UUID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
  | resource_id           | String                                                                                                                        | - 功能说明：VPN网关资源ID。  - 格式：36位UUID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
  | job_type              | String                                                                                                                        | - 功能说明：任务类型。  - 取值范围：upgrade，rollback，auto_rollback，create_gateway。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
  | status                | String                                                                                                                        | - 功能说明：VPN网关状态。  - 取值范围： - init：初始化  - running：执行中  - upgrading：升级中。  - pending_upgrade_confirm：等待升级确认。  - success：升级成功。  - rolling_back：回滚中。  - rollback_success：回滚成功。  - fail：升级失败。     |
  | expected_time_seconds | Integer                                                                                                                       | - 功能说明：预期剩余执行时间。  - 单位：秒。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
  | created_at            | String                                                                                                                        | - 功能说明：创建时间。  - UTC时间格式：*yyyy-MM-ddTHH:mm:ss.SSSZ。*                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
  | finished_at           | String                                                                                                                        | - 功能说明：结束时间。  - UTC时间格式：*yyyy-MM-ddTHH:mm:ss.SSSZ。*                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
  | error_message         | String                                                                                                                        | - 功能说明：错误信息。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
  | sub_jobs              | Array of [SubJob](https://support.huaweicloud.com/api-vpn/vpn_api_0154.html#ZH-CN_TOPIC_0000002303712002__table92142) objects | - 功能说明：子任务列表。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
     
  表5SubJob 
  | 名称                    | 类型      | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
  |:---|:---|:---|
  | id                    | String  | - 功能说明：任务ID。  - 格式：36位UUID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
  | job_type              | String  | - 功能说明：任务类型。  - 取值范围： - prepare_resource  - upgrade_worker_1  - upgrade_worker_2  - migrate_network_1                                                                                      |
  | status                | String  | - 功能说明：任务状态。  - 取值范围： - init：初始化  - running：执行中  - upgrading：升级中  - success：升级成功  - fail：升级失败     |
  | expected_time_seconds | Integer | - 功能说明：预期执行时间。  - 单位：秒。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
  | created_at            | String  | - 功能说明：创建时间。  - UTC时间格式：*yyyy-MM-ddTHH:mm:ss.SSSZ。*                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
  | finished_at           | String  | - 功能说明：结束时间。  - UTC时间格式：*yyyy-MM-ddTHH:mm:ss.SSSZ。*                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
  | error_message         | String  | - 功能说明：错误信息                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
     
   表6PageInfo 
  | 名称            | 类型      | 描述                                |
  |:---|:---|:---|
  | next_marker   | String  | 下一页的marker,值为上一次查询响应中最后一个资源的创建时间。 |
  | current_count | Integer | 当前列表中资源数量。                        |
     
  
- 响应样例
  ```
  {
    "request_id": "5a71735f134a5e7b3e67300ddcd04d8e",
    "jobs": [
      {
        "id": "5333d06c-8bdc-41e6-8758-f13fcef80d07",
        "resource_id": "a016ce55-4e35-47c1-ae3b-91cd022d1717",
        "job_type": "upgrade",
        "status": "success",
        "created_at": "2026-03-20T03:26:18.338355Z",
        "finished_at": "2026-03-20T03:26:40.407165Z",
        "sub_jobs": [
          {
            "id": "a5a1bebc-5430-4bc6-9b76-e24c6e5e3359",
            "job_type": "prepare_resource",
            "status": "success",
            "expected_time_seconds": 20,
            "created_at": "2026-03-20T03:26:18.334659064Z",
            "finished_at": "2026-03-20T03:26:35.49934131Z"
          },
          {
            "id": "e1cfb414-3630-4ed6-a602-22d9f40646fa",
            "job_type": "migrate_network_1",
            "status": "success",
            "expected_time_seconds": 10,
            "created_at": "2026-03-20T03:26:18.33738937Z",
            "finished_at": "2026-03-20T03:26:40.124594368Z"
          }
        ]
      }
    ],
    "total_count": 1,
    "page_info": {
      "current_count": 1
    }
  }
  ```
  
 
#### 状态码
请参见[状态码](https://support.huaweicloud.com/api-vpn/vpn_api_0052.html)。
