Updated on 2023-08-29 GMT+08:00

Reassigning Replicas of a Topic for a Kafka Instance

Function

This API is used to reassign replicas of a topic for a Kafka instance.

URI

POST /v2/{project_id}/instances/{instance_id}/management/topics/{topic}/replicas-reassignment

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain it, see Obtaining a Project ID.

instance_id

Yes

String

Instance ID.

topic

Yes

String

Topic name.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

partitions

No

Array of partitions objects

Assignment of replicas of the partition after the change.

Table 3 partitions

Parameter

Mandatory

Type

Description

partition

No

Integer

Partition ID.

replicas

No

Array of integers

ID of the broker where the replica is expected to reside. The first integer in the array represents the leader replica broker ID. All partitions must have the same number of replicas. The number of replicas cannot be larger than the number of brokers.

Response Parameters

None

Example Requests

Reassigning topic partitions, with replicas of partition 1 on brokers 1 and 2, and the leader replica on broker 1

POST https://{endpoint}/v2/{project_id}/instances/{instance_id}/management/topics/{topic}/replicas-reassignment

{
  "partitions" : [ {
    "partition" : 1,
    "replicas" : [ 1, 2 ]
  }, {
    "partition" : 0,
    "replicas" : [ 0, 1 ]
  } ]
}

Example Responses

None

Status Codes

Status Code

Description

204

The replicas are reassigned successfully.

Error Codes

See Error Codes.