|
| 1 | +import selectors |
| 2 | +import ssl |
| 3 | +from _typeshed import Incomplete |
| 4 | +from collections.abc import Callable, Iterable, Mapping, Sequence |
| 5 | +from typing import Literal, TypeAlias, TypedDict, type_check_only |
| 6 | +from typing_extensions import Unpack |
| 7 | + |
| 8 | +from kafka.admin.acl_resource import ACL, ACLFilter |
| 9 | +from kafka.admin.config_resource import ConfigResource |
| 10 | +from kafka.admin.new_partitions import NewPartitions |
| 11 | +from kafka.admin.new_topic import NewTopic |
| 12 | +from kafka.errors import KafkaError |
| 13 | +from kafka.protocol.admin import ElectionType |
| 14 | +from kafka.structs import GroupInformation, OffsetAndMetadata, TopicPartition |
| 15 | + |
| 16 | +_ApiVersion: TypeAlias = tuple[int, ...] |
| 17 | +_BootstrapServers: TypeAlias = str | Sequence[str] |
| 18 | +_KafkaClientFactory: TypeAlias = Callable[..., object] |
| 19 | +_SaslMechanism: TypeAlias = Literal["PLAIN", "GSSAPI", "OAUTHBEARER", "SCRAM-SHA-256", "SCRAM-SHA-512"] |
| 20 | +_SecurityProtocol: TypeAlias = Literal["PLAINTEXT", "SSL", "SASL_PLAINTEXT", "SASL_SSL"] |
| 21 | +_SocketOption: TypeAlias = tuple[int, int, int] |
| 22 | + |
| 23 | +@type_check_only |
| 24 | +class _KafkaAdminClientConfig(TypedDict, total=False): |
| 25 | + bootstrap_servers: _BootstrapServers |
| 26 | + client_id: str |
| 27 | + request_timeout_ms: int |
| 28 | + connections_max_idle_ms: int |
| 29 | + reconnect_backoff_ms: int |
| 30 | + reconnect_backoff_max_ms: int |
| 31 | + max_in_flight_requests_per_connection: int |
| 32 | + receive_buffer_bytes: int | None |
| 33 | + send_buffer_bytes: int | None |
| 34 | + socket_options: Sequence[_SocketOption] |
| 35 | + sock_chunk_bytes: int |
| 36 | + sock_chunk_buffer_count: int |
| 37 | + retry_backoff_ms: int |
| 38 | + metadata_max_age_ms: int |
| 39 | + security_protocol: _SecurityProtocol |
| 40 | + ssl_context: ssl.SSLContext | None |
| 41 | + ssl_check_hostname: bool |
| 42 | + ssl_cafile: str | None |
| 43 | + ssl_certfile: str | None |
| 44 | + ssl_keyfile: str | None |
| 45 | + ssl_password: str | None |
| 46 | + ssl_crlfile: str | None |
| 47 | + api_version: _ApiVersion | None |
| 48 | + api_version_auto_timeout_ms: int |
| 49 | + selector: type[selectors.BaseSelector] |
| 50 | + sasl_mechanism: _SaslMechanism | None |
| 51 | + sasl_plain_username: str | None |
| 52 | + sasl_plain_password: str | None |
| 53 | + sasl_kerberos_name: object | None |
| 54 | + sasl_kerberos_service_name: str |
| 55 | + sasl_kerberos_domain_name: str | None |
| 56 | + sasl_oauth_token_provider: object | None |
| 57 | + socks5_proxy: str | None |
| 58 | + metric_reporters: Sequence[type[object]] |
| 59 | + metrics_num_samples: int |
| 60 | + metrics_sample_window_ms: int |
| 61 | + kafka_client: _KafkaClientFactory |
| 62 | + |
| 63 | +@type_check_only |
| 64 | +class _CreateAclsResult(TypedDict): |
| 65 | + succeeded: list[ACL] |
| 66 | + failed: list[tuple[ACL, KafkaError]] |
| 67 | + |
| 68 | +log: Incomplete |
| 69 | + |
| 70 | +class KafkaAdminClient: |
| 71 | + DEFAULT_CONFIG: Incomplete |
| 72 | + config: Incomplete |
| 73 | + def __init__(self, **configs: Unpack[_KafkaAdminClientConfig]) -> None: ... |
| 74 | + def close(self) -> None: ... |
| 75 | + def send_request(self, request, node_id=None): ... |
| 76 | + def send_requests(self, requests_and_node_ids, response_fn=...): ... |
| 77 | + def create_topics(self, new_topics: Sequence[NewTopic], timeout_ms: int | None = None, validate_only: bool = False): ... |
| 78 | + def delete_topics(self, topics: Sequence[str], timeout_ms: int | None = None): ... |
| 79 | + def list_topics(self) -> list[str]: ... |
| 80 | + def describe_topics(self, topics: Sequence[str] | None = None) -> list[dict[str, Incomplete]]: ... |
| 81 | + def describe_cluster(self) -> dict[str, Incomplete]: ... |
| 82 | + def describe_acls(self, acl_filter: ACLFilter) -> tuple[list[ACL], KafkaError]: ... |
| 83 | + def create_acls(self, acls: Sequence[ACL]) -> _CreateAclsResult: ... |
| 84 | + def delete_acls( |
| 85 | + self, acl_filters: Sequence[ACLFilter] |
| 86 | + ) -> list[tuple[ACLFilter, list[tuple[ACL, KafkaError]], KafkaError]]: ... |
| 87 | + def describe_configs(self, config_resources: Sequence[ConfigResource], include_synonyms: bool = False): ... |
| 88 | + def alter_configs(self, config_resources: Sequence[ConfigResource]): ... |
| 89 | + def create_partitions( |
| 90 | + self, topic_partitions: Mapping[str, NewPartitions], timeout_ms: int | None = None, validate_only: bool = False |
| 91 | + ): ... |
| 92 | + def delete_records( |
| 93 | + self, |
| 94 | + records_to_delete: Mapping[TopicPartition, int], |
| 95 | + timeout_ms: float | None = None, |
| 96 | + partition_leader_id: int | None = None, |
| 97 | + ) -> dict[TopicPartition, Incomplete]: ... |
| 98 | + def describe_consumer_groups( |
| 99 | + self, group_ids: Sequence[str], group_coordinator_id: int | None = None, include_authorized_operations: bool = False |
| 100 | + ) -> list[GroupInformation]: ... |
| 101 | + def list_consumer_groups(self, broker_ids: Sequence[int] | None = None) -> list[tuple[str, str]]: ... |
| 102 | + def list_consumer_group_offsets( |
| 103 | + self, group_id: str, group_coordinator_id: int | None = None, partitions: Iterable[TopicPartition] | None = None |
| 104 | + ) -> dict[TopicPartition, OffsetAndMetadata]: ... |
| 105 | + def delete_consumer_groups( |
| 106 | + self, group_ids: Sequence[str], group_coordinator_id: int | None = None |
| 107 | + ) -> list[tuple[str, KafkaError]]: ... |
| 108 | + def perform_leader_election( |
| 109 | + self, |
| 110 | + election_type: int | ElectionType, |
| 111 | + topic_partitions: Mapping[str, Sequence[int]] | None = None, |
| 112 | + timeout_ms: int | None = None, |
| 113 | + ): ... |
| 114 | + def describe_log_dirs(self): ... |
0 commit comments