查询集群列表
功能介绍
该接口用于查询并显示集群列表以及集群的状态,主要包括节点对象列表、Kibana公网访问信息、公网IP信息、集群内网访问IPv4地址和端口号等。适用于创建集群后,检查集群的基本情况,以便及时更新集群。
调用方法
请参见如何调用API。
URI
GET /v1.0/{project_id}/clusters
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
参数解释: 项目ID。获取方法请参见获取项目ID和名称。 约束限制: 不涉及 取值范围: 账户的项目ID。 默认取值: 不涉及 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
offset |
否 |
Integer |
参数解释: 指定查询起始值。 约束限制: 不涉及 取值范围: 1-1000 默认取值: 默认值为1,即从第1个集群开始查询。 |
limit |
否 |
Integer |
参数解释: 指定查询不同集群引擎类型的集群总数。。 约束限制: 不涉及 取值范围: 1-1000 默认取值: 默认值为10,即一次查询10个集群信息。 |
datastoreType |
否 |
String |
参数解释: 集群引擎类型。 约束限制: 不涉及 取值范围:
默认取值: 默认值为空。 |
请求参数
无
响应参数
状态码:200
参数 |
参数类型 |
描述 |
---|---|---|
totalSize |
Integer |
参数解释: 集群个数。若指定了datastoreType值,显示指定类型集群个数,反之为所有集群个数。 取值范围: 不涉及 |
clusters |
Array of ClusterList objects |
参数解释: 集群对象列表。 取值范围: 不涉及 |
参数 |
参数类型 |
描述 |
---|---|---|
datastore |
ClusterListDatastore object |
参数解释: 集群类型和版本信息。 取值范围: 不涉及 |
snapshotPolicy |
SnapshotPolicyResp object |
参数解释: 集群自动快照策略相关信息。 取值范围: 不涉及 |
instances |
Array of ClusterListInstances objects |
参数解释: 集群节点对象列表。 取值范围: 不涉及 |
publicKibanaResp |
publicKibanaRespBody object |
参数解释: 公网访问信息,包括IP地址、白名单、宽带信息等。 取值范围:
|
elbWhiteList |
elbWhiteListResp object |
参数解释: 公网访问控制信息。 取值范围: 不涉及 |
updated |
String |
参数解释: 集群上次修改时间。 取值范围: 格式为ISO8601:CCYY-MM-DDThh:mm:ss。 |
name |
String |
参数解释: 集群名称。 取值范围: 不涉及 |
publicIp |
String |
参数解释: 公网IP地址。 取值范围: 不涉及 |
created |
String |
参数解释: 集群创建时间,返回的集群列表信息按照创建时间降序排序,即创建时间最新的集群排在最前。 取值范围: 格式为ISO8601:CCYY-MM-DDThh:mm:ss。 |
id |
String |
参数解释: 集群ID。 取值范围: 字符串格式,包含小写字母、数字和中划线,长度为36。 |
status |
String |
参数解释: 集群状态值。 取值范围:
|
endpoint |
String |
参数解释: 集群内网访问IPv4地址和端口号,如10.10.20.2:9100。 取值范围: 不涉及 |
vpcId |
String |
参数解释: VPC ID,即虚拟私有云ID。 取值范围: 字符串格式,包含小写字母、数字和中划线,长度为36。 |
subnetId |
String |
参数解释: 集群的当前子网。用于后续新增节点的操作,包括扩容、添加Master/Client节点、开启终端节点服务,新增节点将通过新子网自动申请并绑定IP地址。 取值范围: 不涉及 |
securityGroupId |
String |
参数解释: 安全组ID。 取值范围: 不涉及 |
bandwidthSize |
Integer |
参数解释: 公网带宽大小。单位:Mbit/s 取值范围: 不涉及 |
httpsEnable |
Boolean |
参数解释: 是否开启HTTPS访问。 取值范围:
|
authorityEnable |
Boolean |
参数解释: 集群是否开启安全模式认证。 取值范围:
|
diskEncrypted |
Boolean |
参数解释: 磁盘是否加密,为受限功能,需要提交工单申请开通。 取值范围:
|
backupAvailable |
Boolean |
参数解释: 集群快照是否开启。 取值范围:
|
actionProgress |
Object |
参数解释: 集群行为进度,显示创建或扩容进度的百分比等。CREATING表示创建的百分比。 取值范围: 不涉及 |
actions |
Array of strings |
参数解释: 集群当前行为。 取值范围:
|
enterpriseProjectId |
String |
参数解释: 集群所属的企业项目ID。 如果集群所属用户没有开通企业项目,则不会返回该参数。 取值范围: 不涉及 |
tags |
Array of ClusterListTags objects |
参数解释: 集群标签。 取值范围: 不涉及 |
failedReason |
ClusterListFailedReasons object |
参数解释: 集群失败原因。如果集群处于正常状态,则不返回该参数。 取值范围: 不涉及 |
period |
Boolean |
参数解释: 是否为包周期集群。 取值范围:
|
bandwidthResourceId |
String |
参数解释: 当前kibana公网对应的资源ID。 取值范围: 不涉及 |
ipv6Endpoint |
String |
参数解释: 集群内网访问IPv6地址和端口号。 取值范围: 不涉及 |
cmkId |
String |
参数解释: 当前集群使用的磁盘加密密钥ID。 取值范围: 不涉及 |
currentSubnetIds |
String |
参数解释: 集群节点的当前子网。 取值范围: 不涉及 |
参数 |
参数类型 |
描述 |
---|---|---|
type |
String |
参数解释: 集群引擎类型。 取值范围:
|
version |
String |
参数解释: 集群引擎版本号。 取值范围: 详细请参考CSS使用前必读中支持的版本。 |
supportSecuritymode |
Boolean |
参数解释: 集群认证是否支持安全模式。 取值范围:
|
subVersion |
String |
参数解释: 集群发布版本号。 取值范围: 不涉及 |
isEosCluster |
Boolean |
参数解释: 表示集群发布版本是否EOS。 取值范围:
|
参数 |
参数类型 |
描述 |
---|---|---|
backupEnable |
Boolean |
参数解释: 集群是否开启自动快照。 取值范围:
|
bakPeriod |
String |
参数解释: 快照备份时间。 取值范围: 不涉及 |
bakFrequency |
String |
参数解释: 快照备份间隔。 取值范围:
|
bakKeepDay |
Integer |
参数解释: 快照备份保留个数。 取值范围: 不涉及 |
参数 |
参数类型 |
描述 |
---|---|---|
status |
String |
参数解释: 集群节点状态值。 取值范围:
|
type |
String |
参数解释: 当前集群节点的类型。 取值范围:
|
id |
String |
参数解释: 集群实例ID。 取值范围: 不涉及 |
name |
String |
参数解释: 集群实例名字。 取值范围: 不涉及 |
specCode |
String |
参数解释: 集群节点规格名称。参见获取实例规格列表的name属性。 取值范围: 不涉及 |
azCode |
String |
参数解释: 集群节点所属项目名称。 取值范围: 不涉及 |
ip |
String |
参数解释: 集群实例IP地址。 取值范围: 不涉及 |
volume |
ClusterVolumeRsp object |
参数解释: 节点储存类型和容量。 取值范围: 不涉及 |
resourceId |
String |
参数解释: 该实例对应的节点资源ID。 取值范围: 不涉及 |
subnetId |
String |
参数解释: 集群当前节点所属子网ID。 取值范围: 不涉及 |
参数 |
参数类型 |
描述 |
---|---|---|
type |
String |
参数解释: 实例磁盘类型。 取值范围:
|
size |
Integer |
参数解释: 实例磁盘大小,单位GB。 取值范围: 不涉及 |
resourceIds |
Array of strings |
参数解释: 该实例拥有的磁盘对应的计费资源ID。 取值范围: 不涉及 |
参数 |
参数类型 |
描述 |
---|---|---|
eipSize |
Integer |
参数解释: Kibana公网访问或Dashboards公网访问的带宽大小,单位:Mbit/s。 取值范围: 不涉及 |
elbWhiteListResp |
kibanaElbWhiteListResp object |
参数解释: kibana公网访问或Dashboards公网访问控制信息。 取值范围: 不涉及 |
publicKibanaIp |
String |
参数解释: kibana访问或Dashboards访问IP地址。 取值范围: 不涉及 |
bandwidthResourceId |
String |
参数解释: 当前kibana公网或Dashboards对应的资源ID。 取值范围: 不涉及 |
参数 |
参数类型 |
描述 |
---|---|---|
enableWhiteList |
Boolean |
参数解释: 是否开启kibana访问或Dashboards访问控制白名单。 取值范围:
|
whiteList |
String |
参数解释: kibana公网访问或Dashboards公网访问白名单。 取值范围: IP地址。 |
参数 |
参数类型 |
描述 |
---|---|---|
enableWhiteList |
Boolean |
参数解释: 是否开启Elb公网访问控制。设置访问白名单,表示只允许白名单列表中的IP地址访问集群;不设置白名单,所有的IP地址都可以访问集群。 取值范围:
|
whiteList |
String |
参数解释: Elb公网访问白名单。 取值范围: IP地址。 |
请求示例
-
查询前2个集群列表
- 方法1:GET https://{Endpoint}/v1.0/{project_id}/clusters?offset=1&limit=2 - 方法2:GET https://{Endpoint}/v1.0/{project_id}/clusters?limit=2
-
查询前10个集群列表
- 方法1:GET https://{Endpoint}/v1.0/{project_id}/clusters?offset=1&limit=10 - 方法2:GET https://{Endpoint}/v1.0/{project_id}/clusters?limit=10
响应示例
状态码:200
请求已成功。4个请求示例对应的响应示例类似,这里只给出示例,注意:示例中只有1个集群列表。
{ "totalSize" : 1, "clusters" : [ { "datastore" : { "type" : "elasticsearch", "version" : "7.10.2", "subVersion" : "7.10.2_24.3.0_0827", "isEosCluster" : false, "supportSecuritymode" : false }, "instances" : [ { "status" : "200", "type" : "ess", "id" : "{INSTANCE_ID}", "name" : "css-8bc5-ess-esn-1-1", "specCode" : "ess.spec-4u8g", "azCode" : "{AZ_CODE}", "volume" : { "type" : "ULTRAHIGH", "size" : 40, "resourceIds" : [ "{RESOURCE_ID}" ] }, "ip" : "192.168.0.122", "resourceId" : "{RESOURCE_ID}", "subnetId" : "{SUBNET_ID}" } ], "publicKibanaResp" : { "eipSize" : 10, "publicKibanaIp" : "100.95.152.28:9200", "bandwidthResourceId" : "18bec13f-5cc1-4631-867f-33505d15be12" }, "elbWhiteList" : { "whiteList" : "", "enableWhiteList" : false }, "updated" : "2023-10-09T02:07:13", "name" : "css-8bc5", "publicIp" : "100.85.222.202", "created" : "2023-10-09T02:07:13", "id" : "{CLUSTER_ID}", "status" : "200", "endpoint" : "192.168.0.122:9200", "vpcId" : "{VPC_ID}", "subnetId" : "{SUBNET_ID}", "currentSubnetIds" : "{SUBNET_ID}", "securityGroupId" : "{SECURITY_GROUP_ID}", "bandwidthResourceId" : "{BANDWIDTH_RESOURCE_ID}", "bandwidthSize" : 3, "httpsEnable" : true, "authorityEnable" : true, "diskEncrypted" : false, "backupAvailable" : false, "actionProgress" : { }, "actions" : [ ], "enterpriseProjectId" : "0", "tags" : [ ], "period" : true } ] }
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.css.v1.region.CssRegion; import com.huaweicloud.sdk.css.v1.*; import com.huaweicloud.sdk.css.v1.model.*; public class ListClustersDetailsSolution { 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); CssClient client = CssClient.newBuilder() .withCredential(auth) .withRegion(CssRegion.valueOf("<YOUR REGION>")) .build(); ListClustersDetailsRequest request = new ListClustersDetailsRequest(); try { ListClustersDetailsResponse response = client.listClustersDetails(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 huaweicloudsdkcss.v1.region.css_region import CssRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcss.v1 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 = CssClient.new_builder() \ .with_credentials(credentials) \ .with_region(CssRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListClustersDetailsRequest() response = client.list_clusters_details(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" css "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/css/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/css/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/css/v1/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 := css.NewCssClient( css.CssClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListClustersDetailsRequest{} response, err := client.ListClustersDetails(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
请求已成功。4个请求示例对应的响应示例类似,这里只给出示例,注意:示例中只有1个集群列表。 |
400 |
非法请求。 建议直接修改该请求,不要重试该请求。 |
404 |
所请求的资源不存在。 建议直接修改该请求,不要重试该请求。 |
错误码
请参见错误码。