-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtrello-analyze.sh
More file actions
55 lines (43 loc) · 1.74 KB
/
Copy pathtrello-analyze.sh
File metadata and controls
55 lines (43 loc) · 1.74 KB
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
#!/bin/bash
# Usage: ./analyze_trello.sh YOUR_API_KEY YOUR_TOKEN
API_KEY="$1"
API_TOKEN="$2"
if [[ -z "$API_KEY" || -z "$API_TOKEN" ]]; then
echo "Usage: $0 <API_KEY> <TOKEN>"
exit 1
fi
echo "🔍 Verifying credentials..."
ME_URL="https://api.trello.com/1/members/me?key=${API_KEY}&token=${API_TOKEN}"
ME_JSON=$(curl -s "$ME_URL")
USERNAME=$(echo "$ME_JSON" | jq -r '.username')
FULLNAME=$(echo "$ME_JSON" | jq -r '.fullName')
EMAIL=$(echo "$ME_JSON" | jq -r '.email // "N/A"')
ID_MEMBER=$(echo "$ME_JSON" | jq -r '.id')
echo "✅ Authenticated as: $FULLNAME (@$USERNAME)"
echo "📧 Email: $EMAIL"
echo "🆔 Trello Member ID: $ID_MEMBER"
echo
echo "🏢 Fetching organizations (workspaces)..."
ORG_URL="https://api.trello.com/1/members/me/organizations?key=${API_KEY}&token=${API_TOKEN}"
ORG_JSON=$(curl -s "$ORG_URL")
ORG_COUNT=$(echo "$ORG_JSON" | jq 'length')
if [[ "$ORG_COUNT" -eq 0 ]]; then
echo "No organizations found or access denied."
exit 0
fi
for (( i=0; i<ORG_COUNT; i++ )); do
ORG_ID=$(echo "$ORG_JSON" | jq -r ".[$i].id")
ORG_NAME=$(echo "$ORG_JSON" | jq -r ".[$i].name")
ORG_DISPLAY=$(echo "$ORG_JSON" | jq -r ".[$i].displayName")
ORG_DESC=$(echo "$ORG_JSON" | jq -r ".[$i].desc")
echo "-------------------------------------------"
echo "🏢 Workspace: $ORG_DISPLAY ($ORG_NAME)"
echo "📝 Description: ${ORG_DESC:-N/A}"
echo "👥 Members:"
curl -s "https://api.trello.com/1/organizations/${ORG_ID}/members?key=${API_KEY}&token=${API_TOKEN}" \
| jq -r '.[] | " - \(.fullName) (@\(.username)) [\(.memberType)]"'
echo "📋 Boards:"
curl -s "https://api.trello.com/1/organizations/${ORG_ID}/boards?key=${API_KEY}&token=${API_TOKEN}" \
| jq -r '.[] | " - \(.name) [\(.id)] (\(.prefs.permissionLevel))"'
echo
done