kafka-connect-py is a Python client library for interacting with the Confluent Platform Kafka Connect REST API. It provides a convenient way to manage Kafka Connect clusters, including listing, creating, updating, and deleting connectors. The current stable version is 1.0.0, and releases appear to be infrequent, driven by new feature additions or maintenance.
pip install kafka-connect-pyVerified import paths — ran on the pinned version, not inferred.
Initialize the KafkaConnect client, retrieve the cluster version, and list existing connectors. Requires the `KAFKA_CONNECT_URL` environment variable to be set to the base URL of your Kafka Connect REST API.
Verify the `KAFKA_CONNECT_URL` environment variable or the URL passed to the `KafkaConnect` constructor. Use `try-except requests.exceptions.ConnectionError` for robust error handling.
Implement specific error handling for `requests.exceptions.HTTPError` and check the status code (e.g., `if e.response.status_code == 404:`). Consider listing connectors (`client.get_connectors()`) before attempting operations on specific ones.
Catch `requests.exceptions.HTTPError` and inspect `e.response.json()` (if JSON) or `e.response.text` for the specific validation errors from the Kafka Connect cluster. Correct your connector configuration dictionary accordingly.
Double-check the `KAFKA_CONNECT_URL` environment variable or the URL provided to `KafkaConnect`. Ensure the Kafka Connect cluster is running and accessible from the machine where your Python code is executed. Verify firewall rules or network configuration if necessary.
Verify the connector name for typos. Before attempting operations, you can list existing connectors using `client.get_connectors()` to confirm its presence. Implement `try-except` blocks to handle 404 errors gracefully.
Inspect the error response body for detailed validation messages from the Kafka Connect API. When catching the `HTTPError`, access `e.response.json()` or `e.response.text` to read the specific reasons for the 'Bad Request' and adjust your connector configuration dictionary.
No dependency data recorded yet.