• 文档
  • 控制台
  • 登录
  • 立即注册
    目前不支持用户自主注册,如需注册账号,请联系400-080-1100
消息队列kafka API参考手册
最近更新时间:2023-04-16 17:00:00

1 集群管理

1.1 UpdateConfig

 调用 UpdateConfig 接口修改 kafka 实例 sasl 用户的密码。

1.1.1 使用说明

 PUT https://{Endpoint}/cmqk/kafka/v1.0/clusters/configs

1.1.2 请求参数

 说明:经过网关调用接口时不需要传入表 1-1。
 表1-1 header 中请求参数

image.png

 表1-2 body 中的请求参数

image.png

1.1.3 返回数据

image.png

1.1.4 示例

 1. 请求示例
 PUT https://{Endpoint}/cmqk/kafka/v1.0/clusters/configs
 {
      "InstanceID": "cmq-kafka-185d9d8ccc5a4a12",
      "SaslUsers": "lxl6",
      "SaslPasswords": "MTIzNDU2Nw=="
 }
 2. 正常返回示例
 HTTPS/1.1 200 OK
 Content-Type:application/json
 {
     "RequestId": "d933fcb8-173d-4d3e-a6fb-805ac68cd8a6",
     "TenantId": "220509030201100",
     "TenantType": 0,
     "InstanceId": "cmq-kafka-185d9d8ccc5a4a12",
     "IsSSL": 0,
     "SaslEnable": 1,
     "SaslUsers": "lxl6",
     "SaslPasswords": "1234567"
 }

1.2 GetCluster

 调用 GetCluster 接口获取集群详细信息。

1.2.1 使用说明

 GET https://{Endpoint}/cmqk/kafka/v1.0/cluster/get

1.2.2 请求参数

 说明:经过网关调用接口时不需要传入表 1-3。
 表1-3 header 中请求参数

image.png

 表1-4 URL 请求参数

image.png

1.2.3 返回数据

image.png

image.png

image.png

image.png

image.png

 表1-5 proxy 结构

image.png

image.png

image.png

image.png

