Skip to content

Instantly share code, notes, and snippets.

@sebge2emasphere
Created May 30, 2018 08:43
Show Gist options
  • Save sebge2emasphere/d369c448e92320442e24a5c1f2401057 to your computer and use it in GitHub Desktop.
Save sebge2emasphere/d369c448e92320442e24a5c1f2401057 to your computer and use it in GitHub Desktop.
#!/bin/bash
key="MxypbrLuFuLghheGCVHRroeiVhgULsrKgxbZQacaImQZFFeOcILGtCPYRKRlCvKt"
cookieFile="/tmp/cookie-refresh.txt"
baseUrl="https://nexis.preprod.emasphere.com"
waitingTimeInSec="120"
situation="ba14ee31-b3a5-4d9f-88a7-62cbdb357b91"
currentMonth="2018-04"
function loginEmasphere {
curl -c $cookieFile -i -u "#$key:" "$baseUrl/user?locale=EN" &> /dev/null
result=$?
if [[ $result -ne 0 ]]; then
echo "Error while login"
exit 1
fi
}
function getEmasphere {
curl -b $cookieFile "$baseUrl$1?locale=EN" 2> /dev/null
result=$?
if [[ $result -ne 0 ]]; then
echo "Error while calling $1"
exit 1
fi
}
function getMatrixValue {
fileBody=$1
url="$baseUrl/operational-query-service/matrix/rendering?locale=EN&situation=$situation&current-month=$currentMonth"
httpStatus=$(curl -b $cookieFile $url -H "Content-Type: application/json" -w '%{http_code}' -X POST --data @$fileBody)
if [[ $httpStatus -ne 200 && $httpStatus -ne 204 ]]; then
echo -e " \033[0;31mError $httpStatus while calling url $url, go on file $file\033[0m"
sleep $waitingTimeInSec
fi
}
echo "{\"type\":\"WIDGET\",\"id\":\"156a81bb-a6c8-44fb-81dd-00331eca31e0\",\"renderingId\":\"e2cfce4c-c935-4561-a2e4-954f191db1e5\",\"filters\":[{\"id\":\"ext-28634\",\"valid\":true,\"valueReference\":{\"code\":\"q\",\"defaultLabel\":\"S$
echo "{\"type\":\"WIDGET\",\"id\":\"11a79138-ae1a-42aa-bc80-b1053ac56f7c\",\"renderingId\":\"20407d1f-629c-4306-ae5a-514552ad37ea\",\"filters\":[{\"id\":\"ext-3548\",\"valid\":true,\"valueReference\":{\"code\":\"d\",\"defaultLabel\":\"Ve$
getMatrixValue "/tmp/query-1.json"
#getMatrixValue "/tmp/query-2.json"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment