查询集群列表
功能介绍
该接口用于查询并显示集群列表。
调用方法
请参见如何调用API。
URI
GET /v1.0/{project_id}/clusters
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
参数解释: 项目ID。获取方法请参见获取项目ID。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
enterprise_project_id |
否 |
String |
参数解释: 企业项目ID。查询所有绑定企业项目的集群,则值为all_granted_eps。 约束限制: 不涉及。 取值范围: all_granted_eps:所有企业项目。 0:表示默认企业项目“default”的ID。 其它:过滤对应企业项目下的数据。 默认取值: 不涉及。 |
请求参数
无
响应参数
状态码:200
参数 |
参数类型 |
描述 |
---|---|---|
clusters |
Array of ClusterInfo objects |
参数解释: 集群对象列表。 取值范围: 不涉及。 |
count |
Integer |
参数解释: 集群对象列表总数。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
id |
String |
参数解释: 集群ID。 取值范围: 不涉及。 |
name |
String |
参数解释: 集群名称。 取值范围: 同一个账号ID下唯一。 |
status |
String |
参数解释: 集群状态,字符串枚举。 取值范围:
|
version |
String |
参数解释: 数据仓库集群版本。 取值范围: 小数点分割的3~4段字符串,如9.1.0.200,每一段数字越大版本越新。 |
updated |
String |
参数解释: 集群上次修改时间,格式为ISO8601:YYYY-MM-DDThh:mm:ssZ 取值范围: 大于等于集群创建时间的ISO8601格式时间。 |
created |
String |
参数解释: 集群创建时间,格式为ISO8601:YYYY-MM-DDThh:mm:ssZ 取值范围: ISO8601格式的时间。 |
port |
Integer |
参数解释: 集群服务端口,创建集群时如未指定则默认8000。 取值范围: 8000~30000 |
endpoints |
Array of Endpoints objects |
参数解释: 集群的内网连接信息。 取值范围: 不涉及。 |
nodes |
Array of Nodes objects |
参数解释: 集群实例。 取值范围: 列表大小与集群节点数量字段number_of_node相同。 |
tags |
Array of Tags objects |
参数解释: 集群标签。 取值范围: 默认null。 |
user_name |
String |
参数解释: 管理员用户名。 取值范围: 默认dbadmin。 |
number_of_node |
Integer |
参数解释: 节点数量。创建集群时指定。 取值范围: 不涉及。 |
recent_event |
Integer |
参数解释: 事件数。仅记录用户操作且对集群产生影响的事件,部分按钮开闭类操作不记入集群事件数。 取值范围: 不涉及。 |
availability_zone |
String |
参数解释: 可用区。 取值范围: 不涉及。 |
enterprise_project_id |
String |
参数解释: 企业项目ID,对集群指定企业项目。如果未指定,则使用默认企业项目“default”的ID,即0。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 0 |
node_type |
String |
参数解释: 集群规格ID。 取值范围: 不涉及。 |
vpc_id |
String |
参数解释: 虚拟私有云ID。 取值范围: 不涉及。 |
subnet_id |
String |
参数解释: 子网ID。 取值范围: 不涉及。 |
public_ip |
PublicIp object |
参数解释: 公网IP信息,如果未指定,则默认不支持公网连接。 取值范围: 不涉及。 |
public_endpoints |
Array of PublicEndpoints objects |
参数解释: 公网IP信息,如果未指定,则默认不支持公网连接。 取值范围: 不涉及。 |
action_progress |
Map<String,String> |
参数解释: 任务信息,由key、value组成。key值为正在进行的任务,value值为正在进行任务的进度。 取值范围: key值的有效值包括但不限于以下这些:
|
sub_status |
String |
参数解释: “可用”集群状态的子状态。 取值范围: 有效值包括:
|
task_status |
String |
参数解释: 集群管理任务,表示当前正在进行的任务或已执行的任务的结果。 取值范围: 有效值包括但不限于以下值:
|
security_group_id |
String |
参数解释: 安全组ID。 取值范围: 不涉及。 |
failed_reasons |
FailedReason object |
参数解释: 失败原因。如果为空,则集群处于正常状态。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
connect_info |
String |
参数解释: 内网连接信息。 取值范围: 不涉及。 |
jdbc_url |
String |
参数解释: 内网JDBC URL。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: jdbc:postgresql://<connect_info>/<YOUR_DATABASE_NAME> |
参数 |
参数类型 |
描述 |
---|---|---|
id |
String |
参数解释: 集群实例ID。 取值范围: 不涉及。 |
status |
String |
参数解释: 集群实例状态。 取值范围: 100:创建中 199:空闲 200:可用 300:不可用 303:创建失败 304:删除中 305:删除失败 400:已删除 |
name |
String |
参数解释: 实例名称。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
key |
String |
参数解释: 标签的键。 约束限制: 不涉及。 取值范围:
默认取值: 不涉及。 |
value |
String |
参数解释: 标签的值。 约束限制: 不涉及。 取值范围:
默认取值: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
public_bind_type |
String |
参数解释: 弹性IP绑定类型。 约束限制: 不涉及。 取值范围: auto_assign:自动绑定。 not_use:暂未使用。 bind_existing :使用已有。 默认取值: null |
eip_id |
String |
参数解释: 弹性公网IP的id。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: null |
请求示例
GET https://{Endpoint}/v1.0/89cd04f168b84af6be287f71730fdb4b/clusters?enterprise_project_id=all_granted_eps
响应示例
状态码: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.dwscloud.com",
"jdbc_url" : "jdbc:postgresql://dws-1.cn-north-4.dwscloud.com/<YOUR_DATABASE_name>"
} ],
"nodes" : [ {
"id" : "acaf62a4-41b3-4106-bf6b-2f669d88291e",
"name" : "dws-1-dws-cn-cn-1-1",
"status" : "200"
}, {
"id" : "d32de51e-4fcd-4e5a-a9dc-bb903abb494b",
"name" : "dws-1-dws-cn-cn-2-1",
"status" : "200"
}, {
"id" : "d71a4a25-c9bc-4ffd-9f4a-e422aef327f9",
"name" : "dws-1-dws-cn-cn-3-1",
"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.dwscloud.com",
"jdbc_url" : "jdbc:postgresql://dws-1.cn-north-4.dwscloud.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 46 47 |
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");
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();
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 30 31 |
# 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 = 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 36 37 |
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 := basic.NewCredentialsBuilder().
WithAk(ak).
WithSk(sk).
WithProjectId(projectId).
Build()
client := dws.NewDwsClient(
dws.DwsClientBuilder().
WithRegion(region.ValueOf("<YOUR REGION>")).
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代码示例。
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 |
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");
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();
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 30 31 |
# 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 = 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 36 37 |
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 := basic.NewCredentialsBuilder().
WithAk(ak).
WithSk(sk).
WithProjectId(projectId).
Build()
client := dws.NewDwsClient(
dws.DwsClientBuilder().
WithRegion(region.ValueOf("<YOUR REGION>")).
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 |
服务不可用。 |