Help Center/ MapReduce Service/ API Reference/ API V1.1/ Cluster Management APIs/ Querying a Cluster List - ListClusters
Updated on 2026-09-15 GMT+08:00

Querying a Cluster List - ListClusters

Function

This API is used to view the list information of MRS clusters created by the current user. It supports filtering and paginated queries by conditions such as cluster name, status, tags, and enterprise projects. This API is incompatible with Sahara.

Constraints

None

Debugging

You can debug this API in API Explorer. Automatic authentication is supported. API Explorer can automatically generate sample SDK code and supports sample SDK code debugging.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, no identity policy-based permissions are required for calling this API.

URI

  • Format

    GET /v1.1/{project_id}/cluster_infos

  • Parameter description
    Table 1 URI parameters

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Definition

    Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

    Constraints

    N/A

    Range

    The value must consist of 1 to 64 characters. Only letters and digits are allowed.

    Default Value

    N/A

    Table 2 Query parameters

    Parameter

    Mandatory

    Type

    Description

    pageSize

    No

    String

    Definition

    Maximum number of clusters displayed on a page

    Constraints

    N/A

    Range

    1-2147483646

    Default Value

    10

    currentPage

    No

    String

    Definition

    Current page number

    Constraints

    N/A

    Range

    N/A

    Default Value

    1

    clusterName

    No

    String

    Definition

    Cluster name.

    Constraints

    N/A

    Range

    N/A

    Default Value

    N/A

    clusterState

    No

    String

    Definition

    Query clusters by status.

    Constraints

    N/A

    Range

    • existing: Query existing clusters, including all clusters except those in the Deleted state and the yearly/monthly clusters in the Order processing or Preparing state.
    • history: Query historical clusters, including all the deleted clusters, clusters that fail to delete, clusters whose VMs fail to delete, and clusters whose database updates fail to delete.
    • starting: Query a list of clusters that are being started.
    • running: Query a list of running clusters.
    • terminated: Query a list of terminated clusters.
    • failed: Query a list of failed clusters.
    • abnormal: Query a list of abnormal clusters.
    • terminating: Query a list of clusters that are being terminated.
    • frozen: Query a list of frozen clusters.
    • scaling-out: Query a list of clusters that are being scaled out.
    • scaling-in: Query a list of clusters that are being scaled in.

    Default Value

    N/A

    tags

    No

    String

    Definition

    Tag list. You can search for a cluster by its tag. If you specify multiple tags, the relationship between them is AND.

    Constraints

    N/A

    Range

    • The format of the tags parameter is tags=k1*v1,k2*v2,k3*v3.
    • When the values of some tags are null, the format is tags=k1,k2,k3*v3.
    • The tag key and value can contain letters, digits, spaces, and the special characters (_.:=+-@). However, they must not start or end with a space, must not start with _sys_, and the length must be 1 to 128 characters.

    Default Value

    N/A

    enterpriseProjectId

    No

    String

    Definition

    The enterprise project ID used to query clusters in a specified enterprise project. To obtain the enterprise project ID, check the id value in the enterprise_project field data structure table in "Querying the Enterprise Project List" in Enterprise Management API Reference.

    Constraints

    N/A

    Range

    N/A

    Default Value

    0

Request Parameters

None

Response Parameters

Table 3 Response parameters

Parameter

Type

Description

clusterTotal

Integer

Definition

Total number of clusters in a list

Range

N/A

clusters

Array of Cluster objects

Definition

Cluster parameters. For details, see Table 4.

Range

N/A

Table 4 clusters parameters

Parameter

Type

Description

clusterId

String

Definition

Cluster ID.

Range

N/A

clusterName

String

Definition

Cluster name.

Range

N/A

masterNodeNum

String

Definition

Number of Master nodes deployed in a cluster.

Range

N/A

coreNodeNum

String

Definition

Number of Core nodes deployed in a cluster.

Range

N/A

totalNodeNum

String

Definition

Total number of nodes deployed in a cluster.

Range

N/A

clusterState

String

Definition

Cluster status. (The status is in English by default. When the X-Language request header is set to zh-cn, this field returns Chinese text.)

Range
  • starting: The cluster is being started.
  • running: The cluster is running.
  • terminated: The cluster has been terminated.
  • failed: The cluster fails.
  • abnormal: The cluster is abnormal.
  • terminating: The cluster is being terminated.
  • frozen: The cluster has been frozen.
  • scaling-out: The cluster is being scaled out.
  • scaling-in: The cluster is being scaled in.

createAt

String

Definition

Cluster creation time, which is a 10-bit timestamp.

Range

N/A

updateAt

String

Definition

Cluster update time, which is a 10-bit timestamp.

Range

N/A

billingType

String

Definition

Cluster billing mode.

Range

  • Yearly/Monthly: Yearly/monthly billing
  • Metered: Pay-per-use billing

dataCenter

String

Definition

Cluster work region.

Range

N/A

vpc

String

Definition

VPC name.

Range

N/A

vpcId

String

Definition

VPC ID.

Range

N/A

duration

String

Definition

Required duration of a yearly/monthly cluster, for example, one month.

Range

N/A

fee

String

Definition

Cluster creation fee, which is automatically calculated.

Range

N/A

hadoopVersion

String

Definition

Hadoop version

Range

N/A

masterNodeSize

String

Definition

Instance specifications of a Master node.

Range

N/A

coreNodeSize

String

Definition

Instance specifications of a Core node.

Range

N/A

componentList

Array

Definition

Component list. For details, see Table 5.

Range

N/A

externalIp

String

Definition

External IP address. This IP address is opened to the outside of the cluster as access to the active Master process.

Range

N/A

externalAlternateIp

String

Definition

Backup external IP address. This IP address is used outside the cluster as access to the standby Master process.

Range

N/A

internalIp

String

Definition

Internal IP address. This IP address is used within the cluster as access to Master processes.

Range

N/A

deploymentId

String

Definition

Cluster deployment ID. The ID is used by cloud services to query details about cluster deployment tasks.

Range

N/A

remark

String

Definition

Cluster remarks. By default, this parameter is left blank.

Range

N/A

orderId

String

Definition

Cluster creation order ID.

Range

N/A

azId

String

Definition

AZ ID.

Range

N/A

masterNodeProductId

String

Definition

Product ID of a Master node.

Range

N/A

masterNodeSpecId

String

Definition

Specification ID of a Master node.

Range

N/A

coreNodeProductId

String

Definition

Product ID of a Core node.

Range

N/A

coreNodeSpecId

String

Definition

Specification ID of a Core node

Range

N/A

azName

String

Definition

AZ name.

Range

N/A

azCode

String

Definition

AZ name (en).

Range

N/A

availabilityZoneId

String

Definition

Availability zone.

Range

N/A

instanceId

String

Definition

Instance ID.

Range

N/A

vnc

String

Definition

URI for remotely logging in to an ECS.

Range

N/A

tenantId

String

Definition

Project ID.

Range

N/A

volumeSize

Integer

Definition

Disk storage space.

Range

N/A

volumeType

String

Definition

Disk type.

Range

  • SATA: common I/O
  • SAS: high I/O
  • SSD: ultra-high I/O

subnetId

String

Definition

Subnet ID.

Range

N/A

enterpriseProjectId

String

Definition

Enterprise project ID.

Range

N/A

clusterType

Integer

Definition

Cluster type.

Range

  • 0: analysis cluster
  • 1: streaming cluster
  • 2: hybrid cluster
  • 3: custom cluster
  • 4: Offline cluster

subnetName

String

Definition

Subnet name.

Range

N/A

securityGroupsId

String

Definition

Security group ID.

Range

N/A

slaveSecurityGroupsId

String

Definition

Security group ID of a non-master node. Currently, one MRS cluster uses only one security group. Therefore, this field has been discarded. This field returns the same value as securityGroupsId does for compatibility consideration.

Range

N/A

bootstrapScripts

Array of BootstrapScript objects

Definition

Bootstrap action script. For details, see Table 6.

Range

N/A

stageDesc

String

Definition

Cluster process. (The status is in English by default. When the X-Language request header is set to zh-cn, this field returns Chinese text.)

Range

The cluster installation progress includes:
  • Verifying cluster parameters: Cluster parameters are being verified.
  • Applying for cluster resources: Cluster resources are being applied for.
  • Creating VMs: The VMs are being created.
  • Initializing VMs: The VMs are being initialized.
  • Installing MRS Manager: MRS Manager is being installed.
  • Deploying the cluster: The cluster is being deployed.
  • Cluster installation failed: Failed to install the cluster.
The cluster scale-out progress includes:
  • Preparing for scale-out: Cluster scale-out is being prepared.
  • Creating VMs: The VMs are being created.
  • Initializing VMs: The VMs are being initialized.
  • Adding nodes to the cluster: The nodes are being added to the cluster.
  • Scale-out failed: Failed to scale out the cluster.
