-
Notifications
You must be signed in to change notification settings - Fork 0
/
getMeta
executable file
·82 lines (70 loc) · 2.74 KB
/
getMeta
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
###################################################################################
# getMeta: Get metadata for a Cromwell workflow run #
# Copyright (C) 2023 Heather Ward - DNAstack #
# #
# This program is free software; you can redistribute it and/or #
# modify it under the terms of the GNU General Public License #
# as published by the Free Software Foundation, version 2 of the #
# License. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #
###################################################################################
IFS=$'\n'
set -euo pipefail
usage() {
cat << EOF
Get metadata for a given workflow
Defaults to using Cromwell running at localhost:8000
Set and export CROMWELL_URL to target a different Cromwell location
Usage: $(basename "${0}") [OPTIONS] workflow_id
OPTIONS
-h Display this message and exit
-r Raw output
-s Save to a file name \${wf_id}.meta.json rather than outputting to stdout
EOF
}
while getopts "hrs" OPTION; do
case ${OPTION} in
h) usage; exit 1;;
r) RAW=true;;
s) SAVE=true;;
\?) usage; exit 1;;
esac
done
RAW=${RAW:-}
SAVE=${SAVE:-}
CROMWELL_URL=${CROMWELL_URL:-localhost:8000}
if [[ "${#}" -eq 0 ]]; then
usage
err "Must provide workflow ID"
exit 1
else
WORKFLOW_ID=${*: -1}
fi
if [[ "${RAW}" == "true" ]]; then
curl \
-s \
-X GET \
-H "accept: application/json" \
"${CROMWELL_URL}/api/workflows/v1/${WORKFLOW_ID}/metadata?expandSubWorkflows=false"
elif [[ "${SAVE}" == "true" ]]; then
curl \
-X GET \
-H "accept: application/json" \
"${CROMWELL_URL}/api/workflows/v1/${WORKFLOW_ID}/metadata?expandSubWorkflows=false" \
--output "${WORKFLOW_ID}.meta.json"
else
curl \
-X GET \
-H "accept: application/json" \
"${CROMWELL_URL}/api/workflows/v1/${WORKFLOW_ID}/metadata?expandSubWorkflows=false" \
| jq
fi