|
15 | 15 | from enum import Enum |
16 | 16 | from json.decoder import JSONDecodeError |
17 | 17 | from logging import Logger |
18 | | -from typing import Any, Callable, NamedTuple, Optional, Protocol, cast |
| 18 | +from typing import Any, Callable, List, NamedTuple, Optional, Protocol, cast |
19 | 19 | from uuid import UUID |
20 | 20 |
|
21 | 21 | import requests |
@@ -1094,7 +1094,7 @@ def trigger_cores_rebalance(self, node): |
1094 | 1094 |
|
1095 | 1095 | return self._request("post", path, node=node) |
1096 | 1096 |
|
1097 | | - def list_reconfigurations(self, node=None): |
| 1097 | + def list_reconfigurations(self, node: ClusterNode | None = None): |
1098 | 1098 | """ |
1099 | 1099 | List pending reconfigurations |
1100 | 1100 | """ |
@@ -1135,7 +1135,9 @@ def get_partitions(self, topic=None, partition=None, *, namespace=None, node=Non |
1135 | 1135 |
|
1136 | 1136 | return self._request("get", path, node=node).json() |
1137 | 1137 |
|
1138 | | - def get_partition(self, ns: str, topic: str, id: int, node=None): |
| 1138 | + def get_partition( |
| 1139 | + self, ns: str, topic: str, id: int, node: ClusterNode | None = None |
| 1140 | + ) -> dict[str, Any]: |
1139 | 1141 | return self._request("GET", f"partitions/{ns}/{topic}/{id}", node=node).json() |
1140 | 1142 |
|
1141 | 1143 | def get_transactions(self, topic, partition, namespace, node=None): |
@@ -1193,7 +1195,12 @@ def find_tx_coordinator(self, tid, node=None): |
1193 | 1195 | return self._request("get", path, node=node).json() |
1194 | 1196 |
|
1195 | 1197 | def set_partition_replicas( |
1196 | | - self, topic, partition, replicas, *, namespace="kafka", node=None |
| 1198 | + self, |
| 1199 | + topic: str, |
| 1200 | + partition: int, |
| 1201 | + replicas: List[dict[str, int]], |
| 1202 | + namespace: str = "kafka", |
| 1203 | + node: ClusterNode | None = None, |
1197 | 1204 | ): |
1198 | 1205 | """ |
1199 | 1206 | [ {"node_id": 0, "core": 1}, ... ] |
@@ -1402,8 +1409,14 @@ def get_partition_leader(self, *, namespace, topic, partition, node=None): |
1402 | 1409 | return partition_info["leader_id"] |
1403 | 1410 |
|
1404 | 1411 | def transfer_leadership_to( |
1405 | | - self, *, namespace, topic, partition, target_id=None, leader_id=None |
1406 | | - ): |
| 1412 | + self, |
| 1413 | + *, |
| 1414 | + namespace: str, |
| 1415 | + topic: str, |
| 1416 | + partition: int, |
| 1417 | + target_id: int | None = None, |
| 1418 | + leader_id: int | None = None, |
| 1419 | + ) -> bool: |
1407 | 1420 | """ |
1408 | 1421 | Looks up current ntp leader and transfer leadership to target node, |
1409 | 1422 | this operations is NOP when current leader is the same as target. |
|
0 commit comments