|
1 | 1 | #!/bin/bash |
2 | 2 | ACT_VERSION="v0.4.0" |
3 | | -ACT_LAST_COMMIT="05b09dfd00a013c4ec108156661cd20e8218bde2" |
| 3 | +ACT_LAST_COMMIT="43a2301ebe6ce3e819b9ac5a09a6fb0a3687c4a7" |
4 | 4 | USER_CONFIG="$HOME/.appdynamics/act/config.sh" |
5 | 5 | GLOBAL_CONFIG="/etc/appdynamics/act/config.sh" |
6 | 6 | CONFIG_CONTROLLER_COOKIE_LOCATION="/tmp/appdynamics-controller-cookie.txt" |
@@ -162,10 +162,12 @@ function dashboard_delete { apiCall -X POST -d '[{{i:dashboard_id}}]' '/controll |
162 | 162 | rde dashboard_delete "Delete a dashboard." "Provide a dashboard id (-i) as parameter" "-i 2" |
163 | 163 | function dashboard_export { apiCall '/controller/CustomDashboardImportExportServlet?dashboardId={{i:dashboard_id}}' "$@" ; } |
164 | 164 | rde dashboard_export "Export a dashboard." "Provide a dashboard id (-i) as parameter" "-i 2" |
| 165 | +function dashboard_import { apiCallExpand -X POST -F 'file={{d:dashboard}}' '/controller/CustomDashboardImportExportServlet' "$@" ; } |
| 166 | +rde dashboard_import "Import a dashboard." "Provide a dashboard file or json (-d) as parameter." "-d @examples/dashboard.json" |
165 | 167 | function dashboard_list { apiCall '/controller/restui/dashboards/getAllDashboardsByType/false' "$@" ; } |
166 | 168 | rde dashboard_list "List all dashboards." "This command requires no further arguments." "" |
167 | 169 | function dashboard_update { apiCall -X POST -d '{{f:dashboard_definition}}' '/controller/restui/dashboards/updateDashboard' "$@" ; } |
168 | | -rde dashboard_update "Update a dashboard." "Provide a dashboard file or json (-f) as parameter. Please not that the json you need to provide is not compatible with the export format." "-i 2" |
| 170 | +rde dashboard_update "Update a dashboard." "Provide a dashboard file or json (-f) as parameter. Please not that the json you need to provide is not compatible with the export format." "-d @dashboardUpdate.json" |
169 | 171 | doc dbmon << EOF |
170 | 172 | Use the Database Visibility API to get, create, update, and delete Database Visibility Collectors. |
171 | 173 | EOF |
@@ -612,19 +614,6 @@ Get installed version from controller |
612 | 614 | EOF |
613 | 615 | example controller_version << EOF |
614 | 616 | EOF |
615 | | -function dashboard_import { |
616 | | - FILE="$*" |
617 | | - if [ -r $FILE ] ; then |
618 | | - controller_call -X POST -F file=@$FILE /controller/CustomDashboardImportExportServlet |
619 | | - else |
620 | | - COMMAND_RESULT="" |
621 | | - error "File not found or not readable: $FILE" |
622 | | - fi |
623 | | -} |
624 | | -register dashboard_import Import a dashboard |
625 | | -describe dashboard_import << EOF |
626 | | -Import a dashboard from a given file |
627 | | -EOF |
628 | 617 | function actiontemplate_delete { |
629 | 618 | local TYPE="httprequest" |
630 | 619 | local ID=0 |
@@ -1442,6 +1431,44 @@ function recursiveSource { |
1442 | 1431 | done |
1443 | 1432 | fi |
1444 | 1433 | } |
| 1434 | +# Helper function to expand multiple files that are provided as payload |
| 1435 | +function apiCallExpand { |
| 1436 | + debug "Calling apiCallExpand" |
| 1437 | + local COUNTER=0 |
| 1438 | + local PREFIX="" |
| 1439 | + local SUFFIX="" |
| 1440 | + local LIST="" |
| 1441 | + declare -i COUNTER |
| 1442 | + for ARG in $*; do |
| 1443 | + if [ "${ARG:0:1}" = "@" ] && [ "${ARG:1}" != "$(echo ${ARG:1})" ] ; then |
| 1444 | + LIST=$(echo ${ARG:1}) |
| 1445 | + COUNTER=${COUNTER}+1 |
| 1446 | + elif [ "${COUNTER}" -eq "0" ]; then |
| 1447 | + PREFIX="${PREFIX} ${ARG}" |
| 1448 | + else |
| 1449 | + SUFFIX="${SUFFIX} ${ARG}" |
| 1450 | + fi; |
| 1451 | + done; |
| 1452 | + case "${COUNTER}" in |
| 1453 | + "0") |
| 1454 | + debug "apiCallExpand: No expansion" |
| 1455 | + apiCall "$@" |
| 1456 | + ;; |
| 1457 | + "1") |
| 1458 | + debug "apiCallExpand: With expansion" |
| 1459 | + local COMBINED_RESULT="" |
| 1460 | + for ELEMENT in ${LIST}; do |
| 1461 | + COMBINED_RESULT="${COMBINED_RESULT}${EOL}$(apiCall ${PREFIX} @${ELEMENT} ${SUFFIX})" |
| 1462 | + echo $COMBINED_RESULT |
| 1463 | + done; |
| 1464 | + COMMAND_RESULT=${COMBINED_RESULT} |
| 1465 | + ;; |
| 1466 | + *) |
| 1467 | + error "You can only provide one file list for expansion." |
| 1468 | + COMMAND_RESULT="" |
| 1469 | + ;; |
| 1470 | + esac |
| 1471 | +} |
1445 | 1472 | function apiCall { |
1446 | 1473 | local OPTS |
1447 | 1474 | local OPTIONAL_OPTIONS="" |
@@ -1563,7 +1590,7 @@ function apiCall { |
1563 | 1590 | CONTROLLER_ARGS+=("-B") |
1564 | 1591 | debug "Using basic http authentication" |
1565 | 1592 | fi; |
1566 | | - if [ -n "$PAYLOAD" ] ; then |
| 1593 | + if [ -n "${PAYLOAD}" ] ; then |
1567 | 1594 | if [ "${PAYLOAD:0:1}" = "@" ] ; then |
1568 | 1595 | debug "Loading payload from file ${PAYLOAD:1}" |
1569 | 1596 | if [ -r "${PAYLOAD:1}" ] ; then |
|
0 commit comments