更新时间:2024-03-19 GMT+08:00
分享

查询集群列表

功能介绍

该接口用于查询并显示集群列表。

调用方法

请参见如何调用API

URI

1
GET /v1.0/{project_id}/clusters
表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

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

请求参数

响应参数

状态码: 200

表2 响应Body参数

参数

参数类型

描述

clusters

Array of ClusterInfo objects

集群对象列表。

count

Integer

集群对象的总数。

表3 ClusterInfo

参数

参数类型

描述

id

String

集群ID。

name

String

集群名称。

status

String

集群状态,有效值包括:

  • CREATING(100):创建中

  • ACTIVE(200):可用

  • FAILED(300):不可用

  • CREATION FAILED(303):创建失败

  • DELETING(304):删除中

  • DELETION FAILED(302):删除失败

  • DELETED(400):已删除

  • STOPING(910):停止中
  • STOPPED(900):已停止
  • STARTING(920):启动中
  • FROZEN(800):已冻结

    说明:

    如果用户查询返回状态为“AVAILABLE(200)”,也表示可用。

version

String

数据仓库版本。

updated

String

集群上次修改时间,格式为 ISO8601:YYYY-MM-DDThh:mm:ssZ

created

String

集群创建时间,格式为 ISO8601:YYYY-MM-DDThh:mm:ssZ

port

Integer

集群服务端口。

endpoints

Array of Endpoints objects

集群的内网连接信息。

nodes

Array of Nodes objects

集群实例。

tags

Array of Tags objects

集群标签。

user_name

String

管理员用户名。

number_of_node

Integer

集群节点数量。

recent_event

Integer

事件数。

availability_zone

String

可用区。

enterprise_project_id

String

企业项目ID。值为0表示默认企业项目“default”。

node_type

String

节点类型。

vpc_id

String

虚拟私有云ID。

subnet_id

String

子网ID。

public_ip

PublicIp object

公网IP地址,如果未指定,则默认不使用公网连接。

public_endpoints

Array of PublicEndpoints objects

集群的公网连接信息,如果未指定,则默认不使用公网连接信息。

action_progress

Map<String,String>

任务信息,由key、value组成。key值为正在进行的任务,value值为正在进行任务的进度。key值的有效值包括:

  • CREATING:创建中

  • RESTORING:恢复中

  • SNAPSHOTTING:快照中

  • GROWING:扩容中

  • REBOOTING:重启中

  • SETTING_CONFIGURATION:安全设置配置中

  • CONFIGURING_EXT_DATASOURCE:MRS连接配置中

  • ADD_CN_ING:增加CN中

  • DEL_CN_ING:删除CN中

  • REDISTRIBUTING:重分布中

  • ELB_BINDING:弹性负载均衡绑定中

  • ELB_UNBINDING:弹性负载均衡解绑中

  • ELB_SWITCHING:弹性负载均衡切换中

  • NETWORK_CONFIGURING:网络配置中

  • DISK_EXPANDING:磁盘扩容中

  • ACTIVE_STANDY_SWITCHOVER:主备恢复中

  • CLUSTER_SHRINKING:缩容中

  • SHRINK_CHECKING:缩容检测中

  • FLAVOR_RESIZING:规格变更中

  • MANAGE_IP_BINDING:登录开通中

  • FINE_GRAINED_RESTORING:细粒度恢复中

  • DR_RECOVERING:容灾恢复中

  • REPAIRING:修复中

示例如下:

"action_progress":
{"SNAPSHOTTING":"16%"}

sub_status

String

“可用”集群状态的子状态,有效值包括:

  • NORMAL:正常
  • READONLY:只读
  • REDISTRIBUTING:重分布中
  • REDISTRIBUTION-FAILURE:重分布失败
  • UNBALANCED:非均衡
  • UNBALANCED | READONLY:非均衡,只读-
  • DEGRADED:节点故障
  • DEGRADED | READONLY:节点故障,只读
  • DEGRADED | UNBALANCED:节点故障,非均衡
  • UNBALANCED | REDISTRIBUTING:非均衡,重分布中
  • UNBALANCED | REDISTRIBUTION-FAILURE:非均衡,重分布失败
  • READONLY | REDISTRIBUTION-FAILURE:只读,重分布失败
  • UNBALANCED | READONLY | REDISTRIBUTION-FAILURE:非均衡,只读,重分布失败
  • DEGRADED | REDISTRIBUTION-FAILURE:节点故障,重分布失败
  • DEGRADED | UNBALANCED | REDISTRIBUTION-FAILURE:节点故障,非均衡,只读,重分布失败
  • DEGRADED | UNBALANCED | READONLY | REDISTRIBUTION-FAILURE:节点故障,非均衡,只读,重分布失败
  • DEGRADED | UNBALANCED | READONLY:节点故障,非均衡,只读

task_status

String

集群管理任务,有效值包括:

  • UNFREEZING:解冻中

  • FREEZING:冻结中

  • RESTORING:恢复中

  • SNAPSHOTTING:快照中

  • GROWING:扩容中

  • REBOOTING:重启中

  • SETTING_CONFIGURATION:安全设置配置中

  • CONFIGURING_EXT_DATASOURCE:MRS连接配置中

  • DELETING_EXT_DATASOURCE:删除MRS连接

  • REBOOT_FAILURE:重启失败

  • RESIZE_FAILURE:扩容失败

  • ADD_CN_ING:增加CN中

  • DEL_CN_ING:删除CN中

  • CREATING_NODE:添加节点

  • CREATE_NODE_FAILED:添加节点失败

  • DELETING_NODE:删除节点

  • DELETE_NODE_FAILED:删除节点失败

  • REDISTRIBUTING:重分布中

  • REDISTRIBUTE_FAILURE:重分布失败

  • WAITING_REDISTRIBUTION:待重分布

  • REDISTRIBUTION_PAUSED:重分布暂停

  • ELB_BINDING:弹性负载均衡绑定中

  • ELB_BIND_FAILED:弹性负载均衡绑定失败

  • ELB_UNBINDING:弹性负载均衡解绑中

  • ELB_UNBIND_FAILED:弹性负载均衡解绑失败

  • ELB_SWITCHING:弹性负载均衡切换中

  • ELB_SWITCHING_FAILED:弹性负载均衡切换失败

  • NETWORK_CONFIGURING:网络配置中

  • NETWORK_CONFIG_FAILED:网络配置失败

  • DISK_EXPAND_FAILED:磁盘扩容失败

  • DISK_EXPANDING:磁盘扩容中

  • ACTIVE_STANDY_SWITCHOVER:主备恢复中

  • ACTIVE_STANDY_SWITCHOVER_FAILURE:主备恢复失败

  • CLUSTER_SHRINK_FAILED:缩容失败

  • CLUSTER_SHRINKING:缩容中

  • SHRINK_CHECK_FAILED:缩容检测失败

  • SHRINK_CHECKING:缩容检测中

  • FLAVOR_RESIZING_FAILED:规格变更失败

  • FLAVOR_RESIZING:规格变更中

  • MANAGE_IP_BIND_FAILED:登录开通失败

  • MANAGE_IP_BINDING:登录开通中

  • ORDER_PENDING:订单待支付

  • FINE_GRAINED_RESTORING:细粒度恢复中

  • DR_RECOVERING:容灾恢复中

security_group_id

String

安全组ID。

failed_reasons

FailedReason object

失败原因。如果为空,则集群处于正常状态。

表4 Endpoints

参数

参数类型

描述

connect_info

String

内网连接信息。

jdbc_url

String

内网JDBC URL,默认格式如下: jdbc:postgresql://<connect_info>/<YOUR_DATABASE_NAME>

表5 Nodes

参数

参数类型

描述

id

String

集群实例ID。

status

String

集群实例状态。

  • 100:创建中

  • 199:空闲

  • 200:可用

  • 300:不可用

  • 303:创建失败

  • 304:删除中

  • 305:删除失败

  • 400:已删除

表6 Tags

参数

参数类型

描述

key

String

键。输入标签键的最大长度为128个字符,不能为空字符串,且首尾字符不能为空格。 不能包含“=”,“*”,“<”,“>”,“\”,“,”,“|”,“/”。 只能包含大写字母(A-Z)、小写字母(a-z)、数字(0-9)和特殊字符(中划线-、下划线_)以及中文字符。

value

String

值。输入标签值的最大长度为255个字符,首尾字符不能为空格,可以为空字符串。 不能包含“=”,“*”,“<”,“>”,“\”,“,”,“|”,“/”。 只能包含大写字母(A-Z)、小写字母(a-z)、数字(0-9)和特殊字符(中划线-、下划线_)以及中文字符。

表7 PublicIp

参数

参数类型

描述

public_bind_type

String

弹性IP绑定类型,取值如下:

  • auto_assign:现在购买

  • not_use:暂不使用

  • bind_existing :使用已有

eip_id

String

弹性IP的ID。

表8 PublicEndpoints

参数

参数类型

描述

public_connect_info

String

公网连接信息。

jdbc_url

String

公网JDBC URL,默认格式如下: jdbc:postgresql://<public_connect_info>/<YOUR_DATABASE_name>

表9 FailedReason

参数

参数类型

描述

error_code

String

错误码。

error_msg

String

错误信息。

请求示例

GET https://{Endpoint}/v1.0/89cd04f168b84af6be287f71730fdb4b/clusters

响应示例

状态码: 200

查询集群列表成功。

{
  "clusters" : [ {
    "id" : "7d85f602-a948-4a30-afd4-e84f47471c15",
    "name" : "dws-1",
    "status" : "AVAILABLE",
    "version" : "1.2.0",
    "updated" : "2016-02-10T14:28:14Z",
    "created" : "2016-02-10T14:26:14Z",
    "port" : 8000,
    "endpoints" : [ {
      "connect_info" : "dws-1.cn-north-4.myhuaweicloud.com",
      "jdbc_url" : "jdbc:postgresql://dws-1.cn-north-4.myhuaweicloud.com/<YOUR_DATABASE_name>"
    } ],
    "nodes" : [ {
      "id" : "acaf62a4-41b3-4106-bf6b-2f669d88291e",
      "status" : "200"
    }, {
      "id" : "d32de51e-4fcd-4e5a-a9dc-bb903abb494b",
      "status" : "200"
    }, {
      "id" : "d71a4a25-c9bc-4ffd-9f4a-e422aef327f9",
      "status" : "200"
    } ],
    "tags" : [ {
      "key" : "key1",
      "value" : "value1"
    }, {
      "key" : "key2",
      "value" : "value2"
    } ],
    "user_name" : "dbadmin",
    "number_of_node" : 3,
    "recent_event" : 6,
    "availability_zone" : "cn-north-4b",
    "enterprise_project_id" : "0",
    "node_type" : "dws.d1.xlarge.ultrahigh",
    "vpc_id" : "85b20d7e-9eb7-4b2a-98f3-3c8843ea3574",
    "subnet_id" : "374eca02-cfc4-4de7-8ab5-dbebf7d9a720",
    "public_ip" : {
      "public_bind_type" : "auto_assign",
      "eip_id" : "85b20d7e-9eb7-4b2a-98f3-3c8843ea3574"
    },
    "public_endpoints" : [ {
      "public_connect_info" : "dws-1.cn-north-4.myhuaweicloud.com",
      "jdbc_url" : "jdbc:postgresql://dws-1.cn-north-4.myhuaweicloud.com/<YOUR_DATABASE_name>"
    } ],
    "action_progress" : {
      "SNAPSHOTTING" : "20%"
    },
    "sub_status" : "READONLY",
    "task_status" : "SNAPSHOTTING",
    "security_group_id" : "dc3ec145-9029-4b39-b5a3-ace5a01f772b"
  } ]
}

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
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 ListClustersSolution {

    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");

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

        DwsClient client = DwsClient.newBuilder()
                .withCredential(auth)
                .withRegion(DwsRegion.valueOf("cn-north-4"))
                .build();
        ListClustersRequest request = new ListClustersRequest();
        try {
            ListClustersResponse response = client.listClusters(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
# coding: utf-8

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.getenv("CLOUD_SDK_AK")
    sk = os.getenv("CLOUD_SDK_SK")

    credentials = BasicCredentials(ak, sk) \

    client = DwsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(DwsRegion.value_of("cn-north-4")) \
        .build()

    try:
        request = ListClustersRequest()
        response = client.list_clusters(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
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")

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := dws.NewDwsClient(
        dws.DwsClientBuilder().
            WithRegion(region.ValueOf("cn-north-4")).
            WithCredential(auth).
            Build())

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

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

状态码

状态码

描述

200

查询集群列表成功。

400

请求错误。

401

鉴权失败。

403

没有操作权限。

404

找不到资源。

500

服务内部错误。

503

服务不可用。

分享:

    相关文档

    相关产品