文档首页/ 数据仓库服务 DWS/ API参考/ API说明/ 智能运维/ 查询运维任务列表 - ListOperationalTask
更新时间:2026-09-28 GMT+08:00

查询运维任务列表 - ListOperationalTask

功能介绍

查询运维任务列表。

调用方法

请参见如何调用API。

授权信息

账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限。

  • 如果使用角色与策略授权,具体权限要求请参见权限和授权项。
  • 如果使用身份策略授权,需具备如下身份策略权限。

    授权项

    访问级别

    资源类型(*为必须)

    条件键

    别名

    依赖的授权项

    dws:cluster:listOperationalTask

    List

    cluster *

    • g:ResourceTag/<tag-key>

    • g:EnterpriseProjectId

    dws:operationalTask:get

    -

URI

GET /v1/{project_id}/clusters/{cluster_id}/operational-tasks

表1 路径参数

参数

是否必选

参数类型

描述

project_id

是

String

参数解释:

项目ID。获取方法请参见获取项目ID。

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

不涉及。

cluster_id

是

String

参数解释:

集群ID。获取方法请参见获取集群ID。

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

不涉及。

表2 Query参数

参数

是否必选

参数类型

描述

time_zone

否

String

参数解释:

时区偏移量,默认为UTC时间(0偏移),即+0000。

约束限制:

不涉及。

取值范围:

-2359~+2359

默认取值:

+0000

type

否

String

参数解释:

任务类型。

约束限制:

仅支持两种值。

取值范围:

Date:单次型任务;

Window:周期型任务;

默认取值:

无。

limit

否

Integer

参数解释:

分页查询,每页大小。

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

100

offset

否

Integer

参数解释:

分页偏移量,从0开始,页数减1。

约束限制:

不涉及。

取值范围:

大于等于0

默认取值:

0

请求参数

无

响应参数

状态码:200

表3 响应Body参数

参数

参数类型

描述

count

Integer

参数解释:

总条数。

取值范围:

大于等于0。

data

Array of TaskInfoVo objects

参数解释:

任务列表。

取值范围:

不涉及。

表4 TaskInfoVo

参数

参数类型

描述

category

String

参数解释:

分类。

取值范围:

VacuumFull

description

String

参数解释:

描述信息。

取值范围:

不涉及。

type

String

参数解释:

任务类型。

取值范围:

Window:周期型任务;

Date:单次型任务;

task_id

String

参数解释:

任务ID。

取值范围:

不涉及。

task_name

String

参数解释:

任务名称。

取值范围:

不涉及。

start_time

String

参数解释:

任务开始时间。

取值范围:

不涉及。

end_time

String

参数解释:

任务结束时间。

取值范围:

不涉及。

white_list

Array of DateInfo objects

参数解释:

任务时间窗。

取值范围:

不涉及。

vacuum_mode

String

参数解释:

任务模式。

取值范围:

manual:指定目标;

auto:自动;

vacuum_target

String

参数解释:

自动Vacuum目标。

取值范围:

user_vacuumfull:用户表VacuumFull;

system_vacuum:系统表VacuumFull;

is_paused

Integer

参数解释:

是否暂停。

取值范围:

0:否;

1:是;

vacuum_threshold

String

参数解释:

膨胀率,单位为百分比。

取值范围:

不涉及。

vacuum_retrieving_space

String

参数解释:

目标表可回收空间。

取值范围:

不涉及。

vacuum_priority

Array of TableInfoOpen objects

参数解释:

优先Vacuum目标。

取值范围:

不涉及。

time_zone

String

参数解释:

时区信息。

取值范围:

不涉及。

表5 DateInfo

参数

参数类型

描述

date_type

String

参数解释:

日期类型,如每月1号执行则为1th。

取值范围:

不涉及。

date_start

String

参数解释:

开始时间,如:04:00:00。

取值范围:

不涉及。

date_end

String

参数解释:

结束时间,如:08:00:00。

取值范围:

不涉及。

表6 TableInfoOpen

参数

参数类型

描述

database_name

String

参数解释:

数据库名。

取值范围:

不涉及。

schema_name

String

参数解释:

模式名。

取值范围:

不涉及。

table_name

String

参数解释:

表名。

取值范围:

不涉及。

请求示例

查询运维任务列表。

GET https://{Endpoint}/v1/169439ece752470aa5171633e9d3e47f/clusters/50aee999-9215-4dd0-a142-254ac6bf80e7/operational-tasks

响应示例

状态码:200

{
  "data" : [ {
    "category" : "VacuumFull",
    "description" : "desc",
    "type" : "Window",
    "task_id" : "VacuumFull_68FCLmSTSScb87zWrxEFZ",
    "task_name" : "test1",
    "start_time" : "2025-12-31T20:00:00Z",
    "end_time" : "2026-01-01T00:00:00Z",
    "white_list" : [ {
      "date_type" : "31th",
      "date_start" : "20:00:00",
      "date_end" : "23:59:59"
    }, {
      "date_type" : "1th",
      "date_start" : "00:00:00",
      "date_end" : "00:00:00"
    } ],
    "vacuum_mode" : "manual",
    "vacuum_target" : "",
    "is_paused" : 0,
    "vacuum_threshold" : "",
    "vacuum_retrieving_space" : "",
    "vacuum_priority" : [ {
      "database_name" : null,
      "schema_name" : "public",
      "table_name" : "a"
    } ],
    "time_zone" : null
  } ],
  "count" : 1
}

SDK代码示例

SDK代码示例如下。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.dws.v2.region.DwsRegion;
import com.huaweicloud.sdk.dws.v2.*;
import com.huaweicloud.sdk.dws.v2.model.*;


public class ListOperationalTaskSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        DwsClient client = DwsClient.newBuilder()
                .withCredential(auth)
                .withRegion(DwsRegion.valueOf("<YOUR REGION>"))
                .build();
        ListOperationalTaskRequest request = new ListOperationalTaskRequest();
        request.withClusterId("{cluster_id}");
        try {
            ListOperationalTaskResponse response = client.listOperationalTask(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdws.v2.region.dws_region import DwsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkdws.v2 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = DwsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(DwsRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListOperationalTaskRequest()
        request.cluster_id = "{cluster_id}"
        response = client.list_operational_task(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    dws "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth, err := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        SafeBuild()

    if err != nil {
        fmt.Println(err)
        return
    }

    hcClient, err := dws.DwsClientBuilder().
         WithRegion(region.ValueOf("<YOUR REGION>")).
         WithCredential(auth).
         SafeBuild()


    if err != nil {
        fmt.Println(err)
        return
    }

    client := dws.NewDwsClient(hcClient)

    request := &model.ListOperationalTaskRequest{}
	request.ClusterId = "{cluster_id}"
	response, err := client.ListOperationalTask(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

查询运维任务列表响应信息。

400

请求错误。

401

鉴权失败。

403

没有操作权限。

404

找不到资源。

500

服务内部错误。

503

服务不可用。