Last active
January 7, 2021 18:48
-
-
Save deanproctor/ecb1711a0fdcb475f848770a6182291d to your computer and use it in GitHub Desktop.
StreamSets Transformer REST API Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# Variables | |
host=http://10.0.0.190:19630 | |
user=admin | |
password=admin | |
pipeline_id=DevtoTra7f2bc652-e6a6-4b63-9c88-8e89108204c3 | |
parameters='{"foo": "bar"}' | |
# Start Pipeline | |
echo "Starting Pipeline with ID ${pipeline_id}..." | |
response=$(curl -s -u ${user}:${password} -X POST ${host}/rest/v1/pipeline/${pipeline_id}/start?rev=0 -H "X-Requested-By:sdc" -H "Content-Type:application/json" --data-binary "${parameters}") | |
echo "Response: ${response}" | |
# Get Pipeline Status | |
echo "Getting pipeline status..." | |
while true; do | |
response=$(curl -s -u ${user}:${password} -X GET ${host}/rest/v1/pipeline/${pipeline_id}/status -H "X-Requested-By:sdc") | |
status=$(echo ${response} | python -c 'import sys, json; obj = json.load(sys.stdin); print(obj["status"])') | |
echo -ne "Status: ${status}\r" | |
if [[ ${status} == "FINISHED" ]]; then | |
metrics=$(echo ${response} | python -c 'import sys, json; obj = json.load(sys.stdin); print(obj["metrics"])') | |
echo | |
echo "Job metrics: ${metrics}" | |
break | |
else | |
sleep 5 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment