forked from confluentinc/demo-scene
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rest_example.sh
16 lines (15 loc) · 1.01 KB
/
rest_example.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
#
# Ref: https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-rest-api/ksql-endpoint/
#
# This works but is really horrid to look at, because the whole of the `ksql` value has to be a single line.
curl -X "POST" "http://ksqldb:8088/ksql" \
-H "Content-Type: application/vnd.ksql.v1+json; charset=utf-8" \
-d '{"ksql":"CREATE STREAM RATINGS WITH (KAFKA_TOPIC='\''ratings'\'',VALUE_FORMAT='\''AVRO'\''); CREATE STREAM POOR_RATINGS AS SELECT STARS, CHANNEL, MESSAGE FROM RATINGS WHERE STARS<3;"}'
# Splitting each command into a separate call makes more sense:
curl -X "POST" "http://ksqldb:8088/ksql" \
-H "Content-Type: application/vnd.ksql.v1+json; charset=utf-8" \
-d '{"ksql":"CREATE STREAM RATINGS2 WITH (KAFKA_TOPIC='\''ratings'\'',VALUE_FORMAT='\''AVRO'\'');"}'
curl -X "POST" "http://ksqldb:8088/ksql" \
-H "Content-Type: application/vnd.ksql.v1+json; charset=utf-8" \
-d '{"ksql":"CREATE STREAM POOR_RATINGS2 AS SELECT STARS, CHANNEL, MESSAGE FROM RATINGS WHERE STARS<3;"}'