Created
September 26, 2016 19:34
-
-
Save heyseus1/3ee0807c5710f37208b13af977880973 to your computer and use it in GitHub Desktop.
hacky way to gather logs for mulesoft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~#!/bin/bash | |
# API log call | |
##### SUBJECT TO CHANGE!!!!!!####### | |
# Matthew Morcaldi 2016 | |
show_menu(){ | |
NORMAL=`echo "\033[m"` | |
MENU=`echo "\033[36m"` #Blue | |
NUMBER=`echo "\033[33m"` #yellow | |
FGRED=`echo "\033[41m"` | |
RED_TEXT=`echo "\033[31m"` | |
ENTER_LINE=`echo "\033[33m"` | |
echo -e "${MENU}---------------------------------------------${NORMAL}" | |
echo -e "${MENU}** please run step 1 before selecting other options, tokens expire!" | |
echo -e "${MENU}**${NUMBER} 1)${MENU} login ${NORMAL}" | |
echo -e "${MENU}**${NUMBER} 2)${MENU} show all orginizations ${NORMAL}" | |
echo -e "${MENU}**${NUMBER} 3)${MENU} show all environments ${NORMAL}" | |
echo -e "${MENU}**${NUMBER} 4)${MENU} list atlassian environment apps menu ${NORMAL}" | |
echo -e "${MENU}**${NUMBER} 5)${MENU} list API Modelers apps menu ${NORMAL}" | |
echo -e "${MENU}**${NUMBER} 6)${MENU} list Salestech apps menu ${NORMAL}" | |
echo -e "${MENU}---------------------------------------------${NORMAL}" | |
echo -e "${ENTER_LINE}Please enter a menu option and enter or ${RED_TEXT}enter to exit. ${NORMAL}" | |
read opt | |
} | |
show_menu2(){ | |
NORMAL=`echo "\033[m"` | |
MENU=`echo "\033[36m"` #Blue | |
NUMBER=`echo "\033[33m"` #yellow | |
FGRED=`echo "\033[41m"` | |
RED_TEXT=`echo "\033[31m"` | |
ENTER_LINE=`echo "\033[33m"` | |
echo -e "${MENU}---------------------------------------------${NORMAL}" | |
echo -e "${MENU}**${NUMBER} 7)${MENU} Business Systems Development ${NORMAL}" | |
echo -e "${MENU}**${NUMBER} 8)${MENU} Business Systems Production ${NORMAL}" | |
echo -e "${MENU}**${NUMBER} 9)${MENU} People Systems Development ${NORMAL}" | |
echo -e "${MENU}**${NUMBER} 10)${MENU} Sales Tech ${NORMAL}" | |
echo -e "${MENU}**${NUMBER} back)${MENU} return to main menu ${NORMAL}" | |
echo -e "${MENU}---------------------------------------------${NORMAL}" | |
echo -e "${ENTER_LINE}Please enter a menu option and enter or ${RED_TEXT}enter to exit. ${NORMAL}" | |
read opt | |
} | |
show_menu3(){ | |
NORMAL=`echo "\033[m"` | |
MENU=`echo "\033[36m"` #Blue | |
NUMBER=`echo "\033[33m"` #yellow | |
FGRED=`echo "\033[41m"` | |
RED_TEXT=`echo "\033[31m"` | |
ENTER_LINE=`echo "\033[33m"` | |
echo -e "${MENU}---------------------------------------------${NORMAL}" | |
echo -e "${MENU}**${NUMBER} 11)${MENU} API Modeling Development ${NORMAL}" | |
echo -e "${MENU}**${NUMBER} back)${MENU} return to main menu ${NORMAL}" | |
echo -e "${MENU}---------------------------------------------${NORMAL}" | |
echo -e "${ENTER_LINE}Please enter a menu option and enter or ${RED_TEXT}enter to exit. ${NORMAL}" | |
read opt | |
} | |
show_menu4(){ | |
NORMAL=`echo "\033[m"` | |
MENU=`echo "\033[36m"` #Blue | |
NUMBER=`echo "\033[33m"` #yellow | |
FGRED=`echo "\033[41m"` | |
RED_TEXT=`echo "\033[31m"` | |
ENTER_LINE=`echo "\033[33m"` | |
echo -e "${MENU}---------------------------------------------${NORMAL}" | |
echo -e "${MENU}**${NUMBER} 12)${MENU} API Modeling Development ${NORMAL}" | |
echo -e "${MENU}**${NUMBER} back)${MENU} return to main menu ${NORMAL}" | |
echo -e "${MENU}---------------------------------------------${NORMAL}" | |
echo -e "${ENTER_LINE}Please enter a menu option and enter or ${RED_TEXT}enter to exit. ${NORMAL}" | |
read opt | |
} | |
function access_token(){ | |
curl -ik -d "username=`cat username`&password=`cat auth`" "https://anypoint.mulesoft.com/accounts/login" | egrep -i "access_token" | awk '{ print $2 }' | perl -p -e 's/",//g;s/"//g' | openssl enc -base64 > hash | |
echo `cat hash` | openssl enc -base64 -d > access_token.txt | |
cat access_token.txt | |
} | |
function orginizations(){ | |
curl -H "Authorization: Bearer `cat access_token.txt`" https://anypoint.mulesoft.com/accounts/api/me | \ | |
egrep "id|Atlassian|SalesTech|APIModelers" | egrep -vi 'parent|last|first|idprovider' | \ | |
uniq -u | tail -6 | awk '{ print $2}' | perl -p -e 's/",//g;s/"//g' | |
} | |
function atlassian(){ | |
curl -H "Authorization: Bearer `cat access_token.txt`" https://anypoint.mulesoft.com/accounts/api/organizations/a9bf284c-b082-4c83-b05a-a237483430a3/environments | \ | |
egrep -i "id|name" | egrep -v organization | perl -p -e 's/",//g;s/"//g' | |
} | |
function api_modelers(){ | |
curl -H "Authorization: Bearer `cat access_token.txt`" https://anypoint.mulesoft.com/accounts/api/organizations/aec04b1f-e64e-4211-bfe1-90593f2f8bc7/environments | \ | |
egrep -i "id|name" | egrep -v organization | perl -p -e 's/",//g;s/"//g' | |
} | |
function sales_tech(){ | |
curl -H "Authorization: Bearer `cat access_token.txt`" https://anypoint.mulesoft.com/accounts/api/organizations/4e55743c-f65e-4011-b886-aeb396e131e6/environments | \ | |
egrep -i "id|name" | egrep -v organization | perl -p -e 's/",//g;s/"//g' | |
} | |
function environments(){ | |
atlassian | |
api_modelers | |
sales_tech | |
} | |
function bizsystemsdevelopment_atlassian(){ | |
curl -H "Authorization: Bearer `cat access_token.txt`" https://anypoint.mulesoft.com/accounts/api/organizations/a9bf284c-b082-4c83-b05a-a237483430a3/environments | \ | |
egrep -i "id|biz" | head -1 | awk '{ print $2 }' | perl -p -e 's/",//g;s/"//g' > bizsysdev.txt | |
curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/applications > bizsysdev.json | |
cat bizsysdev.json | jq '.[].domain' | |
bizsystemsdevelopment_atlassian_apps | |
} | |
function bizsystemsdevelopment_atlassian_apps() { | |
PS3='Please enter your choice: ' | |
options=("atl-dev-billing-app" "preceda-to-baml-dev" "atl-coupa-app-dev" "atl-aria-kinesis-app" "atlprecedabaml" "atl-expensify-app-dev" "atl-deve2e-billing-app" "atl-anaplan-app-dev" "kryo-issue" "atl-dlq-monitors" "quit") | |
select opt in "${options[@]}" | |
do | |
case $opt in | |
"atl-dev-billing-app") | |
curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/atl-dev-billing-app/deployments | jq '.[]' | egrep "deploymentId" | awk '{ print $2 }' | perl -p -e 's/",//g;s/"//g' > deployments.txt | |
for i in `cat deployments.txt`; do printf $i | curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/atl-dev-billing-app/deployments/$i/logs ; done > atl-dev-billing-app-logs-`date '+%Y-%m-%d-%H:%M:%S'`.json | |
cat atl-dev-billing-app-`date '+%Y-%m-%d'`.json | jq '.' | |
break | |
show_menu2 | |
;; | |
"preceda-to-baml-dev") | |
curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/preceda-to-baml-dev/deployments | jq '.[]' | egrep "deploymentId" | awk '{ print $2 }' | perl -p -e 's/",//g;s/"//g' > deployments.txt | |
for i in `cat deployments.txt`; do printf $i | curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/preceda-to-baml-dev/deployments/$i/logs ; done > preceda-to-baml-dev-logs-`date '+%Y-%m-%d-%H:%M:%S'`.json | |
cat preceda-to-baml-dev-`date '+%Y-%m-%d'`.json | jq '.' | |
break | |
show_menu2 | |
;; | |
"atl-coupa-app-dev") | |
curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/atl-coupa-app-dev/deployments | jq '.[]' | egrep "deploymentId" | awk '{ print $2 }' | perl -p -e 's/",//g;s/"//g' > deployments.txt | |
for i in `cat deployments.txt`; do printf $i | curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/atl-coupa-app-dev/deployments/$i/logs ; done > atl-coupa-app-dev-logs-`date '+%Y-%m-%d-%H:%M:%S'`.json | |
cat atl-coupa-app-dev-`date '+%Y-%m-%d'`.json | jq '.' | |
break | |
show_menu2 | |
;; | |
"atl-aria-kinesis-app") | |
curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/atl-aria-kinesis-app/deployments | jq '.[]' | egrep "deploymentId" | awk '{ print $2 }' | perl -p -e 's/",//g;s/"//g' > deployments.txt | |
for i in `cat deployments.txt`; do printf $i | curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/atl-aria-kinesis-app/deployments/$i/logs ; done > atl-aria-kinesis-app-logs-`date '+%Y-%m-%d-%H:%M:%S'`.json | |
cat atl-aria-kinesis-app-`date '+%Y-%m-%d'`.json | jq '.' | |
break | |
show_menu2 | |
;; | |
"atlprecedabaml") | |
curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/atlprecedabaml/deployments | jq '.[]' | egrep "deploymentId" | awk '{ print $2 }' | perl -p -e 's/",//g;s/"//g' > deployments.txt | |
for i in `cat deployments.txt`; do printf $i | curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/atlprecedabaml/deployments/$i/logs ; done > atlprecedabaml-logs-`date '+%Y-%m-%d-%H:%M:%S'`.json | |
cat atlprecedabaml-`date '+%Y-%m-%d'`.json | jq '.' | |
break | |
show_menu2 | |
;; | |
"atl-expensify-app-dev") | |
curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/atl-expensify-app-dev/deployments | jq '.[]' | egrep "deploymentId" | awk '{ print $2 }' | perl -p -e 's/",//g;s/"//g' > deployments.txt | |
for i in `cat deployments.txt`; do printf $i | curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/atl-expensify-app-dev/deployments/$i/logs ; done > atl-expensify-app-dev-logs-`date '+%Y-%m-%d-%H:%M:%S'`.json | |
cat atl-expensify-app-dev-`date '+%Y-%m-%d'`.json | jq '.' | |
break | |
show_menu2 | |
;; | |
"atl-deve2e-billing-app") | |
curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/atl-deve2e-billing-app/deployments | jq '.[]' | egrep "deploymentId" | awk '{ print $2 }' | perl -p -e 's/",//g;s/"//g' > deployments.txt | |
for i in `cat deployments.txt`; do printf $i | curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/atl-deve2e-billing-app/deployments/$i/logs ; done > atl-deve2e-billing-app-logs-`date '+%Y-%m-%d-%H:%M:%S'`.json | |
cat atl-deve2e-billing-app-`date '+%Y-%m-%d'`.json | jq '.' | |
break | |
show_menu2 | |
;; | |
"atl-anaplan-app-dev") | |
curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/atl-anaplan-app-dev/deployments | jq '.[]' | egrep "deploymentId" | awk '{ print $2 }' | perl -p -e 's/",//g;s/"//g' > deployments.txt | |
for i in `cat deployments.txt`; do printf $i | curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/atl-anaplan-app-dev/deployments/$i/logs ; done > atl-anaplan-app-dev-logs-`date '+%Y-%m-%d-%H:%M:%S'`.json | |
cat atl-anaplan-app-dev-`date '+%Y-%m-%d'`.json | jq '.' | |
break | |
show_menu2 | |
;; | |
"kryo-issue") | |
curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/kryo-issue/deployments | jq '.[]' | egrep "deploymentId" | awk '{ print $2 }' | perl -p -e 's/",//g;s/"//g' > deployments.txt | |
for i in `cat deployments.txt`; do printf $i | curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/kryo-issue/deployments/$i/logs ; done > kryo-issue-logs-`date '+%Y-%m-%d-%H:%M:%S'`.json | |
cat kryo-issue-`date '+%Y-%m-%d'`.json | jq '.' | |
break | |
show_menu2 | |
;; | |
"atl-dlq-monitors") | |
curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/atl-dlq-monitors/deployments | jq '.[]' | egrep "deploymentId" | awk '{ print $2 }' | perl -p -e 's/",//g;s/"//g' > deployments.txt | |
for i in `cat deployments.txt`; do printf $i | curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/v2/applications/atl-dlq-monitors/deployments/$i/logs ; done > atl-dlq-monitors-logs-`date '+%Y-%m-%d-%H:%M:%S'`.json | |
cat atl-dlq-monitors-`date '+%Y-%m-%d'`.json | jq '.' | |
break | |
show_menu2 | |
;; | |
"quit") | |
break | |
;; | |
*) echo invalid option;; | |
esac | |
done | |
} | |
function bizsystemsproduction_atlassian(){ | |
curl -H "Authorization: Bearer `cat access_token.txt`" https://anypoint.mulesoft.com/accounts/api/organizations/a9bf284c-b082-4c83-b05a-a237483430a3/environments | \ | |
egrep -i '"id": "a' | egrep -v "organization" | awk '{ print $2 }' | perl -p -e 's/",//g;s/"//g' > bizsysprod.txt | |
curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat bizsysprod.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/applications > bizsysprod.json | |
rm bizsysprod.txt | |
cat bizsysprod.json | jq '.[].domain' | |
} | |
function peoplesystemsdevelopment_atlassian(){ | |
curl -H "Authorization: Bearer `cat access_token.txt`" https://anypoint.mulesoft.com/accounts/api/organizations/a9bf284c-b082-4c83-b05a-a237483430a3/environments | \ | |
egrep -i '"id": "0084'| awk '{ print $2 }' | perl -p -e 's/",//g;s/"//g' > peoplesysdev.txt | |
curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat peoplesysdev.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/applications > peoplesysdev.json | |
rm peoplesysdev.txt | |
cat peoplesysdev.json | jq '.[].domain' > apps.txt | |
} | |
function salestech_atlassian(){ | |
curl -H "Authorization: Bearer `cat access_token.txt`" https://anypoint.mulesoft.com/accounts/api/organizations/a9bf284c-b082-4c83-b05a-a237483430a3/environments | \ | |
egrep -i '"id": "ec205'| awk '{ print $2 }' | perl -p -e 's/",//g;s/"//g' > salestech_atl.txt | |
curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat salestech_atl.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/applications > salestech_atl.json | |
rm salestech_atl.txt | |
cat salestech_atl.json | jq '.[].domain' | |
} | |
function apimodelingdevelopment_apimodelers(){ | |
curl -H "Authorization: Bearer `cat access_token.txt`" https://anypoint.mulesoft.com/accounts/api/organizations/aec04b1f-e64e-4211-bfe1-90593f2f8bc7/environments | \ | |
egrep -i '"id": "aa1c3'| awk '{ print $2 }' | perl -p -e 's/",//g;s/"//g' > apimoddev_apimod.txt | |
curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat apimoddev_apimod.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/applications > apimodelingdevelopment_apimodelers.json | |
rm apimoddev_apimod.txt | |
cat apimoddev_apimod.json | jq '.[].domain' | |
} | |
function production_salestech(){ | |
curl -H "Authorization: Bearer `cat access_token.txt`" https://anypoint.mulesoft.com/accounts/api/organizations/4e55743c-f65e-4011-b886-aeb396e131e6/environments | \ | |
egrep -i '"id": "e418e'| awk '{ print $2 }' | perl -p -e 's/",//g;s/"//g' > production_salestech.txt | |
curl -H "Authorization: Bearer `cat access_token.txt`" -H "X-ANYPNT-ENV-ID:`cat production_salestech.txt`" -X GET https://anypoint.mulesoft.com/cloudhub/api/applications > production_salestech.json | |
rm production_salestech.txt | |
cat production_salestech.json | jq '.[].domain' | |
} | |
function option_picked() { | |
COLOR='\033[01;31m' # bold red | |
RESET='\033[00;00m' # normal white | |
MESSAGE=${@:-"${RESET}Error: No message passed"} | |
echo -e "${COLOR}${MESSAGE}${RESET}" | |
} | |
clear | |
show_menu | |
while [ opt != '' ] | |
do | |
if [[ $opt = "" ]]; then | |
exit; | |
else | |
case $opt in | |
1) clear; | |
option_picked "logging in one moment..."; | |
access_token; #access token | |
echo -e "above is your access token" | |
show_menu; | |
;; | |
2) clear; | |
option_picked "generating list of orginization's environment IDs..."; | |
orginizations; #orginization's environment ID | |
show_menu; | |
;; | |
3) clear; | |
option_picked "generating list of environments"; | |
environments; #display all environments | |
show_menu; | |
;; | |
4) clear; | |
option_picked "sub menu selected type back to return to main menu"; | |
show_menu2 ; #display atlassian apps | |
;; | |
5) clear; | |
option_picked "sub menu selected type back to return to main menu"; | |
show_menu3 ; #display APIModelers apps | |
;; | |
6) clear; | |
option_picked "sub menu selected type back to return to main menu"; | |
show_menu4 ; #display SalesTech apps | |
;; | |
7) clear; | |
option_picked "Option 7 Selected"; | |
bizsystemsdevelopment_atlassian ; #null | |
show_menu; | |
;; | |
8) clear; | |
option_picked "Option 8 Selected"; | |
bizsystemsproduction_atlassian ; #null | |
show_menu; | |
;; | |
9) clear; | |
option_picked "Option 9 Selected"; | |
peoplesystemsdevelopment_atlassian ; #null | |
show_menu; | |
;; | |
10) clear; | |
option_picked "Option 10 Selected"; | |
salestech_atlassian ; #null | |
show_menu; | |
;; | |
back) clear; | |
option_picked "returning to main menu"; | |
show_menu ; #null | |
;; | |
11) clear; | |
option_picked "Option 11 Selected"; | |
apimodelingdevelopment_apimodelers ; #null | |
show_menu; | |
;; | |
12) clear; | |
option_picked "Option 12 Selected"; | |
production_salestech ; #null | |
show_menu; | |
;; | |
x)exit; | |
;; | |
\n)exit; | |
;; | |
*)clear; | |
option_picked "Pick an option from the menu"; | |
show_menu; | |
;; | |
esac | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment