@@ -98,6 +98,69 @@ function recursiveSource {
9898 done
9999 fi
100100}
101+ function apiCall {
102+ local OPTS
103+ while getopts " X:d:" opt " $@ " ;
104+ do
105+ case " ${opt} " in
106+ X)
107+ METHOD=${OPTARG}
108+ ;;
109+ d)
110+ PAYLOAD=${OPTARG}
111+ ;;
112+ esac
113+ done
114+ shiftOptInd
115+ shift $SHIFTS
116+ ENDPOINT=$1
117+ debug " Unparsed endpoint is $ENDPOINT "
118+ debug " Unparsed payload is $PAYLOAD "
119+ shift
120+ OLDIFS=$IFS
121+ IFS=" \$ "
122+ for MATCH in $PAYLOAD ; do
123+ if [ " ${MATCH:: 1} " = " {" ] ; then
124+ MATCH=${MATCH: 1}
125+ OPT=${MATCH%% \} * } :
126+ OPTS=" ${OPTS}${OPT} "
127+ fi
128+ done ;
129+ for MATCH in $ENDPOINT ; do
130+ if [ " ${MATCH:: 1} " = " {" ] ; then
131+ MATCH=${MATCH: 1}
132+ OPT=${MATCH%% \} * } :
133+ OPTS=" ${OPTS}${OPT} "
134+ fi
135+ done ;
136+ IFS=$OLDIFS
137+ if [ -n " $OPTS " ] ; then
138+ while getopts ${OPTS} opt;
139+ do
140+ PAYLOAD=${PAYLOAD// \$\{ $opt \} / $OPTARG }
141+ ENDPOINT=${ENDPOINT// \$\{ $opt \} / $OPTARG }
142+ done
143+ shiftOptInd
144+ shift $SHIFTS
145+ fi
146+ while [[ $ENDPOINT =~ \$ {[^}]* } ]] ; do
147+ if [ -z " $1 " ] ; then
148+ error " Please provide an argument for paramater -${BASH_REMATCH: 2: 1} "
149+ return ;
150+ fi
151+ ENDPOINT=${ENDPOINT// ${BASH_REMATCH[0]} / $1 }
152+ shift
153+ done
154+ debug " Call Controller: -X $METHOD -d $PAYLOAD $ENDPOINT "
155+ if [ -n " $PAYLOAD " ] ; then
156+ controller_call -X $METHOD -d $PAYLOAD $ENDPOINT
157+ else
158+ controller_call -X $METHOD $ENDPOINT
159+ fi
160+ }
161+ # __call GET "/controller/rest/applications/\${a}/business-transactions" -a ECommerce
162+ # echo "########"
163+ # __call GET "/controller/rest/applications/\${a}/nodes/\${n}" -n Web2 -a ECommerce
101164function _config {
102165 local FORCE=0
103166 local GLOBAL=0
@@ -272,7 +335,7 @@ function controller_call {
272335 COMMAND_RESULT=$( httpClient -s -b $CONFIG_CONTROLLER_COOKIE_LOCATION \
273336 -X $METHOD \
274337 -H " X-CSRF-TOKEN: $XCSRFTOKEN " \
275- " ` [ -z " $FORM " ] && echo -H " Content- Type: application/json;charset=UTF-8" ` " \
338+ " $( [ -z " $FORM " ] && echo " -HContent- Type: application/json;charset=UTF-8" ) " \
276339 -H " Accept: application/json, text/plain, */*" \
277340 " ` [ -n " $PAYLOAD " ] && echo -d ${PAYLOAD} ` " \
278341 " ` [ -n " $FORM " ] && echo -F ${FORM} ` " \
@@ -447,18 +510,26 @@ describe application_export << EOF
447510Export a application from the controller. Specifiy the application id as parameter.
448511EOF
449512function bt_list {
450- local APPLICATION_ID=$*
451- if [[ $APPLICATION_ID =~ ^[0-9]+$ ]]; then
452- controller_call /controller/rest/applications/${APPLICATION_ID} /business-transactions
453- else
454- COMMAND_RESULT=" "
455- error " This is not a number: '$APPLICATION_ID '"
456- fi
513+ apiCall -X GET " /controller/rest/applications/\$ {a}/business-transactions" " $@ "
457514}
458515register bt_list List all business transactions for a given application
459516describe bt_list << EOF
460517List all business transactions for a given application. Provide the application id as parameter.
461518EOF
519+ function tier_list {
520+ apiCall -X GET " /controller/rest/applications/\$ {a}/tiers" " $@ "
521+ }
522+ register tier_list List all tiers for a given application
523+ describe tier_list << EOF
524+ List all tiers for a given application. Provide the application id as parameter.
525+ EOF
526+ function tier_get {
527+ apiCall -X GET " /controller/rest/applications/\$ {a}/tiers/\$ {t}" " $@ "
528+ }
529+ register tier_get Retrieve Tier Information by Tier Name
530+ describe tier_get << EOF
531+ Retrieve Tier Information by Tier Name. Provide the application and the tier as parameters
532+ EOF
462533function metric_list {
463534 local APPLICATION=${CONFIG_CONTROLLER_DEFAULT_APPLICATION}
464535 local METRIC_PATH=" "
@@ -643,13 +714,7 @@ describe dbmon_list << EOF
643714List all database collectors
644715EOF
645716function dbmon_delete {
646- local COLLECTOR_ID=$*
647- if [[ $COLLECTOR_ID =~ ^[0-9]+$ ]]; then
648- controller_call -X POST -d " [$COLLECTOR_ID ]" /controller/restui/databases/collectors/configuration/batchDelete
649- else
650- COMMAND_RESULT=" "
651- error " This is not a number: '$COLLECTOR_ID '"
652- fi
717+ apiCall -X POST -d " [\$ {c}]" /controller/restui/databases/collectors/configuration/batchDelete " $@ "
653718}
654719register dbmon_delete Delete a database collector
655720describe dbmon_delete << EOF
0 commit comments