更新时间:2025-07-24 GMT+08:00
分享

批量查询实例详情

功能介绍

批量查询实例详情。

调用方法

请参见如何调用API

URI

GET /v3.1/{project_id}/instances/details

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数解释

租户在某一Region下的project ID。

获取方法请参见获取项目ID

约束限制

不涉及。

取值范围

只能由英文字母、数字组成,且长度为32个字符。

默认取值

不涉及。

表2 Query参数

参数

是否必选

参数类型

描述

instance_ids

String

参数解释

实例ID列表。

约束限制

最多20个实例ID。

取值范围

实例ID只能由英文字母、数字组成,后缀为in07,长度为36个字符。

默认取值

不涉及。

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

参数解释

用户Token。 通过调用IAM服务获取用户Token接口获取。

请求响应成功后在响应消息头中包含的“X-Subject-Token”的值即为Token值。

约束限制

不涉及。

取值范围

不涉及。

默认取值

不涉及。

X-Language

String

参数解释

请求语言类型。

约束限制

不涉及。

取值范围

  • en-us

  • zh-cn

默认取值

en-us

响应参数

状态码:200

表4 响应Body参数

参数

参数类型

描述

instances

Array of MysqlInstanceInfoDetailUnifyStatus objects

参数解释

实例详情。

表5 MysqlInstanceInfoDetailUnifyStatus

参数

参数类型

描述

id

String

参数解释

实例ID。

取值范围

只能由英文字母、数字组成,后缀为in07,长度为36个字符。

name

String

参数解释

实例名称。

取值范围

不涉及。

project_id

String

参数解释

租户在某一Region下的project ID。

取值范围

不涉及。

status

String

参数解释

实例状态。

取值范围

  • creating,实例正在创建。

  • normal,实例正常。

  • abnormal,实例异常。

  • createfail,实例创建失败。

port

String

参数解释

数据库端口号。

取值范围

不涉及。

alias

String

参数解释

实例备注。

取值范围

不涉及。

type

String

参数解释

实例类型。

取值范围

Cluster。

charge_info

MysqlInstanceChargeInfo object

参数解释

计费类型信息。

node_count

Integer

参数解释

节点个数。

取值范围

不涉及。

datastore

MysqlDatastoreWithKernelVersion object

参数解释

数据库信息。

backup_used_space

Double

参数解释

备份空间使用大小,单位为GB。

取值范围

不涉及。

created

String

参数解释

创建时间,格式为"yyyy-mm-ddThh:mm:ssZ"。

其中,T指某个时间的开始;Z指时区偏移量,例如偏移1个小时显示为+0100。

取值范围

不涉及。

updated

String

参数解释

更新时间,格式为"yyyy-mm-ddThh:mm:ssZ"。

其中,T指某个时间的开始;Z指时区偏移量,例如偏移1个小时显示为+0100。

取值范围

不涉及。

private_write_ips

Array of strings

参数解释

实例的写内网IP地址。

取值范围

不涉及。

private_dns_names

Array of strings

参数解释

实例内网域名列表。实例创建成功后,需要手动申请内网域名,否则查询内网域名为空。

取值范围

不涉及。

public_ips

String

参数解释

实例的公网IP地址。

取值范围

不涉及。

db_user_name

String

参数解释

默认用户名。

取值范围

不涉及。

vpc_id

String

参数解释

虚拟私有云ID。

取值范围

不涉及。

subnet_id

String

参数解释

子网的网络ID信息。

取值范围

不涉及。

security_group_id

String

参数解释

安全组ID。

取值范围

不涉及。

configuration_id

String

参数解释

实例创建的模板ID,或者应用到实例的最新参数组模板ID。

取值范围

不涉及。

backup_strategy

MysqlBackupStrategy object

参数解释

自动备份策略。

约束限制

不涉及。

nodes

Array of MysqlInstanceNodeInfo objects

参数解释

节点信息。

enterprise_project_id

String

参数解释

企业项目ID。

取值范围

不涉及。

time_zone

String

参数解释

时区。

取值范围

不涉及。

az_mode

String

参数解释

可用区模式。

取值范围

  • single:单可用区。

  • multi:多可用区。

master_az_code

String

参数解释

主可用区。

取值范围

不涉及。

maintenance_window

String

参数解释

可维护时间窗,为UTC时间。

取值范围

不涉及。

tags

Array of MysqlTags objects

参数解释

实例标签。

取值范围

不涉及。

dedicated_resource_id

String

参数解释

专属资源池ID,只有数据库实例属于专属资源池才会返回该参数。

取值范围

不涉及。

proxies

Array of MysqlProxyInfo objects

参数解释

代理信息。

tde_info

MysqlTdeInfo object

参数解释

透明数据加密配置信息,支持AES256、SM4加密算法。

透明加密功能目前处于公测阶段,如需使用,请提交工单联系客服人员申请权限。

表6 MysqlInstanceChargeInfo

参数

参数类型

描述

charge_mode

String

参数解释

计费模式。

取值范围

  • prePaid:预付费,即包年/包月。

  • postPaid:后付费,即按需付费。

order_id

String

参数解释

订单号。仅包年包月返回。

取值范围

不涉及。

表7 MysqlDatastoreWithKernelVersion

参数

参数类型

描述

type

String

参数解释

数据库引擎。

取值范围

gaussdb-mysql。

version

String

参数解释

数据库版本。

取值范围

不涉及。

kernel_version

String

参数解释

数据库内核版本。

取值范围

不涉及。

表8 MysqlBackupStrategy

参数

参数类型

描述

start_time

String

参数解释

自动备份开始时间段。自动备份将在该时间一个小时内触发。

约束限制

不涉及。

取值范围

非空,格式必须为hh:mm-HH:MM且有效,当前时间指UTC时间。

  1. HH取值必须比hh大1。

  2. mm和MM取值必须相同,且取值必须为00。

默认取值

不涉及。

keep_days

String

参数解释

自动备份保留天数。

约束限制

值为正整数。

取值范围

1-732。

默认取值

不涉及。

表9 MysqlInstanceNodeInfo

参数

参数类型

描述

id

String

参数解释

实例ID,严格匹配UUID规则。

取值范围

只能由英文字母、数字组成,后缀为in07,长度为36个字符。

name

String

参数解释

节点名称。

取值范围

不涉及。

type

String

参数解释

节点类型。

取值范围

  • master:主节点。

  • slave:只读节点。

status

String

参数解释

节点状态。

取值范围

不涉及。

port

Integer

参数解释

数据库端口号。

取值范围

不涉及。

private_read_ips

Array of strings

参数解释

节点的读内网地址。

取值范围

不涉及。

volume

MysqlInstanceNodeVolumeInfo object

参数解释

存储盘信息。

取值范围

不涉及。

az_code

String

参数解释

可用区。

取值范围

不涉及。

region_code

String

参数解释

实例所在的区域。

取值范围

不涉及。

created

String

参数解释

创建时间,格式为"yyyy-mm-ddThh:mm:ssZ"。

其中,T指某个时间的开始;Z指时区偏移量,例如偏移1个小时显示为+0100。

取值范围

不涉及。

updated

String

参数解释

更新时间,格式与"created"字段对应格式完全相同。

取值范围

不涉及。

flavor_id

String

参数解释

规格ID。

取值范围

不涉及。

flavor_ref

String

参数解释

规格码。

取值范围

不涉及。

max_connections

String

参数解释

允许的最大连接数。

取值范围

不涉及。

vcpus

String

参数解释

CPU核数。

取值范围

不涉及。

ram

String

参数解释

内存大小,单位为GB。

取值范围

不涉及。

need_restart

Boolean

参数解释

是否需要重启使修改的参数生效。

取值范围

不涉及。

priority

Integer

参数解释

主备倒换优先级。

取值范围

-1或1-16。

表10 MysqlInstanceNodeVolumeInfo

参数

参数类型

描述

type

String

参数解释

磁盘类型。

取值范围

不涉及。

used

String

参数解释

已使用磁盘大小,单位GB。

取值范围

不涉及。

size

Long

参数解释

包年/包月实例购买的存储空间大小,单位GB。

取值范围

不涉及。

表11 MysqlTags

参数

参数类型

描述

key

String

参数解释:

标签键。

约束限制

key不能为空或者空字符串,不能为空格。

取值范围

1-128个unicode字符。字符集:A-Z,a-z ,0-9,‘-’,‘_’,UNICODE字符(\u4E00-\u9FFF)。

默认取值

不涉及。

value

String

参数解释:

标签值。

约束限制

可以为空字符串。

取值范围

0-255个unicode字符。字符集:A-Z,a-z ,0-9,‘-’,‘_’,UNICODE字符(\u4E00-\u9FFF)。

默认取值

不涉及。

表12 MysqlProxyInfo

参数

参数类型

描述

pool_id

String

参数解释

数据库代理ID。

取值范围

不涉及。

name

String

参数解释

数据库代理名称。

取值范围

不涉及。

address

String

参数解释

Proxy读写分离地址。

取值范围

不涉及。

表13 MysqlTdeInfo

参数

参数类型

描述

enable_tde

Boolean

参数解释

是否打开透明加密功能。

约束限制

不涉及。

取值范围

  • true: 打开。

  • false: 关闭。

默认取值

不涉及。

encryption_type

String

参数解释:

透明加密算法。

约束限制

不涉及。

取值范围

  • AES256。

  • SM4。

默认取值

不涉及。

状态码:400

表14 响应Body参数

参数

参数类型

描述

error_code

String

错误码。

error_msg

String

错误消息。

状态码:500

表15 响应Body参数

参数

参数类型

描述

error_code

String

错误码。

error_msg

String

错误消息。

请求示例

批量查询实例信息。

GET https://{endpoint}/v3.1/97b026aa9cc4417888c14c84a1ad9860/instances/details?instance_ids=11684a0e59e94bceba7880d58cfb07b5in07

响应示例

状态码:200

Success.

{
  "instances" : [ {
    "id" : "11684a0e59e94bceba7880d58cfb07b5in07",
    "name" : "gaussdb-mysql-instance01",
    "alias" : "",
    "status" : "normal",
    "project_id" : "3cedfc54-b105-4652-a4e0-847b11576628",
    "enterprise_project_id" : 0,
    "type" : "Cluster",
    "charge_info" : {
      "charge_mode" : "postPaid",
      "order_id" : ""
    },
    "node_count" : 2,
    "datastore" : {
      "type" : "gaussdb-mysql",
      "version" : "8.0",
      "kernel_version" : "2.0.29.1"
    },
    "created" : "2022-07-14T16:26:58+0800",
    "updated" : "2022-07-18T14:20:33+0800",
    "public_ips" : "10.154.219.187",
    "private_write_ips" : [ "192.168.0.142" ],
    "private_dns_names" : [ "11684a0e59e94bceba7880d58cfb07b5in07.internal.cn-xianhz-1.gaussdbformysql.myhuaweicloud.com" ],
    "db_user_name" : "root",
    "port" : 3306,
    "vpc_id" : "3cedfc54-b105-4652-a4e0-847b11576b58",
    "subnet_id" : "c1cfa53c-65d3-431e-8552-326bf310c7ad",
    "security_group_id" : "fc577a1a-f202-424a-977f-24faec3fdd55",
    "backup_strategy" : {
      "start_time" : "19:00-20:00",
      "keep_days" : 7
    },
    "nodes" : [ {
      "id" : "799a0f2fa49a4151bf9f7063c1fbba36no07",
      "name" : "gauss-d616-lb07_node01",
      "type" : "master",
      "status" : "normal",
      "port" : 3306,
      "private_read_ips" : [ "192.168.0.163" ],
      "volume" : {
        "type" : "POOL",
        "used" : 0.07
      },
      "az_code" : "az1xahz",
      "region_code" : "cn-xianhz-1",
      "flavor_id" : "3169caaf-6c2f-41d5-aadd-c8fc3d83597e",
      "flavor_ref" : "gaussdb.mysql.xlarge.arm.4",
      "max_connections" : 1500,
      "vcpus" : 1,
      "ram" : 4,
      "need_restart" : false,
      "priority" : 1,
      "created" : "2022-07-14T16:26:58+0800",
      "updated" : "2022-07-18T09:24:18+0800"
    }, {
      "id" : "799a0f2fa49a4151bf9f7063c1fbba35no07",
      "name" : "gauss-d616-lb07_node02",
      "type" : "slave",
      "status" : "normal",
      "port" : 3306,
      "private_read_ips" : [ "192.168.0.162" ],
      "volume" : {
        "type" : "POOL",
        "used" : 0.07
      },
      "az_code" : "az1xahz",
      "region_code" : "cn-xianhz-1",
      "flavor_id" : "3169caaf-6c2f-41d5-aadd-c8fc3d83597e",
      "flavor_ref" : "gaussdb.mysql.xlarge.arm.4",
      "max_connections" : 1500,
      "vcpus" : 1,
      "ram" : 4,
      "need_restart" : false,
      "priority" : 1,
      "created" : "2022-07-14T16:26:58+0800",
      "updated" : "2022-07-18T09:36:18+0800"
    } ],
    "time_zone" : "UTC+08:00",
    "backup_used_space" : 0.24,
    "az_mode" : "single",
    "master_az_code" : "az1",
    "maintenance_window" : "18:00-22:00",
    "tags" : [ ],
    "configuration_id" : "53570e0de54e40c5a15f331aa5sd2176pr07",
    "dedicated_resource_id" : "",
    "proxies" : [ {
      "pool_id" : "dab1cfc5150c4d1ca0e8c6596bfc0d8cpo01",
      "address" : "192.168.10.76",
      "name" : "proxy-name"
    } ]
  } ]
}

SDK代码示例

SDK代码示例如下。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.gaussdb.v3.region.GaussDBRegion;
import com.huaweicloud.sdk.gaussdb.v3.*;
import com.huaweicloud.sdk.gaussdb.v3.model.*;


public class ListGaussMySqlInstanceDetailInfoUnifyStatusSolution {

    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);

        GaussDBClient client = GaussDBClient.newBuilder()
                .withCredential(auth)
                .withRegion(GaussDBRegion.valueOf("<YOUR REGION>"))
                .build();
        ListGaussMySqlInstanceDetailInfoUnifyStatusRequest request = new ListGaussMySqlInstanceDetailInfoUnifyStatusRequest();
        try {
            ListGaussMySqlInstanceDetailInfoUnifyStatusResponse response = client.listGaussMySqlInstanceDetailInfoUnifyStatus(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 huaweicloudsdkgaussdb.v3.region.gaussdb_region import GaussDBRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkgaussdb.v3 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 = GaussDBClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(GaussDBRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListGaussMySqlInstanceDetailInfoUnifyStatusRequest()
        response = client.list_gauss_my_sql_instance_detail_info_unify_status(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"
    gaussdb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/gaussdb/v3/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 := gaussdb.NewGaussDBClient(
        gaussdb.GaussDBClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ListGaussMySqlInstanceDetailInfoUnifyStatusRequest{}
	response, err := client.ListGaussMySqlInstanceDetailInfoUnifyStatus(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

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

状态码

状态码

描述

200

Success.

400

Client error.

500

Server error.

错误码

请参见错误码

相关文档