
# 查询集群列表 - ListClusters
#### 功能介绍
查询集群列表接口。
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-dataartsstudio/making_request.html)。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-dataartsstudio/abcd.html)。
- 如果使用身份策略授权，当前API调用无需身份策略权限。
 
#### URI
GET /v1.1/{project_id}/clusters
表1路径参数 
| 参数         | 是否必选 | 参数类型   | 描述                                                                                                    |
|:---|:---|:---|:---|
| project_id | 是    | String | 项目ID，获取方法请参见[项目ID和账号ID](https://support.huaweicloud.com/api-dataartsstudio/projectid_accountid.html)。 |
   
#### 请求参数
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                                                       |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | 用户Token，使用[Token认证](https://support.huaweicloud.com/api-dataartsstudio/dataartsstudio_02_0010.html)时必选。通过调用IAM服务的"获取用户Token"接口获取响应消息头中X-Subject-Token的值。 |
   
#### 响应参数
**状态码：200**
表3响应Body参数 
| 参数       | 参数类型                                                          | 描述    |
|:---|:---|:---|
| clusters | Array of [clusters] objects | 集群列表。 |
   
 表4clusters 
| 参数                   | 参数类型                                                                                    | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
|:---|:---|:---|
| customerConfig       | [CustomerConfig] object                         | 用户配置信息。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| datastore            | [Datastore] object                                   | cdm信息。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| instances            | Array of [ClusterDetailInstance] objects | 集群的节点信息。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| 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：正常。   - ReadOnly：只读。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| id                   | String                                                                                  | 集群ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| isFrozen             | String                                                                                  | 集群是否冻结： - 0：否。   - 1：是。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| updated              | String                                                                                  | 集群更新时间，格式为ISO8601：YYYY-MM-DDThh:mm:ssZ。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| status               | String                                                                                  | 集群状态： - 100：创建中。   - 200：正常。   - 300：失败。   - 303：创建失败。   - 500：重启中。   - 800：冻结。   - 900：已关机。   - 910：正在关机。   - 920：正在开机。    |
| failedReasons        | [FailedReasons] object                           | 失败原因。集群处于正常状态时不返回。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
   
 表5CustomerConfig 
| 参数              | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
|:---|:---|:---|
| failureRemind   | String | 失败提醒。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| clusterName     | String | 集群类型。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| serviceProvider | String | 服务提供。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| localDisk       | String | 是否本地磁盘。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ssl             | String | 是否使用ssl。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| createFrom      | String | 创建来源。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| resourceId      | String | 资源ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| flavorType      | String | 规格类型，常见规格类型如下： - cdm.large：8核CPU、16G内存。   - cdm.xlarge：16核CPU、32G内存。   - cdm.4xlarge：64核CPU、128G内存。    |
| workSpaceId     | String | 工作空间ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| trial           | String | 是否是试用集群： - true：是试用集群。   - false：不是试用集群。                                                                                                                                                                                 |
   
 表6Datastore 
| 参数      | 参数类型   | 描述                 |
|:---|:---|:---|
| type    | String | 类型，一般为cdm。         |
| version | String | 集群版本。如"2.9.3.300"。 |
   
 表7ClusterDetailInstance 
| 参数            | 参数类型                                                                  | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|:---|:---|:---|
| flavor        | [flavor] object                       | 节点的虚拟机规格（查询集群列表时返回值为null）。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| volume        | [volume] object                       | 节点的磁盘信息（查询集群列表时返回值为null）。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| status        | String                                                                | 节点状态： - 100：创建中。   - 200：正常。   - 300：失败。   - 303：创建失败。   - 400：已删除。   - 800：冻结。    |
| actions       | Array of strings                                                      | 节点操作状态列表： - REBOOTING：重启中。   - RESTORING：恢复中。   - REBOOT_FAILURE：重启失败。                                                                                                                                                                                                                                                                                                                                                                   |
| type          | String                                                                | 节点类型，只支持一种类型"cdm"。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| id            | String                                                                | 节点的虚拟机ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| name          | String                                                                | 节点的虚拟机名称。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| isFrozen      | String                                                                | 节点是否冻结： - 0：否。   - 1：是。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| components    | String                                                                | 集群组件列表。已废弃，该字段固定为空值。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| config_status | String                                                                | 节点配置状态（查询集群列表时为null）： - In-Sync：配置已同步。   - Applying：配置中。   - Sync-Failure：配置失败。                                                                                                                                                                                                                                                                                                                                                          |
| 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）。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
   
 表8flavor 
| 参数    | 参数类型                                                                  | 描述          |
|:---|:---|:---|
| id    | String                                                                | 节点虚拟机的规格ID。 |
| links | Array of [ClusterLinks] objects | 链接信息。       |
   
 表9volume 
| 参数   | 参数类型   | 描述                                  |
|:---|:---|:---|
| type | String | 节点的磁盘类型，只支持本地磁盘，实际返回为空值或LOCAL_DISK。 |
| size | Long   | 节点磁盘大小，单位G。                         |
   
 表10ClusterLinks 
| 参数   | 参数类型   | 描述    |
|:---|:---|:---|
| rel  | String | 关系。   |
| href | String | 链接地址。 |
   
 表11Resource 
| 参数            | 参数类型   | 描述                 |
|:---|:---|:---|
| resource_id   | String | 资源ID。              |
| resource_type | String | 资源类型。当前为固定值server。 |
   
 表12ClusterTask 
| 参数          | 参数类型   | 描述    |
|:---|:---|:---|
| description | String | 任务描述。 |
| id          | String | 任务ID。 |
| name        | String | 任务名称。 |
   
 表13ActionProgress 
| 参数           | 参数类型   | 描述             |
|:---|:---|:---|
| CREATING     | String | 创建集群进度，例如：29%。 |
| GROWING      | String | 扩容集群进度，例如：29%。 |
| RESTORING    | String | 恢复集群进度，例如：29%。 |
| SNAPSHOTTING | String | 集群快照进度，例如：29%。 |
| REPAIRING    | String | 修复集群进度，例如：29%。 |
   
 表14FailedReasons 
| 参数            | 参数类型                                                          | 描述        |
|:---|:---|:---|
| CREATE_FAILED | [CREATE_FAILED] object | 集群创建失败原因。 |
   
 表15CREATE_FAILED 
| 参数        | 参数类型   | 描述    |
|:---|:---|:---|
| errorCode | String | 错误码。  |
| errorMsg  | String | 失败原因。 |
   
#### 请求示例
```
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代码示例如下。
- [Java]
  ```
  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());
          }
      }
  }
  ```
- [Python]
  ```
  # coding: utf-8
  import os
  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 = os.environ["CLOUD_SDK_AK"]
      sk = os.environ["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)
  ```
- [Go]
  ```
  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, err := basic.NewCredentialsBuilder().
          WithAk(ak).
          WithSk(sk).
          WithProjectId(projectId).
          SafeBuild()
      if err != nil {
          fmt.Println(err)
          return
      }
      hcClient, err := cdm.CdmClientBuilder().
           WithRegion(region.ValueOf("<YOUR REGION>")).
           WithCredential(auth).
           SafeBuild()
      if err != nil {
          fmt.Println(err)
          return
      }
      client := cdm.NewCdmClient(hcClient)
      request := &model.ListClustersRequest{}
  response, err := client.ListClusters(request)
  if err == nil {
          fmt.Printf("%+v\n", response)
      } else {
          fmt.Println(err)
      }
  }
  ```
- [更多]
  更多编程语言的SDK代码示例，请参见[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/CDM/sdk?api=ListClusters)的代码示例页签，可生成自动对应的SDK代码示例。
#### 状态码
| 状态码 | 描述                    |
|:---|:---|
| 200 | OK。                   |
| 400 | 请求错误。                 |
| 401 | 鉴权失败。                 |
| 403 | 没有操作权限。               |
| 404 | 找不到资源。                |
| 500 | 服务内部错误，具体返回错误码请参考错误码。 |
| 503 | 服务不可用。                |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-dataartsstudio/ErrorCode.html)。
