Kafka ScramAuth¶
KafkaScramAuth
¶
Bases: KafkaAuth, GenericOptions
Connect to Kafka using sasl.mechanism="SCRAM-SHA-256" or sasl.mechanism="SCRAM-SHA-512".
For more details see Kafka Documentation <https://kafka.apache.org/documentation/#security_sasl_scram_clientconfig>_.
.. versionadded:: 0.9.0
Examples:
Auth in Kafka with SCRAM-SHA-256 mechanism:
.. code:: python
from onetl.connection import Kafka
auth = Kafka.ScramAuth(
user="me",
password="abc",
digest="SHA-256",
)
Auth in Kafka with SCRAM-SHA-512 mechanism and some custom SASL options passed to Kafka client config:
.. code:: python
from onetl.connection import Kafka
auth = Kafka.ScramAuth.parse(
{
"user": "me",
"password": "abc",
"digest": "SHA-512",
# options with `sasl.login.` prefix are passed to Kafka client config as-is
"sasl.login.class": "com.example.CustomScramLogin",
}
)
cleanup(kafka)
¶
This method is called while closing Kafka connection.
Implement it to cleanup resources like temporary files.
Parameters:
-
kafka(:obj:Kafka <onetl.connection.db_connection.kafka.connection.Kafka>) –Connection instance
get_options(kafka)
¶
Get options for Kafka connection
Parameters:
-
kafka(:obj:Kafka <onetl.connection.db_connection.kafka.connection.Kafka>) –Connection instance
Returns:
-
dict(dict) –Kafka client options
parse(options)
classmethod
¶
If a parameter inherited from the ReadOptions class was passed, then it will be returned unchanged. If a Dict object was passed it will be converted to ReadOptions.
Otherwise, an exception will be raised