-
Notifications
You must be signed in to change notification settings - Fork 1
/
clean-target-org.sh
executable file
·98 lines (84 loc) · 2.96 KB
/
clean-target-org.sh
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#! /bin/bash
gcloud config get project
export ORG=$X_ORG
echo ORG=$ORG
echo '*******************************************'
echo WARNING WARNING WARNING
echo This will attempt to remove all resources from the org, not just the ones that were imported!
echo WARNING WARNING WARNING
echo '*******************************************'
read -p "OK to proceed (Y/n)? " i
if [ "$i" != "Y" ]
then
echo aborted
exit 1
fi
echo Proceeding...
export TOKEN=$(gcloud auth print-access-token)
echo; echo Cleaning Developers also removes Apps
for DEVELOPER in $(apigeecli -t $TOKEN --org=$ORG developers list | jq -r .developer[].email)
do
echo DEVELOPER: $DEVELOPER
apigeecli -t $TOKEN --org=$ORG developers delete --email=$DEVELOPER
done
echo; echo Cleaning API Products
PRODUCTS=$(apigeecli -t $TOKEN --org=$ORG products list | jq .apiProduct[].name)
for PRODUCT in $(apigeecli -t $TOKEN --org=$ORG products list | jq .apiProduct[].name)
do
echo PRODUCT: $PRODUCT
apigeecli -t $TOKEN --org=$ORG products delete --name=$PRODUCT
done
echo; echo Cleaning Proxies
for API in $(apigeecli -t $TOKEN --org=$ORG apis list | jq -r .proxies[].name)
do
echo API: $API
apigeecli -t $TOKEN --org=$ORG apis delete --name=$API
done
echo; echo Cleaning SharedFlows
for SF in $(apigeecli -t $TOKEN --org=$ORG sharedflows list | jq -r .sharedFlows[].name)
do
echo SF: $SF
apigeecli -t $TOKEN --org=$ORG sharedflows delete --name=$SF
done
echo; echo Cleaning ORG KVMs
for KVM in $(apigeecli -t $TOKEN --org=$ORG kvms list | jq -r .[])
do
echo KVM: $KVM
apigeecli -t $TOKEN --org=$ORG kvms delete --name=$KVM
done
echo; echo Cleaning ENV KVMs
for ENV in $(apigeecli -t $TOKEN --org=$ORG environments list | jq -r .[])
do
echo ENV: $ENV
for KVM in $(apigeecli -t $TOKEN --org=$ORG --env=$ENV kvms list | jq -r .[])
do
echo ENV KVM: $KVM
apigeecli -t $TOKEN --org=$ORG --env=$ENV kvms delete --name=$KVM
done
done
PROXIES=$(apigeecli -t $TOKEN --org=$ORG apis list | jq -r .proxies[].name)
for PROXY in $PROXIES
do
KVMS=$(apigeecli -t $TOKEN --org=$ORG --proxy=$PROXY kvms list | jq -r .[])
if [ "$KVMS" != "" ]
then
echo PROXY KVMS: $PROXY ================================
for KVM in $KVMS
do
echo PROXY KVMS: $PROXY $KVM ================================
# echo apigeecli --org=$ORG --proxy=$PROXY kvms delete --name=$KVM
apigeecli -t $TOKEN --org=$ORG --proxy=$PROXY kvms delete --name=$KVM
done
fi
done
echo TARGETSERVERS ================================
for ENV in $(apigeecli -t $TOKEN --org=$ORG environments list | jq -r .[])
do
echo ENV TARGETSERVERS: $ENV ================================
for TS in $(apigeecli -t $TOKEN --org=$ORG --env=$ENV targetservers list | jq -r .[])
do
echo TS: $TS
# echo apigeecli --org=$ORG --env=$ENV targetservers delete --name=$TS
apigeecli -t $TOKEN --org=$ORG --env=$ENV targetservers delete --name=$TS
done
done