Hi Everyone,
I upload the script:
#This script is used to update the profile attribute for an appId belonging to a tenant
#Make sure your application is registered with the COHORT before using this script
#Update the APPID,USER,COHORT,PASS,SERVER,ATTRIBUTEID and ATTRIBUTEVALUE for which the attribute needs to be updated
#Available AttributeIds and AttributeValues:
#AttributeId | Description
#------------------------------------------------------------------------
#100 | Session timeout period in millisecond
#105 | SDK Log levels 0-OFF, 1-ERROR, 2-WARN, 3-DEBUG 4-INFO
#110 | Collect location details 0-None, 1-Once, 2-Always
#115 | Upload on wifi only 0-False, 1-True
#120 | Collect resources 0 - No (fastest), 1 - url only (default), 2 . url + status code + data stats (expensive)
#125 | Percentage to Sample App Activity Data
#200 | Crashes
#220 | Screen Capture 0-OFF 1-ON
#225 | Orientation
#230 | Application Start time
#405 | Http Response time
#410 | Http Errors
#415 | Http Data received
#420 | Http Data sent
#300 | CPU usage
#305 | Memory usage
#310 | Disk usage
#315 | Framerate per second
#500 | Remote Support
#505 | APM Support 0-OFF, 1-ON
#510 | Auto Transactions 0-OFF, 1-ON
#515 | MAA Data Reporting 0-TRUE, 1-FALSE
#700 | Key expiry period in years
#705 | Revoked or Expired key grace period in days
#replace the values for the ones below
APPID=NoLocalizacion
USER=RODRIGO.BRANDARIZ@TDILATAM.COM
COHORT=RODRIGO.BRANDARIZ@TDILATAM.COM
PASS=CaAxa2015*
SERVER=https://axa.trials.ca.com
ATTRIBUTID=110
ATTRIBUTEVALUE=0
#PROFILENAME=NoLocalizacion
PROFILENAME="${APPID}_${COHORT}_profile";
#If tenant created using MCC-UI , uncomment the line below and use this as the profile name
#PROFILENAME="${APPID}_${COHORT}-USERSTORE_profile";
echo $PROFILENAME
cohort=`echo $COHORT | openssl enc -base64`
echo
echo Using Server : $SERVER with User : $USER and cohort : $COHORT
echo
TOKEN=`curl -s -X POST -H "Authorization: Basic $cohort" -d "grant_type=PASSWORD&username=$USER&password=$PASS" $SERVER/ess/security/v1/token|grep tkn |grep -v rtkn|awk -F\" '{print $4}'`
echo "TOKEN:" $TOKEN
if [ -z "$TOKEN" ]; then
TOKEN=`curl -s -X POST -H "Authorization: Basic $cohort" -d "grant_type=PASSWORD&username=$USER&password=$PASS" $SERVER/ess/security/v1/token|awk -F, '{print $2}' |awk -F\" '{print $4}'`
echo "TOKEN:" $TOKEN
if [ -z "$TOKEN" ]; then
echo no token
exit 1
fi
fi
ENC_AUTHZ=`echo \{\"tkn\":\"$TOKEN\",\"t\":\"$COHORT\"\} | openssl enc -base64 -A`
echo 'ENC_AUTHZ' $ENC_AUTHZ
echo
URL_GET_PROFILE=$SERVER/mdo/v2/profiles/${APPID}
URL_GET_PROFILE_E=${URL_GET_PROFILE// /%20}
echo
echo
echo "Getting profile ${PROFILENAME} for appId '${APPID}' belonging to cohort '${COHORT}'"
echo curl -H "Authorization: Bearer $ENC_AUTHZ" $URL_CU_PROFILE
PROFILENAME=$(curl -X GET $URL_GET_PROFILE_E -H "Authorization: Bearer $ENC_AUTHZ" --header "Content-Type:application/json" | sed -e 's/^.*"profileName":"\([^"]*\)".*$/\1/')
echo Application profile name: "$PROFILENAME"
echo
echo
URL_CU_PROFILE=$SERVER/mdo/v1/profiles/create/${APPID}
URL_U_ATTR=$SERVER/mdo/v1/profiles/$PROFILENAME/attribute
URL_CU_PROFILE_E=${URL_CU_PROFILE// /%20}
URL_U_ATTR_E=${URL_U_ATTR// /%20}
if [ "$PROFILENAME" == "Default" ]; then
echo "You have a Default profile. We will create a new profile for this application based on Default"
PROFILENAME="${APPID}_${COHORT}_profile";
#If tenant created using MCC-UI , uncomment the line below and use this as the profile name
#PROFILENAME="${APPID}_${COHORT}-USERSTORE_profile";
echo $PROFILENAME
echo "Creating/Updating profile ${PROFILENAME} for appId '${APPID}' belonging to cohort '${COHORT}'"
echo curl -H "Authorization: Bearer $ENC_AUTHZ" $URL_CU_PROFILE
curl -X POST $URL_CU_PROFILE_E -H "Authorization: Bearer $ENC_AUTHZ" --header "Content-Type:application/json" | json | json
echo
echo
echo
else
echo "You have profile : $PROFILENAME"
fi
echo
PROFILEID=$(curl -X GET $URL_GET_PROFILE_E -H "Authorization: Bearer $ENC_AUTHZ" --header "Content-Type:application/json" | sed -e 's/^.*"profileId":\([^",]*\).*$/\1/')
echo Application profile id: "$PROFILEID"
echo
echo "Updating profile attribute value"
echo curl -H "Authorization: Bearer $ENC_AUTHZ" $URL_U_ATTR
curl -X PUT -d '{"attributes":[{ "attributeId": "'$ATTRIBUTID'", "value": "'$ATTRIBUTEVALUE'"}]}' $URL_U_ATTR_E -H "Authorization: Bearer $ENC_AUTHZ" --header "Content-Type:application/json" | json | json
echo
echo