Updated on 2022-09-14 GMT+08:00

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

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

instance_id

Yes

String

Instance ID.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

action

No

String

This parameter is used to delete topics in batches. If it is not set, a topic will be created.

Request Parameters

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

name

No

String

Topic name.

brokers

No

Array of strings

Associated brokers.

queue_num

No

Number

Number of queues.

Default: 3

permission

No

String

Permissions.

Default: all

topics

No

Array of strings

Topic list. This parameter is used when topics are deleted in batches.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

id

String

Topic name.

job_id

String

Job ID for deleting topics.

Example Requests

Creating a topic

POST https://{endpoint}/v2/{project_id}/instances/{instance_id}/topics

{
  "name" : "topic-test",
  "brokers" : [ "broker-0" ],
  "queue_num" : 3,
  "permission" : "all"
}

Example Responses

Status code: 200

A topic is created or multiple topics are deleted in batches.

{
  "id" : "topic-test"
}

Status Codes

Status Code

Description

200

A topic is created or multiple topics are deleted in batches.

Error Codes

See Error Codes.