From 706713f57abc3c886421b6d8e2f1658cddb01853 Mon Sep 17 00:00:00 2001 From: Jonathan Bernard <jonathan@jdbernard.com> Date: Tue, 19 Feb 2019 13:26:17 -0600 Subject: [PATCH] Added cURL-based CLI client script. --- api/src/util/bash/client.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 api/src/util/bash/client.sh diff --git a/api/src/util/bash/client.sh b/api/src/util/bash/client.sh new file mode 100755 index 0000000..b3dab9b --- /dev/null +++ b/api/src/util/bash/client.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +host="${PM_API_HOST:-localhost:8080}" +if [ $# -eq 1 ]; then + url="$1" + method="GET" + data="" +elif [ $# -eq 2 ]; then + method="$1" + url="$2" + data="" +else + method="$1" + url="$2" + data="$3" +fi + +curl -s -X "$method" \ + -H "Content-Type: application/json" \ + -H "Authorization: $(cat credential)"\ + "http://${host}/api/$url" \ + -d "$data" | jq .