The cluster scale-in progress includes:
  • Preparing for scale-in: Cluster scale-in is being prepared.
  • Decommissioning instance: The instance is being decommissioned.
  • Deleting VMs: The VMs are being deleted.
  • Deleting nodes from the cluster: The nodes are being deleted from the cluster.
  • Scale-in failed: Failed to scale in the cluster.

If the cluster installation, scale-out, or scale-in fails, stageDesc will display the failure cause.

isMrsManagerFinish

Boolean

Definition

Whether MRS Manager installation is finished during cluster creation.

Range

  • true: MRS Manager installation is finished.
  • false: MRS Manager installation is not finished.

safeMode

Integer

Definition

Run mode of an MRS cluster.

Range

  • 0: Normal cluster
  • 1: Security cluster

clusterVersion

String

Definition

Cluster version.

Range

N/A

nodePublicCertName

String

Definition

Name of the key file.

Range

N/A

masterNodeIp

String

Definition

IP address of a Master node.

Range

N/A

privateIpFirst

String

Definition

Preferred private IP address.

Range

N/A

errorInfo

String

Definition

Error message.

Range

N/A

tags

String

Definition

Tag information.

Range

N/A

chargingStartTime

String

Definition

Billing start time, which is a 10-digit timestamp.

Range

N/A

logCollection

Integer

Definition

Whether to collect logs when cluster installation fails.

Range

  • 0: Do not collect logs.
  • 1: Collect logs.

taskNodeGroups

List<NodeGroup>

Definition

List of Task nodes. For more parameter description, see Table 7.

Range

N/A

nodeGroups

List<NodeGroup>

Definition

List of Master, Core and Task nodes. For more parameter description, see Table 7.

Range

N/A

masterDataVolumeType

String

Definition

Data disk storage type of the Master node. Currently, SATA, SAS, and SSD are supported.

Range

  • SATA: common I/O
  • SAS: high I/O
  • SSD: ultra-high I/O

masterDataVolumeSize

Integer

Definition

Data disk storage space of Master nodes, in GB To increase data storage capacity, you can add disks at the same time when creating a cluster.

Range

100-32000

masterDataVolumeCount

Integer

Definition

Number of data disks of the Master node

Range

The value can only be 1.

coreDataVolumeType

String

Definition

Data disk storage type of the Core node. Currently, SATA, SAS, and SSD are supported.

Range

  • SATA: common I/O
  • SAS: high I/O
  • SSD: ultra-high I/O

coreDataVolumeSize

Integer

Definition

Data disk storage space of Core nodes, in GB To increase data storage capacity, you can add disks at the same time when creating a cluster.

Range

100-32000

coreDataVolumeCount

Integer

Definition

Number of data disks of the Core node.

Range

1-10

periodType

Integer

Definition

Whether the subscription type is yearly or monthly.

Range

  • 0: monthly subscription
  • 1: yearly subscription

scale

String

Definition

Status of node changes If this parameter is left blank, no change operation has been performed on a cluster node. (The status is in English by default. When the X-Language request header is set to zh-cn, this field returns Chinese text.)

Range

  • Scaling-out: The cluster is being scaled out.
  • Scaling-in: The cluster is being scaled in.
  • scaling-error: The cluster is in the running state and fails to be scaled in or out or the specifications fail to be scaled up for the last time.
  • scaling-up: The master node specifications are being scaled up.
  • scaling_up_first: The standby master node specifications are being scaled up.
  • scaled_up_first: The standby master node specifications have been scaled up.
  • scaled-up-success: The master node specifications have been scaled up.

eipId

String

Definition

Unique ID of the cluster EIP

Range

N/A

eipAddress

String

Definition

IPv4 address of the cluster EIP

Range

N/A

eipv6Address

String

Definition

IPv6 address of the cluster EIP. This parameter is not returned when an IPv4 address is used.

Range

N/A

azCategory

Integer

Definition

Type of the current AZ.

Range

  • 0: AZ on the cloud

  • 21: Local AZ

  • 41: Edge AZ

Table 5 componentAmb

Parameter

Type

Description

componentId

String

Definition

Component ID

Range

For example, the component_id of Hadoop is MRS 3.0.2_001, MRS 2.1.0_001, MRS 1.9.2_001, MRS 1.8.10_001.

componentName

String

Definition

Component name.

Range

N/A

componentVersion

String

Definition

Component version.

Range

N/A

componentDesc

String

Definition

Component description.

Range

N/A

Table 6 bootstrapScripts

Parameter

Type

Description

name

String

Definition

Name of a bootstrap action script.

Range

The names of bootstrap action scripts in the same cluster must be unique. The value can contain 1 to 64 characters, including only digits, letters, spaces, hyphens (-), and underscores (_), and cannot start with a space.

uri

String

Definition

The path of a bootstrap action script. Set this parameter to an OBS bucket path or a local VM path.

  • OBS bucket path: Enter a script path. For example, enter the path of the public sample script provided by MRS. Example: s3a://bootstrap/presto/presto-install.sh. If dualroles is installed, the parameter of the presto-install.sh script is dualroles. If worker is installed, the parameter of the presto-install.sh script is worker. Based on the Presto usage habit, you are advised to install dualroles on the active master nodes and worker on the core nodes.
  • Local VM path: Enter a script path. The script path must start with a slash (/) and end with .sh.

Range

N/A

parameters

String

Definition

The bootstrap action script parameters.

Range

N/A

nodes

Array of strings

Definition

Type of a node where the bootstrap action script is executed. The value can be Master, Core, or Task.

Range

N/A

active_master

Boolean

Definition

Whether the bootstrap action script runs only on active master nodes.

Range

  • true: The bootstrap action script runs only on active Master nodes.
  • false: The bootstrap action script can run on all Master nodes.

fail_action

String

Definition

Whether to continue executing subsequent scripts and creating a cluster after the bootstrap action script fails to execute. You are advised to set this parameter to continue in the commissioning phase so that the cluster can continue to be installed and started no matter whether the bootstrap action is successful.

Range

  • continue: Continue to execute subsequent scripts.
  • errorout: Stop the action.

before_component_start

Boolean

Definition

Time when the bootstrap action script is executed. Currently, the following two options are available: Before component start and After component start.

Range

  • true: The bootstrap action script is executed before the component starts.
  • false: The bootstrap action script is executed after the component starts.

start_time

Long

Definition

Execution time for a single bootstrap action script. The value is a Unix timestamp in seconds.

Range

N/A

state

String

Definition

The running status of one bootstrap action script.

Range

  • PENDING: The script is suspended.
  • IN_PROGRESS: The script is being processed.
  • SUCCESS
  • FAILURE: The script fails to be executed.

action_stages

Array of strings

Definition

Select the time when the bootstrap action script is executed.

  • BEFORE_COMPONENT_FIRST_START: before initial component starts
  • AFTER_COMPONENT_FIRST_START: after initial component starts
  • BEFORE_SCALE_IN: before scale-in
  • AFTER_SCALE_IN: after scale-in
  • BEFORE_SCALE_OUT: before scale-out
  • AFTER_SCALE_OUT: after scale-out

Range

N/A

Table 7 NodeGroupV10

Parameter

Type

Description

GroupName

String

Definition

Node group name.

Range

N/A

NodeNum

Integer

Definition

Number of nodes. The value ranges from 0 to 500. The minimum number of Master and Core nodes is 1 and the total number of Core and Task nodes cannot exceed 500.

Range

0-500

NodeSize

String

Definition

Instance specifications of a node.

Range

N/A

NodeSpecId

String

Definition

Instance specification ID of a node.

Range

N/A

NodeProductId

String

Definition

Instance product ID of a node.

Range

N/A

VmProductId

String

Definition

VM specifications of a node.

Range

N/A

VmSpecCode

String

Definition

VM specifications of a node.

Range

N/A

RootVolumeSize

Integer

Definition

System disk size of a node. This parameter is not configurable and its default value is 40 GB.

Range

N/A

RootVolumeProductId

String

Definition

System disk product ID of a node.

Range

N/A

RootVolumeType

String

Definition

System disk type of a node.

Range

  • SATA: common I/O
  • SAS: high I/O
  • SSD: ultra-high I/O

RootVolumeResourceSpecCode

String

Definition

System disk product specifications of a node.

Range

N/A

RootVolumeResourceType

String

Definition

System disk product type of a node.

Range

N/A

DataVolumeType

String

Definition

Data disk storage type of a node. Currently, SATA, SAS, and SSD are supported.

Range

  • SATA: common I/O
  • SAS: high I/O
  • SSD: ultra-high I/O

DataVolumeCount

Integer

Definition

Number of data disks of a node.

Range

N/A

DataVolumeSize

Integer

Definition

Data disk storage size of a node, in GB.

Range