1.2.4 示例

 1. 请求示例
 GET https://{Endpoint}/cmqk/kafka/v1.0/cluster/get?InstanceId=cmq-kafka-861bda97563341a9
 2. 正常返回示例
 HTTPS/1.1 200 OK
 Content-Type:application/json
 {
      "RequestId": "3d8569c0-09f1-4c6e-a08b-0442fd607ef9",
      "Id": 64,
      "ClusterID": "VgWPfOl8RL",
      "ClusterName": "cmq-kafka-v44nhn1t9syxcm15",
      "TenantID": "220509030201100",
      "TenantType": 0,
      "InstanceID": "cmq-kafka-861bda97563341a9",
      "ZoneCode": "zone-1",
      "RegionCode": "jiuzhang02",
      "NetworkType": "vpc",
      "State": "running",
      "DiskType": "ssd",
      "CreateTime": 1665194256,
      "UpdateTime": 0,
      "Subnet": "snet-qtrw9zgyhs",
      "NetworkUid": "vpc-jg843mibez",
      "ResourceClass": "cmq.kafka.small",
      "MsgRetentionHour": 72,
      "MaxTopicNumber": 50,
      "BrokerListK8s": "cmq-kafka-861bda97563341a9-0-0-0.cmq-kafka-861bda97563341a9.tenant-220509030201100.svc.cluster.local:9092,cmq-kafka-861bda97563341a9-1-0-0.cmq-kafka-861bda97563341a9.tenant-220509030201100.svc.cluster.local:9092,cmq-kafka-861bda97563341a9-2-0-0.cmq-kafka-861bda97563341a9.tenant-220509030201100.svc.cluster.local:9092,cmq-kafka-861bda97563341a9
 -3-0-0.cmq-kafka-861bda97563341a9.tenant-220509030201100.svc.cluster.local:9092,cmq-kafka-861bda97563341a9-4-0-0.cmq-kafka-861bda97563341a9.tenant-220509030",
      "BrokerListVpc": "192.168.0.4:9094,192.168.0.20:9094,192.168.0.21:9094,192.168.0.22:9094,192.168.0.23:9094",
      "BrokerListPublic": "",
      "ZkInfo": "cmq-kafka-zk-0.cmq-kafka-zk.product-cmq-kafka.svc.cluster.local:2181, cmq-kafka-zk-1.cmq-kafka-zk.product-cmq-kafka.svc.cluster.local:2181, cmq-kafka-zk-2.cmq-kafka-zk.product-cmq-kafka.svc.cluster.local:2181",
      "IsSSL": 0,
      "MqVersion": "2.4.0",
      "Remark": "",
      "SaslEnable": 1,
      "SaslUsers": "cmq-kafka-yv31eo80dz",
      "SaslPasswords": "chenrui824",
      "Storage": 300,
      "ReplicationNum": 5,
      "OpRequest": "{\"tenantId\":\"220509030201100\",\"productCode\":\"cmq-kafka\",\"region\":\"jiuzhang02\",\"zone\":\"zone-1\",\"productSpec\":[{\"resourceCode\":\"cmq-kafka\",\"specList\":[{\"resourceClass\":\"cmq.kafka.small\",\"resourceNum\":1,\"instanceId\":\"\",\"request\":{\"replicas\":4,\"externalZookeeper\":\"cmq-kafka-zk-0.cmq-kafka-zk.product-cmq-kafka.svc.cluster.local:2181\\\\, cmq-kafka-zk-1.cmq-kafka-zk.product-cmq-kafka.svc.cluster.local:2181\\\\,
 cmq-kafka-zk-2.cmq-kafka-zk.product-cmq-kafka.svc.cluster.local:2181\",\"deleteTopicEnable\":true,\"autoCreateTopicEnable\":false,\"logRetentionHours\":72,\"heapOpts\":\Xmx3584m -Xms1024m\",\"saslEnabled\":true,\"saslUsers\":\"cmq-kafka-yv31eo80dz\",\"saslPasswords\":\"0qzW^virAq\",\"storage\":\"300Gi\",\"sslEnabled\":false,\"brokerStsName\":\"0-0_1-0_2-0_3-0\",\"cksEnabled\":false,\"portId\":\"port-vr2sn3cfm9_port-rvkb53r9et_port-1tiel33xzp_port-7ab9vuazvl\",\"vpcIP\":\"192.168.0.20_192.168.0.21_192.168.0.22_192.168.0.23\",\"msgMaxBytes\":1000012,\
 "replicaFetchMaxBytes\":1048576,\"logSegmentBytes\":1073741824,\"logRetentionBytes\":1073741824,\"topicReplicationFactor\":3,\"compressionType\":\"producer\"},\"networkType\":\"vpc\",\"subnetId\":\"snet-qtrw9zgyhs\",\"ipList\":null,\"requireResource\":[{\"name\":\"myMiniZK01\",\"ipList\":null}]}]}],\"tenantType\":0}",
      "BrokerStsName": "0-0_1-0_2-0_3-0_4-0",
      "MsgMaxBytes": 1000012,
      "ReplicaFetchMaxBytes": 1048576,
      "LogSegmentBytes": 1073741824,
      "LogRetentionBytes": 1073741824,
      "TopicReplicationFactor": 3,
      "CompressionType": "producer",
      "TopicNum": 4,
      "ConsumerGroupNum": 1,
      "PartitionNum": 7,
      "proxy": null
 }

1.3 CreateInstance

 调用 CreateInstance 接口创建 Kafka 实例。

1.3.1 使用说明

 POST https://{Endpoint}/cmqk/resource/v1.0/instance

1.3.2 请求参数

 说明:经过网关调用接口时不需要传入表 1-6。
 表1-6 header 中请求参数

image.png

 表1-7 body 中的请求参数

image.png

image.png

image.png

1.3.3 返回数据

image.png

 表1-8 Data

image.png

image.png

