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

查询指定实例

功能介绍

查询指定实例的详细信息。

调用方法

请参见如何调用API

URI

GET /v2/{project_id}/instances/{instance_id}

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数解释

项目ID,获取方式请参见获取项目ID

约束限制

不涉及。

取值范围

不涉及。

默认取值

不涉及。

instance_id

String

参数解释

实例ID。获取方法如下:调用“查询所有实例列表”接口,从响应体中获取实例ID。

约束限制

不涉及。

取值范围

不涉及。

默认取值

不涉及。

请求参数

响应参数

状态码:200

表2 响应Body参数

参数

参数类型

描述

name

String

参数解释

实例名称。

取值范围

不涉及。

engine

String

参数解释

引擎。

取值范围

  • kafka

engine_version

String

参数解释

Kafka的版本。

取值范围

  • 1.1.0

  • 2.7

  • 3.x

description

String

参数解释

实例描述。

取值范围

不涉及。

specification

String

参数解释

实例规格。

取值范围

不涉及。

storage_space

Integer

参数解释

消息存储空间,单位:GB。

取值范围

  • Kafka实例规格为c6.2u4g.cluster时,存储空间取值范围300GB ~ 300000GB。

  • Kafka实例规格为c6.4u8g.cluster时,存储空间取值范围300GB ~ 600000GB。

  • Kafka实例规格为c6.8u16g.cluster时,存储空间取值范围300GB ~ 1500000GB。

  • Kafka实例规格为c6.12u24g.cluster时,存储空间取值范围300GB ~ 1500000GB。

  • Kafka实例规格为c6.16u32g.cluster时,存储空间取值范围300GB ~ 1500000GB。

  • Kafka实例规格为kafka.2u4g.cluster.small时,存储空间取值范围300GB~300000GB。

partition_num

String

参数解释

Kafka实例的分区数量。

取值范围

不涉及。

used_storage_space

Integer

参数解释

已使用的消息存储空间,单位:GB。

取值范围

不涉及。

dns_enable

Boolean

参数解释

实例是否开启域名访问功能。

取值范围

  • true:开启

  • false:未开启

connect_address

String

参数解释

实例连接IP地址。

取值范围

不涉及。

port

Integer

参数解释

实例连接端口。

取值范围

不涉及。

status

String

参数解释

实例的状态。详细状态说明请参考实例状态说明

取值范围

不涉及。

instance_id

String

参数解释

实例ID。

取值范围

不涉及。

resource_spec_code

String

参数解释

资源规格标识。

取值范围

  • dms.instance.kafka.cluster.c3.mini:Kafka实例的基准带宽为100MByte/秒。

  • dms.instance.kafka.cluster.c3.small.2:Kafka实例的基准带宽为300MByte/秒。

  • dms.instance.kafka.cluster.c3.middle.2:Kafka实例的基准带宽为600MByte/秒。

  • dms.instance.kafka.cluster.c3.high.2:Kafka实例的基准带宽为1200MByte/秒。

charging_mode

Integer

参数解释

付费模式。

取值范围

  • 1表示按需计费。

  • 0表示包年/包月计费。

vpc_id

String

参数解释

VPC ID。

取值范围

不涉及。

vpc_name

String

参数解释

VPC的名称。

取值范围

不涉及。

created_at

String

参数解释

完成创建时间。

格式为时间戳,指从格林威治时间 1970年01月01日00时00分00秒起至指定时间的偏差总毫秒数。

取值范围

不涉及。

subnet_name

String

参数解释

子网名称。

取值范围

不涉及。

subnet_cidr

String

参数解释

子网网段。

取值范围

不涉及。

user_id

String

参数解释

用户ID。

取值范围

不涉及。

user_name

String

参数解释

用户名。

取值范围

不涉及。

access_user

String

参数解释

实例访问用户名。

取值范围

不涉及。

order_id

String

参数解释

订单ID,只有在包周期计费时才会有order_id值,其他计费方式order_id值为空。

取值范围

不涉及。

maintain_begin

String

参数解释

维护时间窗开始时间,格式为HH:mm:ss。

取值范围

不涉及。

maintain_end

String

参数解释

维护时间窗结束时间,格式为HH:mm:ss。

取值范围

不涉及。

enable_publicip

Boolean

参数解释

实例是否开启公网访问功能。

取值范围

  • true:开启

  • false:未开启

management_connect_address

String

参数解释

Kafka实例的Kafka Manager连接地址。

取值范围

不涉及。

ssl_enable

Boolean

参数解释

是否开启安全认证。

取值范围

  • true:开启

  • false:未开启

broker_ssl_enable

Boolean

参数解释

是否开启broker间副本加密传输。

取值范围

  • true:开启

  • false:未开启

kafka_security_protocol

String

参数解释

Kafka使用的安全协议。

若实例详情中不存在port_protocols返回参数,则kafka_security_protocol同时代表内网访问、公网访问以及跨VPC访问的安全协议。

若实例详情中存在port_protocols返回参数,则kafka_security_protocol仅代表跨VPC访问的安全协议。内网访问公网访问的安全协议请参考port_protocols参数。

取值范围

  • PLAINTEXT:既未采用SSL证书进行加密传输,也不支持账号密码认证。性能更好,安全性较低,建议在生产环境下公网访问不使用此方式。

  • SASL_SSL:采用SSL证书进行加密传输,支持账号密码认证,安全性更高。

  • SASL_PLAINTEXT:明文传输,支持账号密码认证,性能更好,建议使用SCRAM-SHA-512机制。

sasl_enabled_mechanisms

Array of strings

参数解释

开启SASL后使用的认证机制。

ssl_two_way_enable

Boolean

参数解释

是否开启双向认证。

取值范围

  • true:开启

  • false:未开启

cert_replaced

Boolean

参数解释

是否开启证书替换。

取值范围

  • true:开启

  • false:未开启

public_management_connect_address

String

参数解释

公网访问Kafka Manager连接地址。

取值范围

不涉及。

enterprise_project_id

String

参数解释

企业项目ID。

取值范围

不涉及。

is_logical_volume

Boolean

参数解释

实例扩容时用于区分老实例与新实例。

取值范围

  • true:新创建的实例,允许磁盘动态扩容不需要重启。

  • false:老实例。

extend_times

Integer

参数解释

实例扩容磁盘次数,如果超过20次则无法扩容磁盘。

取值范围

不涉及。

enable_auto_topic

Boolean

参数解释

是否开启自动创建topic。

取值范围

  • true:开启

  • false:关闭

type

String

参数解释

实例类型。

取值范围

  • single:单机。

  • cluster:集群。

product_id

String

参数解释

产品标识。

取值范围

不涉及。

security_group_id

String

参数解释

安全组ID。

取值范围

不涉及。

security_group_name

String

参数解释

安全组名称。

取值范围

不涉及。

subnet_id

String

参数解释

子网ID。

取值范围

不涉及。

available_zones

Array of strings

参数解释

实例节点所在的可用区,返回“可用区ID”。

available_zone_names

Array of strings

参数解释

实例节点所在的可用区名称,返回“可用区名称”。

total_storage_space

Integer

参数解释

总共消息存储空间,单位:GB。

取值范围

不涉及。

public_connect_address

String

参数解释

实例公网连接IP地址。当实例开启了公网访问,实例才包含该参数。

取值范围

不涉及。

public_connect_domain_name

String

参数解释

实例公网连接域名。当实例开启了公网访问,实例才包含该参数。

取值范围

不涉及。

storage_resource_id

String

参数解释

存储资源ID。

取值范围

不涉及。

storage_spec_code

String

参数解释

IO规格。

取值范围

不涉及。

service_type

String

参数解释

服务类型。

取值范围

advanced

storage_type

String

参数解释

存储类型。

取值范围

不涉及。

retention_policy

String

参数解释

消息老化策略。

取值范围

  • time_base:表示自动删除最老消息。

  • produce_reject:表示拒绝消息写入。

kafka_public_status

String

参数解释

Kafka公网开启状态。

取值范围

  • true:开启公网。

  • closed:关闭公网。

  • false:未使用公网。

  • freezed:公网冻结。

  • actived:公网解冻。

public_bandwidth

Integer

参数解释

kafka公网访问带宽。

取值范围

不涉及。

enable_log_collection

Boolean

参数解释

是否开启消息收集功能。

取值范围

  • true:开启

  • false:不开启

