Creating a Topic or Deleting Topics in Batches
Function
This API is used to create a topic or delete topics in batches.
URI
POST /v2/{project_id}/instances/{instance_id}/topics
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition Project ID. For details about how to obtain it, see Obtaining a Project ID. Constraints N/A Range N/A Default Value N/A |
| instance_id | Yes | String | Definition Instance ID. You can call the API for querying all instances to obtain the instance ID. The instance ID is in the response body. Constraints N/A Range N/A Default Value N/A |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | No | String | Definition Topic name. Constraints Enter 3 to 64 characters. Use only letters, digits, percent (%), vertical bars (|), hyphens (-), and underscores (_). Mandatory for topic creation. Range N/A Default Value N/A |
| brokers | No | Array of strings | Definition Associated broker. Constraints This parameter is mandatory only for RocketMQ 4.8.0 instances. This parameter is valid only when parameter queues is left blank. Range N/A Default Value N/A |
| queue_num | No | Number | Definition Total number of queues. Constraints This parameter is mandatory only for RocketMQ 4.8.0 instances. This parameter is valid only when parameter queues is left blank. Range 1–50 Default Value 4 |
| queues | No | Array of queues objects | Definition Queue. Constraints This parameter is required only for RocketMQ 4.8.0 instances. Range N/A Default Value N/A |
| permission | No | String | Definition Permission. Constraints This parameter is required only for RocketMQ 4.8.0 instances. Range Default Value all |
| message_type | No | String | Definition Message type. Constraints This parameter is required only for RocketMQ 5.x instances. Range Default Value NORMAL |
| topics | No | Array of strings | Definition Topic list. Constraints Mandatory for batch topic deletion. Range N/A Default Value N/A |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| id | String | Definition Topic name. Constraints N/A Range N/A Default Value N/A |
| job_id | String | Definition ID of the topic deletion task. Constraints N/A Range N/A Default Value N/A |
Example Requests
-
For RocketMQ 4.8.0 instances: Creating a topic associated with broker-0 with 3 queues
POST https://{endpoint}/v2/{project_id}/instances/{instance_id}/topics { "name" : "topic-test", "permission" : "all", "queues" : [ { "broker" : "broker-0", "queue_num" : 3 } ] } -
Deleting topics of a RocketMQ 5.x instance in a batch
POST https://{endpoint}/v2/{project_id}/instances/{instance_id}/topics?action=delete { "topics" : [ "topic01", "topic02" ] }
Example Responses
Status code: 200
Topic created.
Status Codes
| Status Code | Description |
|---|---|
| 200 | Topic created. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot