+ query="/ei-producer/v1/eiproducers/$2/eijobs"
+ res="$(__do_curl_to_api ECS GET $query)"
+ status=${res:${#res}-3}
+ if [ $status -ne $1 ]; then
+ echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ if [ $# -gt 2 ]; then
+ body=${res:0:${#res}-3}
+ targetJson="["
+ if [ $# -gt 3 ]; then
+ arr=(${@:3})
+ for ((i=0; i<$(($#-3)); i=i+4)); do
+ if [ "$targetJson" != "[" ]; then
+ targetJson=$targetJson","
+ fi
+ if [ -f ${arr[$i+3]} ]; then
+ jobfile=$(cat ${arr[$i+3]})
+ jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
+ else
+ echo -e $RED" FAIL. Job template file "${arr[$i+3]}", does not exist"$ERED
+ ((RES_FAIL++))
+ __check_stop_at_error
+ return 1
+ fi
+ targetJson=$targetJson"{\"ei_job_identity\":\"${arr[$i]}\",\"ei_type_identity\":\"${arr[$i+1]}\",\"target_uri\":\"${arr[$i+2]}\",\"ei_job_data\":$jobfile}"
+ done
+ fi
+ targetJson=$targetJson"]"