parse historyResponse
This commit is contained in:
parent
51c15ea0e0
commit
c7d5273b1c
14
orcli
14
orcli
|
@ -889,9 +889,9 @@ orcli_transform_command() {
|
|||
# read each operation into one line
|
||||
mapfile -t jsonlines < <(jq -c '.[]' "${files[$i]}")
|
||||
for line in "${jsonlines[@]}"; do
|
||||
# parse operation into curl options
|
||||
# parse one line/operation into array
|
||||
declare -A data="($(echo "$line" | jq -r 'to_entries | map("[\(.key)]=" + @sh "\(.value|tostring)") | .[]'))"
|
||||
# map operation name to command
|
||||
# map operation names to command endpoints
|
||||
com="${data[op]#core/}"
|
||||
if [[ $com == "row-reorder" ]]; then com="reorder-rows"; fi
|
||||
unset "data[op]"
|
||||
|
@ -900,17 +900,17 @@ orcli_transform_command() {
|
|||
unset "data[engineConfig]"
|
||||
# drop description
|
||||
unset "data[description]"
|
||||
# prepare curl options
|
||||
mapfile -t curloptions < <(for K in "${!data[@]}"; do
|
||||
echo "--data"
|
||||
echo "$K=${data[$K]}"
|
||||
done)
|
||||
# get project id and csrf token; post data to it's individual endpoint
|
||||
set -x
|
||||
# debug: remove -fs
|
||||
if ! curl --data "project=$(get_id "${args[project]}")" "${curloptions[@]}" "${OPENREFINE_URL}/command/core/${com}$(get_csrf)"; then
|
||||
error "applying ${op} from ${files[$i]} failed!"
|
||||
if response="$(curl -fs --data "project=$(get_id "${args[project]}")" "${curloptions[@]}" "${OPENREFINE_URL}/command/core/${com}$(get_csrf)")"; then
|
||||
log "applied ${com} to ${args[project]}" "Response: $(jq '.historyEntry.description' <<< "$response")"
|
||||
else
|
||||
error "applying ${com} from ${files[$i]} to ${args[project]} failed!"
|
||||
fi
|
||||
set +x
|
||||
unset data
|
||||
done
|
||||
done
|
||||
|
|
|
@ -31,9 +31,9 @@ for i in "${!files[@]}"; do
|
|||
# read each operation into one line
|
||||
mapfile -t jsonlines < <(jq -c '.[]' "${files[$i]}")
|
||||
for line in "${jsonlines[@]}"; do
|
||||
# parse operation into curl options
|
||||
# parse one line/operation into array
|
||||
declare -A data="($(echo "$line" | jq -r 'to_entries | map("[\(.key)]=" + @sh "\(.value|tostring)") | .[]'))"
|
||||
# map operation name to command
|
||||
# map operation names to command endpoints
|
||||
com="${data[op]#core/}"
|
||||
if [[ $com == "row-reorder" ]]; then com="reorder-rows"; fi
|
||||
unset "data[op]"
|
||||
|
@ -42,14 +42,16 @@ for i in "${!files[@]}"; do
|
|||
unset "data[engineConfig]"
|
||||
# drop description
|
||||
unset "data[description]"
|
||||
# prepare curl options
|
||||
mapfile -t curloptions < <(for K in "${!data[@]}"; do
|
||||
echo "--data"
|
||||
echo "$K=${data[$K]}"
|
||||
done)
|
||||
# get project id and csrf token; post data to it's individual endpoint
|
||||
# debug: remove -fs option temporarily
|
||||
if ! curl --data "project=$(get_id "${args[project]}")" "${curloptions[@]}" "${OPENREFINE_URL}/command/core/${com}$(get_csrf)"; then
|
||||
error "applying ${op} from ${files[$i]} failed!"
|
||||
if response="$(curl -fs --data "project=$(get_id "${args[project]}")" "${curloptions[@]}" "${OPENREFINE_URL}/command/core/${com}$(get_csrf)")"; then
|
||||
log "applied ${com} to ${args[project]}" "Response: $(jq '.historyEntry.description' <<< "$response")"
|
||||
else
|
||||
error "applying ${com} from ${files[$i]} to ${args[project]} failed!"
|
||||
fi
|
||||
unset data
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue