更新时间:2024-04-22 GMT+08:00
分享

查询集群列表

功能介绍

该接口用于查询并显示集群列表以及集群的状态。

调用方法

请参见如何调用API

URI

GET /v1.0/{project_id}/clusters

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID。获取方法请参见获取项目ID和名称

表2 Query参数

参数

是否必选

参数类型

描述

start

Integer

指定查询起始值,默认值为1,即从第1个集群开始查询。

limit

Integer

指定查询个数,默认值为10,即一次查询10个集群信息。

datastoreType

String

集群引擎类型。

枚举值:

  • elasticsearch

  • logstash

请求参数

响应参数

状态码: 200

表3 响应Body参数

参数

参数类型

描述

totalSize

Integer

集群个数。

clusters

Array of ClusterList objects

集群对象列表。

表4 ClusterList

参数

参数类型

描述

datastore

ClusterListDatastore object

数据搜索引擎类型。

instances

Array of ClusterListInstances objects

节点对象列表。

publicKibanaResp

publicKibanaRespBody object

Kibana公网访问信息。

elbWhiteList

elbWhiteListResp object

弹性IP白名单列表。

updated

String

集群上次修改时间,格式为ISO8601: CCYY-MM-DDThh:mm:ss。

name

String

集群名称。

publicIp

String

公网IP信息。

created

String

集群创建时间,格式为ISO8601:CCYY-MM-DDThh:mm:ss。

返回的集群列表信息按照创建时间降序排序,即创建时间最新的集群排在最前。

id

String

集群ID。

status

String

集群状态值。

  • 100:创建中。

  • 200:可用。

  • 303:不可用,如创建失败。

endpoint

String

集群内网访问IPv4地址和端口号。

vpcId

String

VPC ID。

subnetId

String

子网ID。

securityGroupId

String

安全组ID。

bandwidthSize

Integer

公网带宽大小。单位:Mbit/s

httpsEnable

Boolean

通信加密状态。

  • false:未设置通信加密。

  • true:已设置通信加密。

authorityEnable

Boolean

是否开启认证。

  • true:表示集群开启认证。

  • false:表示集群不开启认证。

diskEncrypted

Boolean

磁盘是否加密。

  • true : 磁盘已加密。

  • false : 磁盘未加密。

backupAvailable

Boolean

快照是否开启。

  • true: 快照开启状态。

  • false: 快照关闭状态。

actionProgress

Object

集群行为进度,显示创建或扩容进度的百分比等。CREATING表示创建的百分比。

actions

Array of strings

集群当前行为。REBOOTING表示重启、GROWING表示扩容、RESTORING表示恢复集群、SNAPSHOTTING表示创建快照等。

enterpriseProjectId

String

集群所属的企业项目ID。 如果集群所属用户没有开通企业项目,则不会返回该参数。

tags

Array of ClusterListTags objects

集群标签。

failedReason

ClusterListFailedReasons object

失败原因。如果集群处于正常状态,则不返回该参数。

period

Boolean

是否为包周期集群。

  • "true" 表示是包周期计费的集群。

  • "false" 表示是按需计费的集群。

bandwidthResourceId

String

es公网访问的资源id。

ipv6Endpoint

String

集群内网访问IPv6地址和端口号。

表5 ClusterListDatastore

参数

参数类型

描述

type

String

引擎类型,支持elasticsearch,logstash。

version

String

CSS集群引擎版本号。详细请参考CSS支持的集群版本

supportSecuritymode

Boolean

是否支持安全模式。

表6 ClusterListInstances

参数

参数类型

描述

status

String

节点状态值。

  • 100:创建中。

  • 200:可用。

  • 303:不可用,如创建失败。

type

String

当前节点的类型。

id

String

实例ID。

name

String

实例名字。

specCode

String

节点规格名称。

azCode

String

节点所属AZ信息。

ip

String

实例ip信息。

volume

ClusterVolumeRsp object

实例磁盘信息。

resourceId

String

该实例对应的资源Id。

表7 ClusterVolumeRsp

参数

参数类型

描述

type

String

实例磁盘类型。

size

Integer

实例磁盘大小。

resourceIds

Array of strings

该实例拥有的磁盘对应的资源Id。

表8 publicKibanaRespBody

参数

参数类型

描述

eipSize

Integer

带宽大小。单位:Mbit/s

elbWhiteListResp

kibanaElbWhiteListResp object

Kibana公网访问信息。

publicKibanaIp

String

kibana访问IP。

bandwidthResourceId

String

当前kibana公网对应的资源Id。

表9 kibanaElbWhiteListResp

参数

参数类型

描述

enableWhiteList

Boolean

是否开启kibana访问控制。

  • true: 开启访问控制。

  • false: 关闭访问控制

whiteList

String

kibana公网访问白名单。

表10 elbWhiteListResp

参数

参数类型

描述

enableWhiteList

Boolean

是否开启公网访问控制。

  • true: 开启公网访问控制。

  • false: 关闭公网访问控制。

whiteList

String

公网访问白名单。

表11 ClusterListTags

参数

参数类型

描述

key

String

集群标签的key值。

value

String

集群标签的value值。

表12 ClusterListFailedReasons

参数

参数类型

描述

errorCode

String

错误码。

  • CSS.6000:表示集群创建失败。

  • CSS.6001:表示集群扩容失败。

  • CSS.6002:表示集群重启失败。

  • CSS.6004:表示集群节点创建失败。

  • CSS.6005:表示服务初始化失败。

errorMsg

String

详细错误信息。

请求示例

  • 查询前2个集群

    - 方法1:GET /v1.0/6204a5bd270343b5885144cf9c8c158d/clusters?start=1&limit=2
    
    - 方法2:GET /v1.0/6204a5bd270343b5885144cf9c8c158d/clusters?limit=2
  • 查询前10个集群

    - 方法1:GET /v1.0/6204a5bd270343b5885144cf9c8c158d/clusters?start=1&limit=10
    
    - 方法2:GET /v1.0/6204a5bd270343b5885144cf9c8c158d/clusters?limit=10

响应示例

状态码: 200

请求已成功。

{
  "totalSize" : 1,
  "clusters" : [ {
    "datastore" : {
      "type" : "elasticsearch",
      "version" : "7.10.2",
      "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}"
    } ],
    "publicKibanaResp" : {
      "eipSize" : 10,
      "publicKibanaIp" : "100.95.152.28",
      "elbWhiteListResp" : null,
      "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}",
    "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");

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

        CssClient client = CssClient.newBuilder()
                .withCredential(auth)
                .withRegion(CssRegion.valueOf("<YOUR REGION>"))
                .build();
        ListClustersDetailsRequest request = new ListClustersDetailsRequest();
        request.withStart(<start>);
        request.withLimit(<limit>);
        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

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

    credentials = BasicCredentials(ak, sk) \

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

    try:
        request = ListClustersDetailsRequest()
        request.start = <start>
        request.limit = <limit>
        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
38
39
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")

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

    client := css.NewCssClient(
        css.CssClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListClustersDetailsRequest{}
	startRequest:= int32(<start>)
	request.Start = &startRequest
	limitRequest:= int32(<limit>)
	request.Limit = &limitRequest
	response, err := client.ListClustersDetails(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

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

状态码

状态码

描述

200

请求已成功。

400

非法请求。

建议直接修改该请求,不要重试该请求。

404

所请求的资源不存在。

建议直接修改该请求,不要重试该请求。

错误码

请参见错误码

分享:

    相关文档

    相关产品