new_auth_cert

Boolean

参数解释

是否开启新证书。

取值范围

  • true:开启

  • false:不开启

cross_vpc_info

String

参数解释

跨VPC访问信息。

取值范围

不涉及。

ipv6_enable

Boolean

参数解释

是否开启IPv6。

取值范围

  • true:开启

  • false:不开启

ipv6_connect_addresses

Array of strings

参数解释

IPv6的连接地址。

connector_enable

Boolean

参数解释

是否开启转储。

取值范围

  • true:开启

  • false:不开启

connector_node_num

Integer

参数解释

connector节点数量。

取值范围

2-16。

connector_id

String

参数解释

转储任务ID。

取值范围

不涉及。

rest_enable

Boolean

参数解释

是否开启Kafka rest功能。

取值范围

  • true:开启

  • false:不开启

rest_connect_address

String

参数解释

Kafka rest连接地址。

取值范围

不涉及。

public_boundwidth

Integer

参数解释

Kafka公网访问带宽。待删除版本。

取值范围

不涉及。

message_query_inst_enable

Boolean

参数解释

是否开启消息查询功能。

取值范围

  • true:开启

  • false:不开启

vpc_client_plain

Boolean

参数解释

是否开启VPC明文访问。

取值范围

  • true:开启

  • false:不开启

support_features

String

参数解释

Kafka实例支持的特性功能。

取值范围

不涉及。

trace_enable

Boolean

参数解释

是否开启消息轨迹功能。

取值范围

  • true:开启

  • false:不开启

agent_enable

Boolean

参数解释

是否开启代理。

取值范围

  • true:开启

  • false:不开启

pod_connect_address

String

参数解释

租户侧连接地址。

取值范围

不涉及。

disk_encrypted

Boolean

参数解释

是否开启磁盘加密。

取值范围

  • true:开启

  • false:不开启

disk_encrypted_key

String

参数解释

磁盘加密key,未开启磁盘加密时为空。

取值范围

不涉及。

kafka_private_connect_address

String

参数解释

Kafka实例内网连接地址。

取值范围

不涉及。

kafka_private_connect_domain_name

String

参数解释

Kafka实例内网连接域名。

取值范围

不涉及。

ces_version

String

参数解释

云监控版本。

取值范围

不涉及。

public_access_enabled

String

参数解释

区分实例什么时候开启的公网访问

取值范围

  • true:已开启公网访问

  • actived:已开启公网访问

  • closed:已关闭公网访问

  • false:已关闭公网访问

node_num

Integer

参数解释

节点数。

取值范围

  • 1:kafka单机实例的节点数。

  • 3~50:kafka集群实例的节点数。

port_protocols

PortProtocolsEntity object

参数解释

实例支持的连接方式及其连接地址。

enable_acl

Boolean

参数解释

是否开启访问控制。

取值范围

  • true:开启

  • false:不开启

new_spec_billing_enable

Boolean

参数解释

是否启用新规格计费。

取值范围

  • true:开启

  • false:不开启

broker_num

Integer

参数解释

节点数量。

取值范围

不涉及。

tags

Array of TagEntity objects

参数解释

标签列表。

dr_enable

Boolean

参数解释

是否为容灾实例。

取值范围

  • true:是容灾实例。

  • false:不是容灾实例。

表3 PortProtocolsEntity

参数

参数类型

描述

private_plain_enable

Boolean

参数解释

实例是否支持内网PLAINTEXT访问接入方式。

取值范围

  • true:实例支持内网PLAINTEXT访问方式接入方式。

  • false:实例不支持内网PLAINTEXT访问接入方式。

private_plain_address

String

参数解释

kafka内网PLAINTEXT接入方式连接地址。

取值范围

不涉及

private_plain_domain_name

String

参数解释

内网明文连接域名。

取值范围

不涉及

private_sasl_ssl_enable

Boolean

参数解释

实例是否支持内网SASL_SSL访问接入方式。

取值范围

  • true:实例支持内网SASL_SSL访问方式接入方式。

  • false:实例不支持内网SASL_SSL访问接入方式。

private_sasl_ssl_address

String

参数解释

kafka内网SASL_SSL接入方式连接地址。

取值范围

不涉及

private_sasl_ssl_domain_name

String