image.png

1.3.4 示例

 1. 请求示例
 POST https://{Endpoint}/cmqk/resource/v1.0/instance
 {
      "Subnet": "snet-qtrw9zgyhs",
     "ZoneCode": "zone-1"
 }
 2. 正常返回示例
 HTTPS/1.1 200 OK
 Content-Type:application/json
 {
      "RequestId": "f2f96bd7-13cf-4f13-8b30-b15abe31ab6b",
      "Data": {
          "ChargingMode": "1",
          "PeriodType": "year",
          "Duration": 1,
          "ZoneCode": "zone-1",
          "InstanceId": "cmq-kafka-a9876408a59849dd",
          "InstanceName": "cmq-kafka-oxc319sh9jsed2vw",
          "SSLEnable": false,
          "MsgRetentionHour": 72,
          "SpecType": "cmq.kafka.small",
          "SASLEnable": true,
          "SASLUsername": "cmq-kafka-ik46sxainn",
          "SASLPassword": "gBpwczJj5u",
          "Storage": 300,
          "Vpc": null,
          "Subnet": "snet-qtrw9zgyhs",
          "BrokerNumber": 3,
          "TopicReplicationFactor": 3,
          "MaxMsgBytes": 1000012,
          "MaxReplicationFetchBytes": 1048576,
          "LogSegmentBytes": 1073741824,
          "LogRetentionBytes": 10737418240,
          "CompressionType": "producer"
     }
 }

1.4 DeleteInstance

 调用 DeleteInstance 接口删除 Kafka 实例。

1.4.1 使用说明

 DELETE https://{Endpoint}/cmqk/resource/v1.0/instance/{instanceId}

1.4.2 请求参数

 说明:经过网关调用接口时不需要传入表 1-9。
 表1-9 header 中请求参数

image.png


1.4.3 返回数据

image.png

1.4.4 示例

 1. 请求示例
 DELETE https://{Endpoint}/cmqk/resource/v1.0/instance/cmq-kafka-a9876408a59849dd
 2. 正常返回示例
 HTTPS/1.1 200 OK
 Content-Type:application/json
 {
      "RequestId": "3f7cba1c-cb7d-4328-a69b-5687a8f5ea4e",
      "InstanceId": "cmq-kafka-a9876408a59849dd"
 }

1.5 ListInstance

 调用 ListInstance 接口查询 Kafka 实例列表。

1.5.1 使用说明

 GET https://{Endpoint}/cmqk/resource/v1.0/instance

1.5.2 请求参数

 说明:经过网关调用接口时不需要传入表 1-10。
 表1-10 header 中请求参数

image.png

image.png

 表1-11 URL 请求参数

image.png

1.5.3 返回数据

image.png

 表1-12 Instances 元素

image.png

1.5.4 示例

 1. 请求示例
 GET https://{Endpoint}/cmqk/resource/v1.0/instance
 2. 正常返回示例
 HTTPS/1.1 200 OK
 Content-Type:application/json
 {
      "Instances": [
      {
          "ZoneCode": "zone-1",
          "InstanceId": "cmq-kafka-caacaef210b748a3",
          "InstanceName": "cmq-kafka-wooe5i3fgbplwg8j",
          "SpecType": "cmq.kafka.small",
          "Storage": 300,
          "State": "running",
          "CreateTime": "2022-10-14 09:50:54"
      },
      {
          "ZoneCode": "zone-1",
          "InstanceId": "cmq-kafka-05e1fd6b28ab46da",
          "InstanceName": "cmq-kafka-lxl",
          "SpecType": "cmq.kafka.small",
          "Storage": 300,
          "State": "running",
          "CreateTime": "2022-10-13 14:49:24"
      }
      ],
      "TotalCount": 3,
      "RequestId": "1234",
      "PageSize": 2,
      "PageNumber": 1
 }

意见反馈

文档内容是否对您有帮助?

如您有其他疑问,您也可以通过在线客服来与我们联系探讨 在线客服

联系我们
回到顶部