This commit is contained in:
Felix Lohmeier 2020-07-03 21:57:02 +02:00 committed by GitHub
parent bf14449df9
commit 2df9d33ec4
1 changed files with 270 additions and 124 deletions

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# openrefine-bash-curl.sh, Felix Lohmeier, v0.2, 2020-07-03 # openrefine-bash-curl.sh, Felix Lohmeier, v0.3, 2020-07-03
# How to control OpenRefine 3.3+ with cURL (and jq) in Bash scripts # How to control OpenRefine 3.3+ with cURL (and jq) in Bash scripts
# https://gist.github.com/felixlohmeier/d76bd27fbc4b8ab6d683822cdf61f81d # https://gist.github.com/felixlohmeier/d76bd27fbc4b8ab6d683822cdf61f81d
# tested on Linux (Fedora 33), needs to be adapted to work on macOS # tested on Linux (Fedora 33), needs to be adapted to work on macOS
@ -17,7 +17,7 @@ memory="1400M"
date="$(date +%Y%m%d_%H%M%S)" date="$(date +%Y%m%d_%H%M%S)"
workspace="${date}" workspace="${date}"
# ========================== REQUIREMENTS #=================================== # # ========================== REQUIREMENTS ==================================== #
# check requirement java # check requirement java
java="$(command -v java 2> /dev/null)" java="$(command -v java 2> /dev/null)"
@ -69,10 +69,7 @@ openrefine="$(readlink -f openrefine/refine)"
# ============================ ENVIRONMENT =================================== # # ============================ ENVIRONMENT =================================== #
function log() { # start OpenRefine
echo "$(date +%H:%M:%S.%3N) [ client] $1"
}
function start() { function start() {
${openrefine} -v warn -m "${memory}" -p "${port}" -d "${workspace}" & ${openrefine} -v warn -m "${memory}" -p "${port}" -d "${workspace}" &
pid_server=${!} pid_server=${!}
@ -81,6 +78,7 @@ function start() {
|| { echo 1>&2 "ERROR: starting OpenRefine server failed!"; stop; exit 1; } || { echo 1>&2 "ERROR: starting OpenRefine server failed!"; stop; exit 1; }
} }
# stop OpenRefine
function stop() { function stop() {
echo echo
# print system resources # print system resources
@ -89,38 +87,50 @@ function stop() {
# SIGKILL (kill -9) prevents saving OpenRefine projects # SIGKILL (kill -9) prevents saving OpenRefine projects
{ kill -9 "${pid_server}" && wait "${pid_server}"; } 2>/dev/null { kill -9 "${pid_server}" && wait "${pid_server}"; } 2>/dev/null
# grep log for server exceptions # grep log for server exceptions
grep -i 'exception\|error' "${workspace}/${date}.log" \ echo "check log for any warnings..."
&& exit 1 || log "no warnings, all good!" if grep -i 'exception\|error' "${workspace}/${date}.log"; then
exit 1
else
log "no warnings, all good!"
fi
} }
# cleanup handler
trap "stop;exit 1" SIGHUP SIGINT SIGQUIT SIGTERM trap "stop;exit 1" SIGHUP SIGINT SIGQUIT SIGTERM
# get csrf token (introduced in OpenRefine 3.3)
function csrf() { function csrf() {
response=$(curl -fsS "${endpoint}/command/core/get-csrf-token") response=$(curl -fsS "${endpoint}/command/core/get-csrf-token")
if [[ "${response}" != '{"token":"'* ]]; then if [[ "${response}" != '{"token":"'* ]]; then
echo 1>&2 "ERROR: getting CSRF token failed!"; stop; exit 1 echo 1>&2 "ERROR: getting CSRF token failed!"; return 1
else else
echo "$response" | cut -d \" -f 4 echo "$response" | cut -d \" -f 4
fi fi
} }
function import() { # check and store project ids from import in associative array p
p[$project]=$(echo "$1" | cut -d '=' -f 2) declare -A p
# error handling: exit if import failed function store() {
if [[ "${#p[$project]}" != 13 ]]; then if [[ $# -eq 2 ]]; then
echo 1>&2 "$1"; stop; exit 1 p[$1]=$(cut -d '=' -f 2 "$2")
else else
log "loaded as project id ${p[$project]}" echo 1>&2 "ERROR: invalid arguments supplied to import function"; return 1
fi
if [[ "${#p[$1]}" != 13 ]]; then
echo 1>&2 "ERROR: returned project id is not valid"; return 1
else
rm "$2"
fi fi
} }
# create workspace # create directories
mkdir -p "${workspace}" mkdir -p "${workspace}"
# simple logging # logging
exec &> >(tee -a "${workspace}/${date}.log") exec &> >(tee -a "${workspace}/${date}.log")
function log() {
# declare associative array for projects echo "$(date +%H:%M:%S.%3N) [ client] $1"
declare -A p }
# =================== TEMPLATES FOR YOUR WORKFLOW ============================ # # =================== TEMPLATES FOR YOUR WORKFLOW ============================ #
@ -133,22 +143,31 @@ echo
# ------------------------- IMPORT OPTION 1 ---------------------------------- # # ------------------------- IMPORT OPTION 1 ---------------------------------- #
# create project from heredoc # create project from heredoc
project="example1" # project id will be accessible as ${p[example1]} # project id will be accessible as ${p[example1]}
project="example1"
input="example1.csv"
filename="${input##*/})"
echo "import ${project}..." echo "import ${project}..."
import "$(curl -fsS --write-out "%{redirect_url}\n" \ if curl -fsS --write-out "%{redirect_url}\n" \
--form project-file="@-;filename=example1.csv" \ --form project-file="@-;filename=${input}" \
--form project-name="${project}" \ --form project-name="${project}" \
--form format="text/line-based/*sv" \ --form format="text/line-based/*sv" \
--form options='{"separator": " "}' \ --form options='{"separator": " "}' \
"${endpoint}/command/core/create-project-from-upload?csrf_token=$(csrf)" \ "${endpoint}/command/core/create-project-from-upload?csrf_token=$(csrf)" \
> "${workspace}/${filename}.id" \
<< "DATA" << "DATA"
a b c a b c
1 2 3 1 2 3
0 0 0 0 0 0
$ \ ' $ \ '
DATA DATA
)" then
echo store "${project}" "${workspace}/${filename}.id" \
|| { echo 1>&2 "ERROR: import of ${input} failed!"; stop; exit 1; } \
&& log "imported ${input} as ${p[$project]}"; echo
else
echo 1>&2 "ERROR: import of ${input} failed!"; stop; exit 1
fi
# -------------------------- IMPORT OPTION 2 --------------------------------- # # -------------------------- IMPORT OPTION 2 --------------------------------- #
@ -160,14 +179,64 @@ z,x,y
DATA DATA
# create project from file # create project from file
project="example2" # project id will be accessible as ${p[example2]} # project id will be accessible as ${p[example2]}
echo "import ${project} from file..." project="example2"
import "$(curl -fsS --write-out "%{redirect_url}\n" \ input="${workspace}/test.csv"
--form project-file="@${workspace}/test.csv" \ filename="${input##*/})"
echo "import ${project}..."
if curl -fsS --write-out "%{redirect_url}\n" \
--form project-file="@${input}" \
--form project-name="${project}" \ --form project-name="${project}" \
--form format="text/line-based/*sv" \ --form format="text/line-based/*sv" \
--form options='{"separator": ","}' \ --form options='{"separator": ","}' \
"${endpoint}/command/core/create-project-from-upload?csrf_token=$(csrf)")" "${endpoint}/command/core/create-project-from-upload?csrf_token=$(csrf)" \
> "${workspace}/${filename}.id"
then
store "${project}" "${workspace}/${filename}.id" \
|| { echo 1>&2 "ERROR: import of ${input} failed!"; stop; exit 1; } \
&& log "imported ${input} as ${p[$project]}"; echo
else
echo 1>&2 "ERROR: import of ${input} failed!"; stop; exit 1
fi
# -------------------------- IMPORT OPTION 3 --------------------------------- #
# mockup test data
cat << DATA > "${workspace}/test2.csv"
r,s,t
1,1,1
2,2,2
DATA
# create projects from files (in parallel)
# project ids will be accessible as ${p[test]} and ${p[test2]}
inputs=( "${workspace}/test.csv" "${workspace}/test2.csv" )
echo "import files" "${input[@]}" "..."
pid=()
for i in "${!inputs[@]}"; do
filename="${inputs[$i]##*/}"
project="${filename%%.*}"
curl -fsS --write-out "%{redirect_url}\n" \
--form project-file="@${inputs[$i]}" \
--form project-name="${project}" \
--form format="text/line-based/*sv" \
--form options='{"separator": ","}' \
"${endpoint}/command/core/create-project-from-upload?csrf_token=$(csrf)" \
> "${workspace}/${filename}.id" &
pid+=("$!")
done
for i in "${!inputs[@]}"; do
filename="${inputs[$i]##*/}"
project="${filename%%.*}"
wait "${pid[$i]}"
if [[ $(wait "${pid[$i]}") -eq 0 ]]; then
store "${project}" "${workspace}/${filename}.id" \
|| { echo 1>&2 "ERROR: import of ${input} failed!"; stop; exit 1; } \
&& log "imported ${input} as ${p[$project]}"
else
echo 1>&2 "ERROR: import of ${input} failed!"; stop; exit 1
fi
done
echo echo
# ------------------------ TRANSFORM OPTION 1 -------------------------------- # # ------------------------ TRANSFORM OPTION 1 -------------------------------- #
@ -190,23 +259,31 @@ cat << DATA > "${workspace}/test.json"
DATA DATA
# apply operation from file # apply operation from file
project="example1"
input="${workspace}/test.json"
echo "add column test..." echo "add column test..."
curl -fsS \ if curl -fsS \
--data project="${p[example1]}" \ --data project="${p[$project]}" \
--data-urlencode operations@"${workspace}/test.json" \ --data-urlencode operations@"${input}" \
"${endpoint}/command/core/apply-operations?csrf_token=$(csrf)" \ "${endpoint}/command/core/apply-operations?csrf_token=$(csrf)" > /dev/null
|| { stop; exit 1; } then
echo; echo log "transformed ${p[$project]} with ${input}"
echo
else
echo 1>&2 "ERROR: transform ${p[$project]} with ${input} failed!"
stop; exit 1
fi
# ------------------------ TRANSFORM OPTION 2 -------------------------------- # # ------------------------ TRANSFORM OPTION 2 -------------------------------- #
# apply operation from quoted heredoc # apply operation from quoted heredoc
project="example1"
echo "add column test2..." echo "add column test2..."
curl -fsS \ if curl -fsS \
--data project="${p[example1]}" \ --data project="${p[$project]}" \
--data-urlencode "operations@-" \ --data-urlencode "operations@-" \
"${endpoint}/command/core/apply-operations?csrf_token=$(csrf)" \ "${endpoint}/command/core/apply-operations?csrf_token=$(csrf)" > /dev/null \
<< "JSON" || { stop; exit 1; } << "JSON"
[ [
{ {
"op": "core/column-addition", "op": "core/column-addition",
@ -221,20 +298,26 @@ curl -fsS \
} }
] ]
JSON JSON
echo; echo then
log "transformed ${p[$project]}"
echo
else
echo 1>&2 "ERROR: transform ${p[$project]} failed!"; stop; exit 1
fi
# ------------------------ TRANSFORM OPTION 3 -------------------------------- # # ------------------------ TRANSFORM OPTION 3 -------------------------------- #
# apply operation from unquoted heredoc (allows using bash variables) # apply operation from unquoted heredoc (allows using bash variables)
echo "add column test3..." project="example1"
new_column="test3" new_column="test3"
base_column="b" base_column="b"
replace_value="BAR" replace_value="BAR"
curl -fsS \ echo "add column test3..."
--data project="${p[example1]}" \ if curl -fsS \
--data project="${p[$project]}" \
--data-urlencode "operations@-" \ --data-urlencode "operations@-" \
"${endpoint}/command/core/apply-operations?csrf_token=$(csrf)" \ "${endpoint}/command/core/apply-operations?csrf_token=$(csrf)" > /dev/null \
<< JSON || { stop; exit 1; } << JSON
[ [
{ {
"op": "core/column-addition", "op": "core/column-addition",
@ -249,24 +332,30 @@ curl -fsS \
} }
] ]
JSON JSON
echo; echo then
log "transformed ${p[$project]}"
echo
else
echo 1>&2 "ERROR: transform ${p[$project]} failed!"; stop; exit 1
fi
# ------------------------ TRANSFORM OPTION 4 -------------------------------- # # ------------------------ TRANSFORM OPTION 4 -------------------------------- #
# apply operation from unquoted heredoc with multi-line expression (requires jq) # apply operation from unquoted heredoc with multi-line expression (requires jq)
echo "add column test4..." project="example1"
replace_value="!" replace_value="!"
echo "add column test4..."
read -r -d '' expression << EXPRESSION read -r -d '' expression << EXPRESSION
grel:value.replace( grel:value.replace(
'2', '2',
'${replace_value}' '${replace_value}'
) )
EXPRESSION EXPRESSION
curl -fsS \ if curl -fsS \
--data project="${p[example1]}" \ --data project="${p[$project]}" \
--data-urlencode "operations@-" \ --data-urlencode "operations@-" \
"${endpoint}/command/core/apply-operations?csrf_token=$(csrf)" \ "${endpoint}/command/core/apply-operations?csrf_token=$(csrf)" > /dev/null \
<< JSON || { stop; exit 1; } << JSON
[ [
{ {
"op": "core/column-addition", "op": "core/column-addition",
@ -281,13 +370,19 @@ curl -fsS \
} }
] ]
JSON JSON
echo; echo then
log "transformed ${p[$project]}"
echo
else
echo 1>&2 "ERROR: transform ${p[$project]} failed!"; stop; exit 1
fi
# ------------------------ TRANSFORM OPTION 5 -------------------------------- # # ------------------------ TRANSFORM OPTION 5 -------------------------------- #
# apply multiple operations generated on-the-fly (requires jq) # apply multiple operations generated on-the-fly (requires jq)
echo "delete columns..." project="example1"
columns=( "test" "test2" "test3" ) columns=( "test" "test2" "test3" )
echo "delete columns..."
payload=() payload=()
for column in "${columns[@]}"; do for column in "${columns[@]}"; do
payload+=( "$(cat << JSON payload+=( "$(cat << JSON
@ -300,43 +395,56 @@ for column in "${columns[@]}"; do
JSON JSON
)" ) )" )
done done
echo "${payload[@]}" | "${jq}" -s add | curl -fsS \ if echo "${payload[@]}" | "${jq}" -s add | curl -fsS \
--data project="${p[example1]}" \ --data project="${p[$project]}" \
--data-urlencode operations@- \ --data-urlencode operations@- \
"${endpoint}/command/core/apply-operations?csrf_token=$(csrf)" \ "${endpoint}/command/core/apply-operations?csrf_token=$(csrf)" > /dev/null
|| { stop; exit 1; } then
echo; echo log "transformed ${p[$project]}"
echo
else
echo 1>&2 "ERROR: transform ${p[$project]} failed!"; stop; exit 1
fi
# -------------------------- EXPORT OPTION 1 --------------------------------- # # -------------------------- EXPORT OPTION 1 --------------------------------- #
# export to stdout # export to stdout
project="example1"
echo "export example1..." echo "export example1..."
curl -fsS \ if curl -fsS \
--data project="${p[example1]}" \ --data project="${p[$project]}" \
--data format="tsv" \ --data format="tsv" \
--data engine='{"facets":[],"mode":"row-based"}' \ --data engine='{"facets":[],"mode":"row-based"}' \
"${endpoint}/command/core/export-rows" \ "${endpoint}/command/core/export-rows"
|| { stop; exit 1; } then
echo echo
else
echo 1>&2 "ERROR: export of ${p[$project]} failed!"; stop; exit 1
fi
# -------------------------- EXPORT OPTION 2 --------------------------------- # # -------------------------- EXPORT OPTION 2 --------------------------------- #
# export to file # export to file
project="example1"
output="${workspace}/example1.csv" output="${workspace}/example1.csv"
echo "export example1..." echo "export example1..."
curl -fsS \ if curl -fsS \
--data project="${p[example1]}" \ --data project="${p[$project]}" \
--data format="csv" \ --data format="csv" \
--data engine='{"facets":[],"mode":"row-based"}' \ --data engine='{"facets":[],"mode":"row-based"}' \
"${endpoint}/command/core/export-rows" \ "${endpoint}/command/core/export-rows" \
> "${output}" \ > "${output}"
|| { stop; exit 1; } \ then
&& log "saved to file ${output}" log "${p[$project]} saved to file ${output}"
echo echo
else
echo 1>&2 "ERROR: export of ${p[$project]} failed!"; stop; exit 1
fi
# -------------------------- EXPORT OPTION 3 --------------------------------- # # -------------------------- EXPORT OPTION 3 --------------------------------- #
# templating export to stdout # templating export to stdout
project="example2"
echo "export example2 using template..." echo "export example2 using template..."
IFS= read -r -d '' template << TEMPLATE IFS= read -r -d '' template << TEMPLATE
{ {
@ -344,8 +452,8 @@ IFS= read -r -d '' template << TEMPLATE
"y": {{cells['y'].value.jsonize()}} "y": {{cells['y'].value.jsonize()}}
} }
TEMPLATE TEMPLATE
echo "${template}" | head -c -2 | curl -fsS \ if echo "${template}" | head -c -2 | curl -fsS \
--data project="${p[example2]}" \ --data project="${p[$project]}" \
--data format="template" \ --data format="template" \
--data prefix="[ --data prefix="[
" \ " \
@ -355,13 +463,17 @@ echo "${template}" | head -c -2 | curl -fsS \
" \ " \
--data engine='{"facets":[],"mode":"row-based"}' \ --data engine='{"facets":[],"mode":"row-based"}' \
--data-urlencode template@- \ --data-urlencode template@- \
"${endpoint}/command/core/export-rows" \ "${endpoint}/command/core/export-rows"
|| { stop; exit 1; } then
echo; echo echo; echo
else
echo 1>&2 "ERROR: export of ${p[$project]} failed!"; stop; exit 1
fi
# -------------------------- EXPORT OPTION 4 --------------------------------- # # -------------------------- EXPORT OPTION 4 --------------------------------- #
# templating export to file # templating export to file
project="example2"
output="${workspace}/example2.json" output="${workspace}/example2.json"
echo "export example2 using template..." echo "export example2 using template..."
IFS= read -r -d '' template << TEMPLATE IFS= read -r -d '' template << TEMPLATE
@ -370,8 +482,8 @@ IFS= read -r -d '' template << TEMPLATE
"y": {{cells['y'].value.jsonize()}} "y": {{cells['y'].value.jsonize()}}
} }
TEMPLATE TEMPLATE
echo "${template}" | head -c -2 | curl -fsS \ if echo "${template}" | head -c -2 | curl -fsS \
--data project="${p[example2]}" \ --data project="${p[$project]}" \
--data format="template" \ --data format="template" \
--data prefix="[ --data prefix="[
" \ " \
@ -382,14 +494,17 @@ echo "${template}" | head -c -2 | curl -fsS \
--data engine='{"facets":[],"mode":"row-based"}' \ --data engine='{"facets":[],"mode":"row-based"}' \
--data-urlencode template@- \ --data-urlencode template@- \
"${endpoint}/command/core/export-rows" \ "${endpoint}/command/core/export-rows" \
> "${output}" \ > "${output}"
|| { stop; exit 1; } \ then
&& log "saved to file ${output}" log "${p[$project]} saved to ${output}"
echo; echo echo
else
echo 1>&2 "ERROR: export of ${p[$project]} failed!"; stop; exit 1
fi
# -------------------------- EXPORT OPTION 5 --------------------------------- # # -------------------------- EXPORT OPTION 5 --------------------------------- #
# export projects to files (example for parallel execution) # export projects to files (in parallel)
projects=( "example1" "example2" ) projects=( "example1" "example2" )
format="tsv" format="tsv"
echo "export ${projects[*]} to files..." echo "export ${projects[*]} to files..."
@ -403,10 +518,13 @@ for project in "${projects[@]}"; do
> "${workspace}/${project}.${format}" & > "${workspace}/${project}.${format}" &
pid+=("$!") pid+=("$!")
done done
for i in "${!projects[@]}"; do for i in "${!projects[@]}"; do
wait "${pid[$i]}" \ project="${projects[$i]}"
|| { echo 1>&2 "ERROR: export of ${projects[$i]} failed!"; stop; exit 1; } \ if [[ $(wait "${pid[$i]}") -eq 0 ]]; then
&& log "${projects[$i]} saved to file ${workspace}/${projects[$i]}.${format}" log "${p[$project]} saved to ${workspace}/${project}.${format}"
else
echo 1>&2 "ERROR: export of ${p[$project]} failed!"; stop; exit 1
fi
done done
echo echo
@ -414,79 +532,107 @@ echo
# print id and name for each project (requires jq) # print id and name for each project (requires jq)
echo "list projects..." echo "list projects..."
curl -fsS --get \ if curl -fsS --get \
"${endpoint}/command/core/get-all-project-metadata" \ "${endpoint}/command/core/get-all-project-metadata" \
| "${jq}" -r '.projects | keys[] as $k | "\($k): \(.[$k] | .name)"' \ | "${jq}" -r '.projects | keys[] as $k | "\($k): \(.[$k] | .name)"'
|| { stop; exit 1; } then
echo echo
else
echo 1>&2 "ERROR: list projects failed!"; stop; exit 1
fi
# -------------------------- GET METADATA ------------------------------------ # # -------------------------- GET METADATA ------------------------------------ #
# print metadata (requires jq) # print metadata (requires jq)
project="example1"
echo "metadata for project example1..." echo "metadata for project example1..."
curl -fsS --get \ if curl -fsS --get \
--data project="${p[example1]}" \ --data project="${p[$project]}" \
"${endpoint}/command/core/get-project-metadata" \ "${endpoint}/command/core/get-project-metadata" \
| "${jq}" "{ id: ${p[example1]} } + ." \ | "${jq}" "{ id: ${p[$project]} } + ."
|| { stop; exit 1; } then
echo echo
else
echo 1>&2 "ERROR: getting metadata of ${p[$project]} failed!"; stop; exit 1
fi
# ---------------------------- GET ROWS -------------------------------------- # # -------------------------- GET ROWCOUNT ------------------------------------ #
# print total number of rows (requires jq) # print total number of rows (requires jq)
project="example1"
echo "total number of rows in project example1..." echo "total number of rows in project example1..."
curl -fsS --get \ if curl -fsS --get \
--data project="${p[example1]}" \ --data project="${p[$project]}" \
"${endpoint}/command/core/get-rows" \ "${endpoint}/command/core/get-rows" \
| "${jq}" -r '.total' \ | "${jq}" -r '.total'
|| { stop; exit 1; } then
echo echo
else
echo 1>&2 "ERROR: getting rowcount of ${p[$project]} failed!"; stop; exit 1
fi
# -------------------------- GET COLUMNS ------------------------------------- # # -------------------------- GET COLUMNS ------------------------------------- #
# print columns (requires jq) # print columns (requires jq)
project="example1"
echo "column names of project example1..." echo "column names of project example1..."
curl -fsS --get \ if curl -fsS --get \
--data project="${p[example1]}" \ --data project="${p[$project]}" \
"${endpoint}/command/core/get-models" \ "${endpoint}/command/core/get-models" \
| "${jq}" -r '.columnModel | .columns[] | .name' \ | "${jq}" -r '.columnModel | .columns[] | .name'
|| { stop; exit 1; } then
echo echo
else
echo 1>&2 "ERROR: getting columns of ${p[$project]} failed!"; stop; exit 1
fi
# ---------------------- GET OPERATIONS HISTORY ------------------------------ # # ---------------------- GET OPERATIONS HISTORY ------------------------------ #
# save operations history to file (requires jq) # save operations history to file (requires jq)
project="example1"
output="${workspace}/example1_history.json" output="${workspace}/example1_history.json"
echo "operations history for project example1..." echo "history of operations for project example1..."
curl -fsS --get \ if curl -fsS --get \
--data project="${p[example1]}" \ --data project="${p[$project]}" \
"${endpoint}/command/core/get-operations" \ "${endpoint}/command/core/get-operations" \
| "${jq}" '[ .entries[] | .operation ]' \ | "${jq}" '[ .entries[] | .operation ]' \
> "${output}" \ > "${output}"
|| { stop; exit 1; } \ then
&& log "saved to file ${output}" log "ops history of ${p[$project]} saved to ${output}"
echo echo
else
echo 1>&2 "ERROR: getting ops history of ${p[$project]} failed!"; stop; exit 1
fi
# ------------------------ GET IMPORT History -------------------------------- # # ------------------------ GET IMPORT History -------------------------------- #
# print import options history (requires jq) # print import options history (requires jq)
echo "print import options history for project example2..." project="example2"
curl -fsS --get \ echo "history of import for project example2..."
--data project="${p[example2]}" \ if curl -fsS --get \
--data project="${p[$project]}" \
"${endpoint}/command/core/get-project-metadata" \ "${endpoint}/command/core/get-project-metadata" \
| "${jq}" ".importOptionMetadata[0]" \ | "${jq}" ".importOptionMetadata[0]"
|| { stop; exit 1; } then
echo echo
else
echo 1>&2 "ERROR: getting imp history of ${p[$project]} failed!"; stop; exit 1
fi
# ------------------------- DELETE project ----------------------------------- # # ------------------------- DELETE project ----------------------------------- #
# delete project # delete project
project="example1"
echo "delete project example1..." echo "delete project example1..."
curl -fsS \ if curl -fsS \
--data project="${p[example1]}" \ --data project="${p[$project]}" \
"${endpoint}/command/core/delete-project?csrf_token=$(csrf)" \ "${endpoint}/command/core/delete-project?csrf_token=$(csrf)"
|| { stop; exit 1; } then
echo; echo log "${p[$project]} deleted"
echo
else
echo 1>&2 "ERROR: deletion of ${p[$project]} failed!"; stop; exit 1
fi
# --------------------------- STOP SERVER ------------------------------------ # # --------------------------- STOP SERVER ------------------------------------ #