参数解释

内网SASL_SSL连接域名。

取值范围

不涉及

private_sasl_plaintext_enable

Boolean

参数解释

实例是否支持内网SASL_PLAINTEXT访问接入方式。

取值范围

  • true:实例支持内网SASL_PLAINTEXT访问方式接入方式。

  • false:实例不支持内网SASL_PLAINTEXT访问接入方式。

private_sasl_plaintext_address

String

参数解释

kafka内网SASL_PLAINTEXT接入方式连接地址。

取值范围

不涉及

private_sasl_plaintext_domain_name

String

参数解释

内网SASL_PLAINTEXT连接域名。

取值范围

不涉及

public_plain_enable

Boolean

参数解释

实例是否支持公网PLAINTEXT访问接入方式。

取值范围

  • true:实例支持公网PLAINTEXT访问方式接入方式。

  • false:实例不支持公网PLAINTEXT访问接入方式。

public_plain_address

String

参数解释

kafka公网PLAINTEXT接入方式连接地址。

取值范围

不涉及

public_plain_domain_name

String

参数解释

公网明文连接域名。

取值范围

不涉及

public_sasl_ssl_enable

Boolean

参数解释

实例是否支持公网SASL_SSL访问接入方式。

取值范围

  • true:实例支持内网SASL_SSL访问方式接入方式。

  • false:实例不支持公网SASL_SSL访问接入方式。

public_sasl_ssl_address

String

参数解释

kafka公网SASL_SSL接入方式连接地址。

取值范围

不涉及

public_sasl_ssl_domain_name

String

参数解释

公网SASL_SSL连接域名。

取值范围

不涉及

public_sasl_plaintext_enable

Boolean

参数解释

实例是否支持公网SASL_PLAINTEXT访问接入方式。

取值范围

  • true:实例支持公网SASL_PLAINTEXT访问方式接入方式。

  • false:实例不支持公网SASL_PLAINTEXT访问接入方式。

public_sasl_plaintext_address

String

参数解释

kafka公网SASL_PLAINTEXT接入方式连接地址。

取值范围

不涉及

public_sasl_plaintext_domain_name

String

参数解释

公网SASL_PLAINTEXT连接域名。

取值范围

不涉及

表4 TagEntity

参数

参数类型

描述

key

String

参数解释

标签键。

约束限制

  • 不能为空。

  • 对于同一个实例,Key值唯一。

  • 长度为1~128个字符(中文也可以输入128个字符)。

  • 由任意语种字母、数字、空格和字符组成,字符仅支持_ . : = + - @

  • 不能以_sys_开头。

  • 首尾字符不能为空格。

取值范围

不涉及。

默认取值

不涉及。

value

String

参数解释

标签值。

约束限制

  • 长度为0~255个字符(中文也可以输入255个字符)。

  • 由任意语种字母、数字、空格和字符组成,字符仅支持_ . : = + - @

取值范围

不涉及。

默认取值

不涉及。

请求示例

查询指定实例

GET https://{endpoint}/v2/{project_id}/instances/{instance_id}

响应示例

状态码:200

查询指定实例成功。

