查询实例列表
功能介绍
根据指定条件查询实例列表。
调用方法
请参见如何调用API。
URI
GET /v3.1/{project_id}/instances
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
参数解释: 租户在某一Region下的project ID。 获取方法请参见获取项目ID。 约束限制: 不涉及。 取值范围: 只能由英文字母、数字组成,且长度为32个字符。 默认取值: 不涉及。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
id |
否 |
String |
参数解释: 实例ID。 约束限制: “*”为系统保留字符,如果id是以“*”起始,表示按照“*”后面的值模糊匹配,否则,按照id精确匹配查询。不能只传入“*”。 取值范围: 不涉及。 默认取值: 不涉及。 |
name |
否 |
String |
参数解释: 实例名称。 约束限制: “*”为系统保留字符,如果name是以“*”起始,表示按照“*”后面的值模糊匹配,否则,按照name精确匹配查询。不能只传入“*”。 取值范围: 不涉及。 默认取值: 不涉及。 |
type |
否 |
String |
参数解释: 按照实例类型查询。 约束限制: 当前仅支持Cluster。 取值范围: Cluster:集群版。 默认取值: Cluster。 |
datastore_type |
否 |
String |
参数解释: 数据库类型。 约束限制: 现在只支持gaussdb-mysql。 取值范围: gaussdb-mysql。 默认取值: gaussdb-mysql。 |
vpc_id |
否 |
String |
参数解释: 虚拟私有云ID。获取方法如下:
约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
subnet_id |
否 |
String |
参数解释: 子网的网络ID,获取方法如下:
约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
private_ip |
否 |
String |
参数解释: 读写内网IP地址。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
readonly_private_ip |
否 |
String |
参数解释: 读内网IP地址。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
proxy_ip |
否 |
String |
参数解释: 读写分离IP地址。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
offset |
否 |
Integer |
参数解释: 索引位置,偏移量。从第一条数据偏移offset条数据后开始查询。 约束限制: 必须为整数,不能为负数。 取值范围: ≥0 默认取值: 0 |
limit |
否 |
Integer |
参数解释: 查询记录数。 约束限制: 必须为整数,不能为负数。 取值范围: 1-100 默认取值: 100 |
tags |
否 |
String |
参数解释: 根据实例标签键值对进行查询。
约束限制: 如果同时使用多个标签键值对进行查询,中间使用逗号分隔开,表示查询同时包含指定标签键值对的实例。key不能重复,key之间是与的关系。 取值范围: 不涉及。 默认取值: 不涉及。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
参数解释: 用户Token。 通过调用IAM服务获取用户Token接口获取。 请求响应成功后在响应消息头中包含的“X-Subject-Token”的值即为Token值。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
X-Language |
否 |
String |
参数解释: 请求语言类型。 约束限制: 不涉及。 取值范围:
默认取值: en-us |
响应参数
状态码:200
参数 |
参数类型 |
描述 |
---|---|---|
instances |
Array of MysqlInstanceListInfoUnifyStatus objects |
参数解释: 实例列表信息。 |
total_count |
Integer |
参数解释: 总记录数。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
id |
String |
参数解释: 实例ID。 取值范围: 只能由英文字母、数字组成,后缀为in07,长度为36个字符。 |
name |
String |
参数解释: 创建的实例名称。 取值范围: 不涉及。 |
status |
String |
参数解释: 实例状态。 取值范围:
|
private_ips |
Array of strings |
参数解释: 实例写内网IP地址列表。弹性云服务器创建成功后该值存在,其他情况下为空列表。 取值范围: 不涉及。 |
proxy_ips |
Array of strings |
参数解释: 实例读写分离IP地址列表。TaurusDB实例开启代理成功后该值存在,其他情况下为空列表。 取值范围: 不涉及。 |
readonly_private_ips |
Array of strings |
参数解释: 实例读内网IP地址列表。弹性云服务器创建成功后该值存在,其他情况下为空列表。 取值范围: 不涉及。 |
public_ips |
Array of strings |
参数解释: 实例外网IP地址列表。 取值范围: 不涉及。 |
port |
String |
参数解释: 数据库端口号。 取值范围: 1024-65535,不包含端口5342-5345、12017、20000、20201、20202、33062、33071。 |
type |
String |
参数解释: 实例类型。 取值范围: Cluster:集群版。 |
region |
String |
参数解释: 实例所在区域。 取值范围: 不涉及。 |
datastore |
参数解释: 数据库信息。 |
|
created |
String |
参数解释: 创建时间,格式为"yyyy-mm-ddThh:mm:ssZ"。 其中,T指某个时间的开始;Z指时区偏移量,例如偏移1个小时显示为+0100。 取值范围: 不涉及。 |
updated |
String |
参数解释: 更新时间,格式为"yyyy-mm-ddThh:mm:ssZ"。 其中,T指某个时间的开始;Z指时区偏移量,例如偏移1个小时显示为+0100。 取值范围: 不涉及。 |
db_user_name |
String |
参数解释: 默认用户名。 取值范围: 不涉及。 |
vpc_id |
String |
参数解释: 虚拟私有云ID。 取值范围: 不涉及。 |
subnet_id |
String |
参数解释: 子网的网络ID信息。 取值范围: 不涉及。 |
security_group_id |
String |
参数解释: 安全组ID。 取值范围: 不涉及。 |
flavor_ref |
String |
参数解释: 规格码。 取值范围: 不涉及。 |
flavor_info |
MysqlFlavorInfo object |
参数解释: flavor规格信息。 取值范围: 不涉及。 |
volume |
MysqlVolumeInfo object |
参数解释: 存储盘信息。 |
backup_strategy |
MysqlBackupStrategy object |
参数解释: 自动备份策略。 约束限制: 不涉及。 |
enterprise_project_id |
String |
参数解释: 企业项目ID。 取值范围: 不涉及。 |
time_zone |
String |
参数解释: 时区。 取值范围: 不涉及。 |
charge_info |
MysqlChargeInfo object |
参数解释: 计费类型信息,支持包年包月和按需计费,默认为按需计费。 |
dedicated_resource_id |
String |
参数解释: 专属资源池ID,只有数据库实例属于专属资源池才会返回该参数。 取值范围: 不涉及。 |
tags |
Array of InstanceTagItem objects |
参数解释: 标签列表。 |
参数 |
参数类型 |
描述 |
---|---|---|
type |
String |
参数解释: 数据库引擎。 取值范围: gaussdb-mysql。 |
version |
String |
参数解释: 数据库版本。 取值范围: 不涉及。 |
kernel_version |
String |
参数解释: 数据库内核版本。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
vcpus |
String |
参数解释: CPU核数。 取值范围: 不涉及。 |
ram |
String |
参数解释: 内存大小,单位GB。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
type |
String |
参数解释: 磁盘类型。 取值范围: 不涉及。 |
size |
String |
参数解释: 已使用磁盘大小,单位GB。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
start_time |
String |
参数解释: 自动备份开始时间段。自动备份将在该时间一个小时内触发。 约束限制: 不涉及。 取值范围: 非空,格式必须为hh:mm-HH:MM且有效,当前时间指UTC时间。
默认取值: 不涉及。 |
keep_days |
String |
参数解释: 自动备份保留天数。 约束限制: 值为正整数。 取值范围: 1-732。 默认取值: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
charge_mode |
String |
参数解释: 计费模式。 约束限制: 不涉及。 取值范围:
默认取值: postPaid。 |
period_type |
String |
参数解释: 包周期付费模式下的订购周期类型。 约束限制: charge_mode为prePaid时生效,且为必选值。 取值范围:
默认取值: 不涉及。 |
period_num |
Integer |
参数解释: 包周期付费模式下的订购时间。 约束限制: charge_mode为prePaid时生效,且为必选值。 取值范围:
默认取值: 不涉及。 |
is_auto_renew |
String |
参数解释: 创建包年/包月实例时可指定,表示是否自动续订,续订的周期和原周期相同,且续订时会自动支付。 约束限制: charge_mode为prePaid时生效。 取值范围:
默认取值: false。 |
is_auto_pay |
String |
参数解释: 创建包年/包月实例时可指定,表示是否自动从客户的账户中支付,此字段不影响自动续订的支付方式。 约束限制: charge_mode为prePaid时生效。 取值范围:
默认取值: true。 |
状态码:400
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码。 |
error_msg |
String |
错误消息。 |
状态码:500
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码。 |
error_msg |
String |
错误消息。 |
请求示例
查询TaurusDB实例列表,读写内网IP地址是192.168.0.142。
GET https://{endpoint}/v3.1/054e292c9880d4992f02c0196d3ea468/instances?id=61a4ea66210545909d74a05c27a7179ein07&name=gaussdb-mysql-instance01&type=Cluster&datastore_type=gaussdb-mysql&vpc_id=3cedfc54-b105-4652-a4e0-847b11576b58&subnet_id=c1cfa53c-65d3-431e-8552-326bf310c7ad&private_ip=192.168.0.142&offset=0&limit=10&tags=taurusKey1=value1
响应示例
状态码:200
Success.
{ "total_count" : 1, "instances" : [ { "id" : "61a4ea66210545909d74a05c27a7179ein07", "name" : "gaussdb-mysql-instance01", "status" : "normal", "port" : 3306, "type" : "Cluster", "private_ips" : [ "192.168.0.142" ], "readonly_private_ips" : [ "192.168.0.228", "192.168.0.165" ], "proxy_ips" : [ "192.168.0.15" ], "db_user_name" : "root", "region" : "cn-north-4", "datastore" : { "type" : "gaussdb-mysql", "version" : "8.0", "kernel_version" : "2.0.29.1" }, "created" : "2018-08-20T02:33:49_0800", "updated" : "2018-08-20T02:33:49_0800", "volume" : { "type" : "POOL", "size" : 100 }, "vpc_id" : "3cedfc54-b105-4652-a4e0-847b11576b58", "subnet_id" : "c1cfa53c-65d3-431e-8552-326bf310c7ad", "security_group_id" : "fc577a1a-f202-424a-977f-24faec3fdd55", "flavor_ref" : "gaussdb.mysql.c3.small.4", "flavor_info" : { "vcpus" : 8, "ram" : 16 }, "backup_strategy" : { "start_time" : "19:00-20:00", "keep_days" : 7 }, "charge_info" : { "charge_mode" : "postPaid" }, "enterprise_project_id" : 0, "time_zone" : "UTC", "tags" : [ { "key" : "taurusKey1", "value" : "value1" } ] } ] }
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 ListGaussMySqlInstancesUnifyStatusSolution { 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(); ListGaussMySqlInstancesUnifyStatusRequest request = new ListGaussMySqlInstancesUnifyStatusRequest(); try { ListGaussMySqlInstancesUnifyStatusResponse response = client.listGaussMySqlInstancesUnifyStatus(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 = ListGaussMySqlInstancesUnifyStatusRequest() response = client.list_gauss_my_sql_instances_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.ListGaussMySqlInstancesUnifyStatusRequest{} response, err := client.ListGaussMySqlInstancesUnifyStatus(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. |
错误码
请参见错误码。