
# 查询定时任务列表 - QueryingScheduledTasks
#### 功能介绍
获取任务中心的定时任务列表。
- 调用接口前，您需要了解API [认证鉴权](https://support.huaweicloud.com/api-gaussdb/gaussdb_api_011.html)。
- 调用接口前，您需要提前获取到[地区和终端节点](https://developer.huaweicloud.com/endpoint)。
 
#### 接口约束
最多查询最近一个月的定时任务列表。
#### 调试
您可以在[API Explorer](https://apiexplorer.developer.huaweicloud.com/apiexplorer/doc?product=GaussDBforopenGauss&api=ListScheduleTask)中调试该接口。
#### URI
GET /v3/{project_id}/instances/schedule-tasks
表1参数说明 
| 名称          | 是否必选 | 参数类型    | 说明                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
|:---|:---|:---|:---|
| project_id  | 是    | String  | **参数解释：** 租户在某一Region下的项目ID。 获取方法请参见[获取项目ID](https://support.huaweicloud.com/api-gaussdb/gaussdb_api_196.html)。 **约束限制：** 不涉及。 **取值范围：** 只能由英文字母、数字组成，且长度为32个字符。 **默认取值**： 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| instance_id | 否    | String  | **参数解释：** 实例ID，此参数是用户创建实例的唯一标识。请参考[查询数据库实例列表 - QueryingDBInstances](https://support.huaweicloud.com/api-gaussdb/gaussdb_api_328.html)接口获取实例ID。 **约束限制：** 不涉及。 **取值范围：** 只能由英文字母、数字组成，且长度为36个字符。 **默认取值** **：** 不涉及。 |
| status      | 否    | String  | **参数解释：** 任务状态。 **约束限制：** 不涉及。 **取值范围：** - Running：运行中  - Completed：完成  - Failed：失败  - Pending：待执行  - Canceled：已取消   **默认取值** **：** 不涉及。                                                                                                                                                                                                                                                                                                                 |
| name        | 否    | String  | **参数解释：** 任务名称。 **约束限制：** 不涉及。 **取值范围：** HOTFIX_VERSION_UPGRADE ：热补丁版本升级。 **默认取值** **：** 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| start_time  | 否    | String  | **参数解释：** 开始时间。 格式为"yyyy-mm-ddThh:mm:ssZ"。 其中，T指某个时间的开始；Z指时区偏移量，例如北京时间偏移显示为+0800。 **约束限制：** 不涉及。 **取值范围：** 不涉及。 **默认取值** **：** 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| end_time    | 否    | String  | **参数解释：** 结束时间。 格式为"yyyy-mm-ddThh:mm:ssZ"。 其中，T指某个时间的开始；Z指时区偏移量，例如北京时间偏移显示为+0800。 **约束限制：** 不涉及。 **取值范围：** 不涉及。 **默认取值** **：** 不涉及。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| offset      | 否    | Integer | **参数解释：** 索引位置，偏移量。 **约束限制：** 不涉及。 **取值范围：** 0 \~ 2,147,483,647。 **默认取值** **：** 默认为0（偏移0条数据，表示从第一条数据开始查询）。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| limit       | 否    | Integer | **参数解释：** 查询记录数。 **约束限制：** 不涉及。 **取值范围：** 1\~100。 **默认取值** **：** 默认为100。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
   
#### 请求参数
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | **参数解释：** 用户Token。 通过调用IAM服务[获取用户Token](https://support.huaweicloud.com/api-iam/iam_30_0001.html)接口获取。 请求响应成功后在响应消息头中包含的"X-Subject-Token"的值即为Token值。 **约束限制：** 不涉及。 **取值范围：** 不涉及。 **默认取值** **：** 不涉及。 |
| X-Language   | 否    | String | **参数解释：** 指定接口返回信息的语言类型。 **约束限制：** 不涉及。 **取值范围：** - **zh-cn**：中文  - **en-us**：英文   **默认取值** **：** **en-us**                     |
   
#### 响应参数
表3要素说明 
| 名称          | 参数类型             | 说明                                                                                                                                                                                                                                              |
|:---|:---|:---|
| tasks       | Array of objects | **参数解释：** 任务列表。 详情请参见[表3 tasks字段数据结构说明]。 |
| total_count | Integer          | **参数解释：** 任务数量。 **取值范围：** 不涉及。                                       |
   
 表4tasks字段数据结构说明 
| 名称            | 参数类型   | 说明                                                                                                                                                                                                                                                                                                                                                     |
|:---|:---|:---|
| task_id       | String | **参数解释：** 任务ID。 **取值范围：** 不涉及。                                                                                                                                                   |
| task_name     | String | **参数解释：** 任务名称。 **取值范围：** 不涉及。                                                                                                                                             |
| status        | String | **参数解释：** 任务状态。 **取值范围：** 不涉及。                                                                                                                                             |
| create_time   | String | **参数解释：** 创建时间，格式为"yyyy-mm-ddThh:mm:ssZ"。 其中，T指某个时间的开始；Z指时区偏移量，例如北京时间偏移显示为+0800。 **取值范围：** 不涉及。   |
| start_time    | String | **参数解释：** 设置开始执行时间，格式为"yyyy-mm-ddThh:mm:ssZ"。 其中，T指某个时间的开始；Z指时区偏移量，例如北京时间偏移显示为+0800。 **取值范围：** 不涉及。 |
| instance_id   | String | **参数解释：** 实例ID。 **取值范围：** 不涉及。                                                                                                                                                 |
| instance_name | String | **参数解释：** 实例名称。 **取值范围：** 不涉及。                                                                                                                                                   |
| task_content  | String | **参数解释：** 任务信息。 **取值范围：** 不涉及。                                                                                                                                                 |
   
#### 请求示例
查询任务状态为"完成"的任务列表
```
GET https://gaussdb-opengauss.cn-north-1.myhuaweicloud.com/v3/0611f1bd8b00d5d32f17c017f15b599f/instances/schedule-tasks?status=Completed&offset=1&limit=10
```
#### 响应示例
查询任务列表成功。
```
{
    "tasks": [
        {
            "status": "Completed",
            "task_id": "dea835aa-5ceb-4209-be57-ecd7992ed6af",
            "task_name": "HOTFIX_VERSION_UPGRADE",
            "create_time": "2024-12-16T06:54:39Z",
            "start_time": "2024-12-16T06:55:32Z",
            "instance_id": "54bef6617fab4a88ab52967218c34527in14",
            "instance_name": "gauss-ba81",
            "task_content": "3.208.0.6"
        },
        {
            "status": "Completed",
            "task_id": "8d93aa3a-20c2-4c53-a3cf-933bde3ba002",
            "task_name": "HOTFIX_VERSION_UPGRADE",
            "create_time": "2024-12-16T06:54:39Z",
            "start_time": "2024-12-16T06:55:32Z",
            "instance_id": "096d0720b5604eca93b8a216a15d4778in14",
            "instance_name": "gauss-5185",
            "task_content": "3.208.0.6"
        },
        {
            "status": "Completed",
            "task_id": "5111a1e3-0030-4766-8dd8-7ab73a2e89c4",
            "task_name": "HOTFIX_VERSION_UPGRADE",
            "create_time": "2024-12-16T08:51:11Z",
            "start_time": "2024-12-16T08:53:01Z",
            "instance_id": "b6ac63d384854e76ba7afd0e10aa9c29in14",
            "instance_name": "gauss-7fa8",
            "task_content": "3.208.0.7"
        }
    ],
    "total_count": 3
}
```
#### 状态码
- 正常 200
  
- 异常 请参见[状态码](https://support.huaweicloud.com/api-gaussdb/gaussdb_api_194.html)。
  
 
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-gaussdb/gaussdb_api_195.html)。
