TASKPM/scripts/rest-clients/import-resources.sh
Fernando Bellas Permuy a01c1fa5b3 ItEr40S20CUImportacionRecursosProductivosItEr39S23: REST service for importing resources exported remotely.
REST service for importing resources has been exported remotely. A script and a sample file with resources is also provided. Complex validations are not implemented yet.
2009-12-29 17:13:12 +01:00

33 lines
694 B
Bash
Executable file

#!/bin/sh
. ./rest-common-env.sh
printf "Login name: "
read loginName
printf "Password: "
read password
baseServiceURL=$DEVELOPMENT_BASE_SERVICE_URL
certificate=$DEVELOPMENT_CERTIFICATE
for i in "$@"
do
if [ "$i" = "--prod" ]; then
baseServiceURL=$PRODUCTION_BASE_SERVICE_URL
certificate=$PRODUCTION_CERTIFICATE
else
file=$i
fi
done
if [ "$file" = "" ]; then
printf "Missing file\n" 1>&2
exit -1
fi
authorization=`./base64.sh $loginName:$password`
curl -sv -X POST $certificate -d @$file \
--header "Content-type: application/xml" \
--header "Authorization: Basic $authorization" \
$baseServiceURL/resources | tidy -xml -i -q -utf8