{
  "name" : "kafka-2085975099",
  "engine" : "kafka",
  "port" : 9092,
  "status" : "RUNNING",
  "type" : "cluster",
  "specification" : "100MB",
  "engine_version" : "1.1.0",
  "connect_address" : "192.168.0.100,192.168.0.61,192.168.0.72",
  "instance_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "resource_spec_code" : "dms.instance.kafka.cluster.c3.mini",
  "charging_mode" : 1,
  "vpc_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "vpc_name" : "dms-test",
  "created_at" : "1585618587087",
  "product_id" : "00300-30308-0--0",
  "security_group_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "security_group_name" : "Sys-default",
  "subnet_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "available_zones" : [ "38b0f7a602344246bcb0da47b5d548e7" ],
  "available_zone_names" : [ "AZ1" ],
  "user_id" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "user_name" : "paas_dms",
  "maintain_begin" : "02:00:00",
  "maintain_end" : "06:00:00",
  "enable_log_collection" : false,
  "new_auth_cert" : false,
  "storage_space" : 492,
  "total_storage_space" : 600,
  "used_storage_space" : 25,
  "partition_num" : "300",
  "enable_publicip" : false,
  "ssl_enable" : false,
  "broker_ssl_enable" : false,
  "cert_replaced" : false,
  "management_connect_address" : "https://192.168.0.100:9999",
  "cross_vpc_info" : "{\"192.168.0.61\":{\"advertised_ip\":\"192.168.0.61\",\"port\":9011,\"port_id\":\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"},\"192.168.0.72\":{\"advertised_ip\":\"192.168.0.72\",\"port\":9011,\"port_id\":\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"},\"192.168.0.100\":{\"advertised_ip\":\"192.168.0.100\",\"port\":9011,\"port_id\":\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"}}",
  "storage_resource_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "storage_spec_code" : "dms.physical.storage.ultra",
  "service_type" : "advanced",
  "storage_type" : "hec",
  "enterprise_project_id" : "0",
  "is_logical_volume" : true,
  "extend_times" : 0,
  "retention_policy" : "produce_reject",
  "ipv6_enable" : false,
  "ipv6_connect_addresses" : [ ],
  "connector_enable" : false,
  "connector_node_num" : 0,
  "connector_id" : "",
  "rest_enable" : false,
  "rest_connect_address" : "",
  "kafka_public_status" : "closed",
  "public_bandwidth" : 0,
  "message_query_inst_enable" : true,
  "vpc_client_plain" : false,
  "support_features" : "kafka.new.pod.port,feature.physerver.kafka.topic.modify,feature.physerver.kafka.topic.accesspolicy,message_trace_enable,features.pod.token.access,feature.physerver.kafka.pulbic.dynamic,roma_app_enable,features.log.collection,auto_topic_switch,feature.physerver.kafka.user.manager",
  "trace_enable" : false,
  "agent_enable" : false,
  "pod_connect_address" : "100.86.75.15:9080,100.86.142.77:9080,100.86.250.167:9080",
  "disk_encrypted" : false,
  "kafka_private_connect_address" : "192.168.0.61:9092,192.168.0.100:9092,192.168.0.72:9092",
  "enable_auto_topic" : false,
  "new_spec_billing_enable" : false,
  "ces_version" : "linux",
  "port_protocols" : "{\"private_plain_enable\": true,\"private_plain_address\": \"192.xxx.xxx.xxx:9092,192.xxx.xxx.xxx:9092,192.xxx.xxx.xxx:9092\",\"private_sasl_ssl_enable\": true,\"private_sasl_ssl_address\": \"192.xxx.xxx.xxx:9093,192.xxx.xxx.xxx:9093,192.xxx.xxx.xxx:9093\",\"private_sasl_plaintext_enable\": false,\"private_sasl_plaintext_address\": \"\",\"public_plain_enable\": true,\"public_plain_address\": \"100.xxx.xxx.xxx:9094,100.xxx.xxx.xxx:9094,100.xxx.xxx.xxx:9094\",\"public_sasl_ssl_enable\": true,\"public_sasl_ssl_address\": \"100.xxx.xxx.xxx:9095,100.xxx.xxx.xxx:9095,100.xxx.xxx.xxx:9095\",\"public_sasl_plaintext_enable\": false,\"public_sasl_plaintext_address\": \"\"}"
}

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
48
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.kafka.v2.region.KafkaRegion;
import com.huaweicloud.sdk.kafka.v2.*;
import com.huaweicloud.sdk.kafka.v2.model.*;


public class ShowInstanceSolution {

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

        KafkaClient client = KafkaClient.newBuilder()
                .withCredential(auth)
                .withRegion(KafkaRegion.valueOf("<YOUR REGION>"))
                .build();
        ShowInstanceRequest request = new ShowInstanceRequest();
        request.withInstanceId("{instance_id}");
        try {
            ShowInstanceResponse response = client.showInstance(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
32
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkkafka.v2.region.kafka_region import KafkaRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkkafka.v2 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 = KafkaClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(KafkaRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ShowInstanceRequest()
        request.instance_id = "{instance_id}"
        response = client.show_instance(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    kafka "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/kafka/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/kafka/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/kafka/v2/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 := kafka.NewKafkaClient(
        kafka.KafkaClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

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

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

状态码

状态码

描述

200

查询指定实例成功。

错误码

请参见错误码

相关文档