aboutsummaryrefslogtreecommitdiffstats
path: root/aai-traversal/src/main/scripts/putTool.sh
diff options
context:
space:
mode:
Diffstat (limited to 'aai-traversal/src/main/scripts/putTool.sh')
-rw-r--r--aai-traversal/src/main/scripts/putTool.sh24
1 files changed, 14 insertions, 10 deletions
diff --git a/aai-traversal/src/main/scripts/putTool.sh b/aai-traversal/src/main/scripts/putTool.sh
index 6630d8f..593d0c9 100644
--- a/aai-traversal/src/main/scripts/putTool.sh
+++ b/aai-traversal/src/main/scripts/putTool.sh
@@ -50,12 +50,10 @@ display_usage() {
cat <<EOF
Usage: $0 [options]
- 1. Usage: putTool.sh <resource-path> <json payload file> <optional HTTP Response code> <optional -display>
+ 1. Usage: putTool.sh <resource-path> <json payload file> <optional -display>
2. This script requires two arguments, a resource path and a file path to a json file containing the payload.
- 3. Example: query?format=xxxx customquery.json (possible formats are simple, raw, console, count, graphson, id, pathed, resource and resource_and_url)
- 4. Adding the optional HTTP Response code will allow the script to ignore HTTP failure codes that match the input parameter.
- 5. Adding the optional "-display" argument will display all data returned from the request, instead of just a response code.
-
+ 3. Example: resource-path and payload for a particular customer is: business/customers/customer/JohnDoe customerpayload.json
+ 4. Adding the optional "-display" argument will display all data returned from the request.
EOF
}
if [ $# -eq 0 ]; then
@@ -130,24 +128,30 @@ else
fi
fi
+fname=$JSONFILE
+if [ -f /tmp/$(basename $JSONFILE) ]; then
+ fname=/tmp/$(basename $JSONFILE)
+elif [ ! -f $JSONFILE ]; then
+ echo "The file $JSONFILE does not exist"
+ exit -1
+fi
+
if [ $MISSING_PROP = false ]; then
if [ $USEBASICAUTH = false ]; then
AUTHSTRING="--cert $PROJECT_HOME/resources/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/resources/etc/auth/aaiClientPrivateKey.pem"
else
AUTHSTRING="-u $CURLUSER:$CURLPASSWORD"
fi
-
if [ $RETURNRESPONSE = true ]; then
- curl --request PUT -sL -k $AUTHSTRING -H "Content-Type: application/json" -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE | python -mjson.tool
+ curl --request PUT -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -H "Content-Type: application/json" -T $fname $RESTURL$RESOURCE | jq '.'
RC=$?
else
- result=`curl --request PUT -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "Content-Type: application/json" -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE`
+ result=`curl --request PUT -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -H "Content-Type: application/json" -T $fname $RESTURL$RESOURCE`
#echo "result is $result."
RC=0;
if [ $? -eq 0 ]; then
case $result in
+([0-9])?)
- #if [[ "$result" -eq 412 || "$result" -ge 200 && $result -lt 300 ]]
if [[ "$result" -ge 200 && $result -lt 300 ]]
then
echo "PUT result is OK, $result"
@@ -184,4 +188,4 @@ else
fi
echo `date` " Done $0, returning $RC"
-exit $RC
+exit $RC \ No newline at end of file