-
Notifications
You must be signed in to change notification settings - Fork 0
/
clear_account.sh
executable file
·70 lines (59 loc) · 1.99 KB
/
clear_account.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
#!/usr/bin/env bash
echo "[opslevel] Deleting Services..."
services=$(opslevel list services -o json)
echo "$services" | jq -r '.[] | .id' | while read -r id; do
opslevel delete service "$id"
done
echo "[opslevel] Deleting Systems..."
systems=$(opslevel list systems -o json)
echo "$systems" | jq -r '.[] | .id' | while read -r id; do
opslevel delete system "$id"
done
echo "[opslevel] Deleting Domains..."
domains=$(opslevel list domains -o json)
echo "$domains" | jq -r '.[] | .id' | while read -r id; do
opslevel delete domain "$id"
done
echo "[opslevel] Deleting Infra..."
infra=$(opslevel list infra -o json)
echo "$infra" | jq -r '.[] | .id' | while read -r id; do
opslevel delete infra "$id"
done
echo "[opslevel] Deleting Teams (errors may occur that is ok)..."
while true; do
teams=$(opslevel list teams -o json)
count=$(echo "$teams" | jq '. | length')
if [ "$count" -eq 0 ]; then
echo "[opslevel] All teams deleted."
break
fi
echo "$teams" | jq -r '.[] | .Id' | while read -r id; do
opslevel delete team "$id"
done
sleep 2
done
echo "[opslevel] Deleting Users..."
users=$(opslevel list users -o json)
echo "$users" | jq -r '.[] | select(.Email | test("@example.com$")) | .Email' | while read -r id; do
opslevel delete user "$id"
done
echo "[opslevel] Deleting Checks..."
checks=$(opslevel list checks -o json)
echo "$checks" | jq -r '.[] | .Id' | while read -r id; do
opslevel delete check "$id"
done
echo "[opslevel] Deleting Rubric..."
categories=$(opslevel list category -o json)
echo "$categories" | jq -r '.[] | .id' | while read -r id; do
opslevel delete category "$id"
done
levels=$(opslevel list level -o json)
echo "$levels" | jq -r '.[] | select(.Index != 0) | .id' | while read -r id; do
opslevel delete level "$id"
done
echo "[opslevel] Deleting Integrations..."
integrations=$(opslevel list integrations -o json)
echo "$integrations" | jq -r '.[] | .id' | while read -r id; do
opslevel delete integration "$id"
done
echo "[opslevel] Clear Account Complete."