Creating a Topic
Function
This API is used to create a topic.
URI
POST /v2/{project_id}/mqs/instances/{instance_id}/topics
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Tenant's project ID. |
instance_id |
Yes |
String |
Instance ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token, which can be obtained by calling the IAM API (value of X-Subject-Token in the response header). |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
Yes |
String |
Topic name, which must start with a letter and contains 3 to 200 characters. Only digits, letters, underscores (_), and hyphens (-) are allowed. |
app_id |
Yes |
String |
Integrated application ID. |
app_key |
No |
String |
Integrated application key. |
partition |
No |
Integer |
Number of topic partitions, which is used to set the number of concurrently consumed messages. Value range: 1 to 50. Default value: 3. |
replication |
No |
Integer |
Number of replicas, which is used to configure data reliability. Value range: 1 to 3. Default value: 3.
NOTE:
The number of replicas for an instance of the trial edition can only be 1. |
access_policy |
Yes |
String |
Permission type.
|
sync_message_flush |
No |
Boolean |
Whether synchronous flushing is enabled. The default value is false. Synchronous flushing compromises performance. |
sync_replication |
No |
Boolean |
Whether synchronous replication is enabled. After this function is enabled, the acks parameter on the producer client must be set to –1. Otherwise, this parameter does not take effect. |
retention_time |
No |
Integer |
Message retention period. The default value is 72. Value range: 1 to 720, in hours |
tag |
No |
String |
Tag corresponding to the permission type. When the permission type is all, publish and subscribe tags are separated by ampersands (&). Multiple tags are separated by double vertical bars (||). |
description |
No |
String |
Description. A maximum of 1000 characters can be contained. |
sensitive_word |
No |
String |
Sensitive word. Multiple sensitive words are separated by double vertical bars (||). |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
name |
String |
Topic name. |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
Status code: 403
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
Example Requests
POST https://{endpoint}/v2/{project_id}/mqs/instances/{instance_id}/topics { "name" : "topic-test-2", "app_id" : "c5abd910-02b1-4bc4-b587-c3fe4c49dab9", "partition" : 3, "access_policy" : "all", "replication" : 3, "retention_time" : 72, "sync_replication" : false, "sync_message_flush" : false, "tag" : "11 || 22 || aa || bb&11 || 22 || aa || bb", "description" : "test", "sensitive_word" : "sss || ddd" }
Example Responses
Status code: 200
OK
{ "name" : "topic-mqs-test" }
Status code: 400
Bad Request
{ "error_code" : 400, "error_msg" : "Bad Request" }
Status code: 403
Forbidden
{ "error_code" : 403, "error_msg" : "Forbidden" }
Status Codes
Status Code |
Description |
---|---|
200 |
OK |
400 |
Bad Request |
403 |
Forbidden |
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