async def post_new_schema(self, subject: str, schema: TypedSchema) -> int: payload = { "schema": json_encode(schema.to_json()), "schemaType": schema.schema_type.value } result = await self.client.post(f"subjects/{quote(subject)}/versions", json=payload) if not result.ok: raise SchemaRetrievalError(result.json()) return result.json()["id"]
def send_schema_message( self, *, subject: str, schema: TypedSchema, schema_id: int, version: int, deleted: bool, ): key = '{{"subject":"{}","version":{},"magic":1,"keytype":"SCHEMA"}}'.format( subject, version) value = { "subject": subject, "version": version, "id": schema_id, "schema": json_encode(schema.to_json(), compact=True), "deleted": deleted } if schema.schema_type is not SchemaType.AVRO: value["schemaType"] = schema.schema_type return self.send_kafka_message(key, json_encode(value, compact=True))