N/A

DataVolumeProductId

String

Definition

Data disk product ID of a node.

Range

N/A

DataVolumeResourceSpecCode

String

Definition

Data disk specifications of a node.

Range

N/A

DataVolumeResourceType

String

Definition

Data disk type of a node.

Range

N/A

Example Request

GET /v1.1/{project_id}/cluster_infos?pageSize={page_size}&currentPage={current_page}&clusterState={cluster_state}&tags={tags}

Example Response

Status code: 200

Querying the cluster list is successful.

{
  "clusterTotal" : "1",
  "clusters" : [ {
    "clusterId" : "bc134369-294c-42b7-a707-b2036ba38524",
    "clusterName" : "mrs_D0zW",
    "masterNodeNum" : "2",
    "coreNodeNum" : "3",
    "clusterState" : "terminated",
    "createAt" : "1498272043",
    "updateAt" : "1498636753",
    "chargingStartTime" : "1498273733",
    "logCollection" : "1",
    "billingType" : "Metered",
    "dataCenter" : "cn-hk1",
    "vpc" : null,
    "duration" : "0",
    "fee" : null,
    "hadoopVersion" : null,
    "masterNodeSize" : null,
    "coreNodeSize" : null,
    "componentList" : [ {
      "componentId" : "MRS 3.1.0_001",
      "componentName" : "Hadoop",
      "componentVersion" : "3.1.1",
      "componentDesc" : "A framework that allows for the distributed processing of large data sets across clusters."
    }, {
      "componentId" : "MRS 3.1.0_003",
      "componentName" : "HBase",
      "componentVersion" : "2.1.1",
      "componentDesc" : "A scalable, distributed database that supports structured data storage for large tables."
    }, {
      "componentId" : "MRS 3.1.0_002",
      "componentName" : "Spark",
      "componentVersion" : "2.3.2",
      "componentDesc" : "A fast and general engine for large-scale data processing."
    }, {
      "componentId" : "MRS 3.1.0_004",
      "componentName" : "Hive",
      "componentVersion" : "3.1.0",
      "componentDesc" : "A data warehouse infrastructure that provides data summarization and ad hoc querying."
    } ],
    "externalIp" : null,
    "externalAlternateIp" : null,
    "internalIp" : null,
    "deploymentId" : null,
    "remark" : "",
    "orderId" : null,
    "azId" : null,
    "azCode" : null,
    "masterNodeProductId" : null,
    "masterNodeSpecId" : null,
    "coreNodeProductId" : null,
    "coreNodeSpecId" : null,
    "azName" : "AZ1",
    "instanceId" : null,
    "vnc" : "v2/5a3314075bfa49b9ae360f4ecd333695/servers/e2cda891-232e-4703-995e-3b1406add01d/action",
    "tenantId" : null,
    "volumeSize" : "0",
    "volumeType" : null,
    "subnetId" : null,
    "subnetName" : null,
    "securityGroupsId" : null,
    "slaveSecurityGroupsId" : null,
    "bootstrapScripts" : [ {
      "name" : "test1-success",
      "uri" : "s3a://bootscript/script/simple/basic_success.sh",
      "parameters" : "",
      "nodes" : [ "master", "core" ],
      "active_master" : true,
      "fail_action" : "errorout",
      "before_component_start" : true,
      "state" : "SUCCESS",
      "start_time" : 1527681083,
      "action_stages" : [ "AFTER_SCALE_IN", "AFTER_SCALE_OUT" ]
    } ],
    "isMrsManagerFinish" : false,
    "stageDesc" : "Installing MRS Manager",
    "safeMode" : "0",
    "clusterVersion" : null,
    "nodePublicCertName" : null,
    "masterNodeIp" : "unknown",
    "privateIpFirst" : null,
    "errorInfo" : "",
    "clusterType" : "0",
    "nodeGroups" : [ {
      "GroupName" : "master_node_default_group",
      "NodeNum" : "1",
      "NodeSize" : "s3.xlarge.2.linux.bigdata",
      "NodeSpecId" : "cdc6035a249a40249312f5ef72a23cd7",
      "VmProductId" : "",
      "VmSpecCode" : null,
      "NodeProductId" : "dc970349d128460e960a0c2b826c427c",
      "RootVolumeSize" : "40",
      "RootVolumeProductId" : "16c1dcf0897249758b1ec276d06e0572",
      "RootVolumeType" : "SATA",
      "RootVolumeResourceSpecCode" : "",
      "RootVolumeResourceType" : "",
      "DataVolumeType" : "SATA",
      "DataVolumeCount" : "1",
      "DataVolumeSize" : "100",
      "DataVolumeProductId" : "16c1dcf0897249758b1ec276d06e0572",
      "DataVolumeResourceSpecCode" : "",
      "DataVolumeResourceType" : ""
    }, {
      "GroupName" : "core_node_analysis_group",
      "NodeNum" : "1",
      "NodeSize" : "s3.xlarge.2.linux.bigdata",
      "NodeSpecId" : "cdc6035a249a40249312f5ef72a23cd7",
      "VmProductId" : "",
      "VmSpecCode" : null,
      "NodeProductId" : "dc970349d128460e960a0c2b826c427c",
      "RootVolumeSize" : "40",
      "RootVolumeProductId" : "16c1dcf0897249758b1ec276d06e0572",
      "RootVolumeType" : "SATA",
      "RootVolumeResourceSpecCode" : "",
      "RootVolumeResourceType" : "",
      "DataVolumeType" : "SATA",
      "DataVolumeCount" : "1",
      "DataVolumeSize" : "100",
      "DataVolumeProductId" : "16c1dcf0897249758b1ec276d06e0572",
      "DataVolumeResourceSpecCode" : "",
      "DataVolumeResourceType" : ""
    }, {
      "GroupName" : "task_node_analysis_group",
      "NodeNum" : "1",
      "NodeSize" : "s3.xlarge.2.linux.bigdata",
      "NodeSpecId" : "cdc6035a249a40249312f5ef72a23cd7",
      "VmProductId" : "",
      "VmSpecCode" : null,
      "NodeProductId" : "dc970349d128460e960a0c2b826c427c",
      "RootVolumeSize" : "40",
      "RootVolumeProductId" : "16c1dcf0897249758b1ec276d06e0572",
      "RootVolumeType" : "SATA",
      "RootVolumeResourceSpecCode" : "",
      "RootVolumeResourceType" : "",
      "DataVolumeType" : "SATA",
      "DataVolumeCount" : "1",
      "DataVolumeSize" : "100",
      "DataVolumeProductId" : "16c1dcf0897249758b1ec276d06e0572",
      "DataVolumeResourceSpecCode" : "",
      "DataVolumeResourceType" : ""
    } ],
    "taskNodeGroups" : [ {
      "GroupName" : "task_node_default_group",
      "NodeNum" : "1",
      "NodeSize" : "s3.xlarge.2.linux.bigdata",
      "NodeSpecId" : "cdc6035a249a40249312f5ef72a23cd7",
      "VmProductId" : "",
      "VmSpecCode" : null,
      "NodeProductId" : "dc970349d128460e960a0c2b826c427c",
      "RootVolumeSize" : "40",
      "RootVolumeProductId" : "16c1dcf0897249758b1ec276d06e0572",
      "RootVolumeType" : "SATA",
      "RootVolumeResourceSpecCode" : "",
      "RootVolumeResourceType" : "",
      "DataVolumeType" : "SATA",
      "DataVolumeCount" : "1",
      "DataVolumeSize" : "100",
      "DataVolumeProductId" : "16c1dcf0897249758b1ec276d06e0572",
      "DataVolumeResourceSpecCode" : "",
      "DataVolumeResourceType" : ""
    } ],
    "masterDataVolumeType" : "SATA",
    "masterDataVolumeSize" : "200",
    "masterDataVolumeCount" : "1",
    "coreDataVolumeType" : "SATA",
    "coreDataVolumeSize" : "100",
    "coreDataVolumeCount" : "1",
    "periodType" : "0"
  } ]
}

SDK Sample Code

The SDK sample code is as follows.

 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.mrs.v1.region.MrsRegion;
import com.huaweicloud.sdk.mrs.v1.*;
import com.huaweicloud.sdk.mrs.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);

        MrsClient client = MrsClient.newBuilder()
                .withCredential(auth)
                .withRegion(MrsRegion.valueOf("<YOUR REGION>"))
                .build();
        ListClustersRequest request = new ListClustersRequest();
        try {
            ListClustersResponse response = client.listClusters(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkmrs.v1.region.mrs_region import MrsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkmrs.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 = MrsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(MrsRegion.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"
    mrs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/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 := mrs.NewMrsClient(
        mrs.MrsClientBuilder().
            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)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Table 8 Status code

Status Code

Description

200

The cluster list information has been queried.

Error Codes

See Error Codes.