查询集群列表
功能介绍
查询集群列表接口。
调用方法
请参见如何调用API。
URI
GET /v1.1/{project_id}/clusters
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
项目ID,获取方法请参见项目ID和账号ID |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
clusters |
Array of clusters objects |
集群列表,请参见clusters参数说明。 |
参数 |
参数类型 |
描述 |
---|---|---|
customerConfig |
CustomerConfig object |
用户配置信息 |
datastore |
Datastore object |
cdm信息 |
instances |
Array of ClusterDetailInstance objects |
集群的节点信息,请参见instances参数说明。 |
azName |
String |
az名称 |
dbuser |
String |
数据库用户 |
flavorName |
String |
规格名称 |
recentEvent |
Integer |
事件数 |
isAutoOff |
Boolean |
自动关机 |
isScheduleBootOff |
Boolean |
选择是否启用定时开关机功能。定时开关机功能和自动关机功能不可同时开启。 |
clusterMode |
String |
集群模式:sharding(分片集群) |
namespace |
String |
命名空间 |
task |
ClusterTask object |
任务信息 |
publicEndpoint |
String |
集群绑定的EIP |
actionProgress |
ActionProgress object |
集群操作进度,任务信息,由key、value组成。key值为正在进行的任务,value值为正在进行任务的进度。示例如 "action_progress":{"SNAPSHOTTING":"16%"}。 |
created |
String |
集群创建时间,格式为ISO8601:YYYY-MM-DDThh:mm:ssZ |
bakExpectedStartTime |
String |
开始时间 |
bakKeepDay |
Integer |
保留时间 |
name |
String |
集群名称 |
statusDetail |
String |
集群状态描述:Normal(正常) |
id |
String |
集群ID |
isFrozen |
String |
集群是否冻结:0:否 1:是 |
updated |
String |
集群更新时间,格式为ISO8601:YYYY-MM-DDThh:mm:ssZ |
status |
String |
集群状态:
|
failedReasons |
FailedReasons object |
失败原因。集群处于正常状态时不返回。 |
参数 |
参数类型 |
描述 |
---|---|---|
failureRemind |
String |
失败提醒。 |
clusterName |
String |
集群类型。 |
serviceProvider |
String |
服务提供 |
localDisk |
String |
是否本地磁盘。 |
ssl |
String |
是否使用ssl。 |
createFrom |
String |
创建来源 |
resourceId |
String |
资源ID |
flavorType |
String |
规格类型 |
workSpaceId |
String |
工作空间ID |
trial |
String |
适用 |
参数 |
参数类型 |
描述 |
---|---|---|
flavor |
flavor object |
节点的虚拟机规格,请参见flavor参数说明(查询集群列表时返回值为null)。 |
volume |
volume object |
节点的磁盘信息,请参见volume参数说明(查询集群列表时返回值为null)。 |
status |
String |
节点状态:
|
actions |
Array of strings |
节点操作状态列表:
|
type |
String |
节点类型,只支持一种类型“cdm”。 |
id |
String |
节点的虚拟机ID。 |
name |
String |
节点的虚拟机名称。 |
isFrozen |
String |
节点是否冻结:0:否。1:是。 |
components |
String |
组件 |
config_status |
String |
节点配置状态(查询集群列表时为null):
|
role |
String |
实例角色 |
group |
String |
分组 |
links |
Array of ClusterLinks objects |
链接信息(查询集群列表时返回值为null) |
paramsGroupId |
String |
组件分组id |
publicIp |
String |
公网ip |
manageIp |
String |
管理ip |
trafficIp |
String |
流量ip |
shard_id |
String |
分片id |
manage_fix_ip |
String |
管理修复ip |
private_ip |
String |
私有ip |
internal_ip |
String |
内部ip |
resource |
Array of Resource objects |
资源信息(查询集群列表时返回值为null) |
请求示例
GET /v1.1/1551c7f6c808414d8e9f3c514a170f2e/clusters
响应示例
状态码: 200
ok
{ "clusters" : [ { "publicEndpoint" : "49.xx.xx.10", "actionProgress" : { }, "created" : "2018-09-05T08:38:25", "name" : "cdm-c018", "statusDetail" : "Normal", "id" : "bae65496-643e-47ca-84af-948672de7eeb", "isFrozen" : "0", "updated" : "2018-09-05T08:38:25", "status" : "200" } ] }
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.cdm.v1.region.cdmRegion; import com.huaweicloud.sdk.cdm.v1.*; import com.huaweicloud.sdk.cdm.v1.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); cdmClient client = cdmClient.newBuilder() .withCredential(auth) .withRegion(cdmRegion.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 |
# coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcdm.v1.region.cdm_region import cdmRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcdm.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 = __import__('os').getenv("CLOUD_SDK_AK") sk = __import__('os').getenv("CLOUD_SDK_SK") projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) \ client = cdmClient.new_builder() \ .with_credentials(credentials) \ .with_region(cdmRegion.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" cdm "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdm/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdm/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdm/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 := cdm.NewcdmClient( cdm.cdmClientBuilder(). 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 |
ok |
400 |
请求错误 |
401 |
鉴权失败 |
403 |
没有操作权限 |
404 |
找不到资源 |
500 |
服务内部错误,具体返回错误码请参考错误码 |
503 |
服务不可用 |
错误码
请参见错误码。