-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01_create_br_algorithms.sh
executable file
·29 lines (25 loc) · 1.45 KB
/
01_create_br_algorithms.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
#
# This script will create BR Algorithms from CSV file
#
source apiHostInfo
AUTH_HEADER=`cat Authorization`
count=0
#Get the Framework ID of Secure Lookup Algorithm
curl --location "http://$MASKING_ENGINE/masking/api/algorithm/frameworks" --header "$AUTH_HEADER" -o response_o.json
frameworkId=`jq '.responseList[] | select(.frameworkName == "Secure Lookup") | .frameworkId' response_o.json`
while IFS="," read -r rec_column1 rec_column2 rec_column3 rec_column4 rec_column5 rec_column6
do
ALG_NAME="$rec_column1"
FILE=$PWD$rec_column6
#Upload the text file and capture the fileReferenceId
response=`curl --location "http://$MASKING_ENGINE/masking/api/file-uploads?permanent=false" --header "$AUTH_HEADER" --form file=@\"$FILE\"`
fileReferenceId=$(echo "$response" | sed -n 's/.*"fileReferenceId":"\([^"]*\)".*/\1/p')
echo $fileReferenceId
echo -e "Pressione Enter para continuar"
#Create the Algorithm
curl -X POST --header "$AUTH_HEADER" --header 'Content-Type: application/json' --header 'Accept: application/json' --data "{\"algorithmName\": \"$ALG_NAME\", \"algorithmType\": \"COMPONENT\", \"description\": \"teste\", \"pluginId\": 7, \"frameworkId\": \"$frameworkId\", \"algorithmExtension\": { \"lookupFile\": { \"uri\": \"$fileReferenceId\" } } }" "http://$MASKING_ENGINE/masking/api/algorithms"
count=$(( count + 1 ))
done < <(tail -n +2 ./CSV/algorithms.csv)
echo "Created $count of $count Algorithms with success."
exit 0