#!/bin/bash
topic="topic-name"
case "$1" in
topic)
kcat -b dev-kafka.cloud.com:9094 -t "$topic" -C -e -o beginning -p 0 | kcat -b localhost:48792 -t "$topic" -P
;;
schema)
curl -X GET http://dev-schema-registry.com:8081/subjects/$topic-value/versions/latest | jq -r '.schema' > /tmp/value-schema.avsc
curl -X POST http://localhost:47086/subjects/$topic-value/versions \
-H "Content-Type: application/vnd.schemaregistry.v1+json" \
-d "{\"schema\": $(jq -Rs . < /tmp/value-schema.avsc)}"
;;
*)
echo "topics|schema"
;;
esac