KafkaSchema API#
Handle#
get_kafka_api#
Project.get_kafka_api()
Get the kafka api for the project.
Returns
KafkaApi
: The Kafka Api handle
Creation#
create_schema#
KafkaApi.create_schema(subject, schema)
Create a new kafka schema.
import hopsworks
connection = hopsworks.connection()
project = connection.get_project()
kafka_api = project.get_kafka_api()
avro_schema = {
"type": "record",
"name": "tutorial",
"fields": [
{
"name": "id",
"type": "int"
},
{
"name": "data",
"type": "string"
}
]
}
kafka_topic = kafka_api.create_schema("my_schema", avro_schema)
- subject
str
: subject name of the schema - schema
dict
: avro schema definition
Returns
KafkaSchema
: The KafkaSchema object
Raises
RestAPIError
: If unable to create the schema
Retrieval#
get_schema#
KafkaApi.get_schema(subject, version)
Get schema given subject name and version.
Arguments
- subject
str
: subject name - version
int
: version number
Returns
KafkaSchema
: KafkaSchema object
Raises
RestAPIError
: If unable to get the schema
get_schemas#
KafkaApi.get_schemas(subject)
Get all schema versions for the subject.
Arguments
- subject
str
: subject name
Returns
List[KafkaSchema]
: List of KafkaSchema objects
Raises
RestAPIError
: If unable to get the schemas
get_subjects#
KafkaApi.get_subjects()
Get all subjects.
Returns
List[str]
: List of registered subjects
Raises
RestAPIError
: If unable to get the subjects
Properties#
id#
Id of the kafka schema
schema#
Schema definition
subject#
Name of the subject for the schema
version#
Version of the schema
Methods#
delete#
KafkaSchema.delete()
Delete the schema
Potentially dangerous operation
This operation deletes the schema.
Raises
RestAPIError
.