更新时间:2024-03-15 GMT+08:00

查询指定实例

功能介绍

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

调用方法

请参见如何调用API

URI

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

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

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

instance_id

String

实例ID。

请求参数

响应参数

状态码: 200

表2 响应Body参数

参数

参数类型

描述

name

String

实例名称。

engine

String

引擎。

engine_version

String

版本。

description

String

实例描述。

specification

String

实例规格。

storage_space

Integer

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

partition_num

String

Kafka实例的分区数量。

used_storage_space

Integer

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

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

开启SASL后使用的安全协议。

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

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

sasl_enabled_mechanisms

Array of strings

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

  • PLAIN: 简单的用户名密码校验。

  • SCRAM-SHA-512: 用户凭证校验,安全性比PLAIN机制更高。

ssl_two_way_enable

Boolean

是否开启双向认证。

cert_replaced

Boolean

是否能够证书替换。

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

是否打开kafka自动创建topic功能。

  • true:开启

  • false:关闭

type

String

实例类型:集群,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地址。当实例开启了公网访问,实例才包含该参数。

storage_resource_id

String

存储资源ID。

storage_spec_code

String

IO规格。

service_type

String

服务类型。

storage_type

String

存储类型。

retention_policy

String

消息老化策略。

kafka_public_status

String

Kafka公网开启状态。

public_bandwidth

Integer

kafka公网访问带宽。

kafka_manager_enable

Boolean

是否已开启kafka manager

kafka_manager_user

String

登录Kafka Manager的用户名。

enable_log_collection

Boolean

是否开启消息收集功能。

new_auth_cert

Boolean

是否开启新证书。

cross_vpc_info

String

跨VPC访问信息。

ipv6_enable

Boolean

是否开启ipv6。

ipv6_connect_addresses

Array of strings

IPv6的连接地址。

connector_enable

Boolean

是否开启转储。新规格产品暂不支持开启转储。

connector_node_num

Integer

connector节点数量。

connector_id

String

转储任务ID。

rest_enable

Boolean

是否开启Kafka rest功能。

rest_connect_address

String

Kafka rest连接地址。

public_boundwidth

Integer

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

message_query_inst_enable

Boolean

是否开启消息查询功能。

vpc_client_plain

Boolean

是否开启VPC明文访问。

support_features

String

Kafka实例支持的特性功能。

trace_enable

Boolean

是否开启消息轨迹功能。

agent_enable

Boolean

是否开启代理。

pod_connect_address

String

租户侧连接地址。

disk_encrypted

Boolean

是否开启磁盘加密。

disk_encrypted_key

String

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

kafka_private_connect_address

String

Kafka实例私有连接地址。

ces_version

String

云监控版本。

public_access_enabled

String

区分实例什么时候开启的公网访问:true,actived,closed,false。

node_num

Integer

节点数。

enable_acl

Boolean

是否开启访问控制。

new_spec_billing_enable

Boolean

是否启用新规格计费。

broker_num

Integer

节点数量。

tags

Array of TagEntity objects

标签列表。

dr_enable

Boolean

是否为容灾实例。

表3 TagEntity

参数

参数类型

描述

key

String

标签键。

  • 不能为空。

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

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

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

  • 首尾字符不能为空格。

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",
      "kafka_manager_enable" : false,
      "kafka_manager_user" : "root",
      "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"
    }

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
# coding: utf-8

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 = __import__('os').getenv("CLOUD_SDK_AK")
    sk = __import__('os').getenv("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

查询指定实例成功。

错误码

请参见错误码