-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path27-admin.sh
More file actions
executable file
·84 lines (69 loc) · 2.7 KB
/
27-admin.sh
File metadata and controls
executable file
·84 lines (69 loc) · 2.7 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
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
#!/bin/bash
# Example 27: Admin API
# Manage API keys and view organization usage analytics (requires admin API key)
set -e
echo "=== DeepL CLI Example 27: Admin API ==="
echo
echo "Note: Admin API requires an admin-level API key."
echo "These commands manage developer keys and usage analytics for your organization."
echo
# Check if API key is configured
if ! deepl auth show &>/dev/null; then
echo "Error: API key not configured"
echo "Run: deepl auth set-key YOUR_API_KEY"
exit 1
fi
echo "API key configured"
echo
# 1. List API keys
echo "1. Listing API keys"
echo " Shows all developer API keys in your organization."
deepl admin keys list || echo " (Admin API access required)"
echo
# 2. List keys in JSON format
echo "2. JSON output format"
echo " Useful for scripting and automation..."
deepl admin keys list --format json || echo " (Admin API access required)"
echo
# 3. Create a new API key
echo "3. Creating a new API key (skipped in demo)"
echo ' Command: deepl admin keys create --label "My New Key"'
echo " This would create a new developer API key with the given label."
echo
# 4. Rename an API key
echo "4. Renaming an API key (skipped in demo)"
echo ' Command: deepl admin keys rename <key-id> "New Label"'
echo " This would update the label of an existing API key."
echo
# 5. Set usage limit
echo "5. Setting usage limits (skipped in demo)"
echo ' Command: deepl admin keys set-limit <key-id> 1000000'
echo ' Command: deepl admin keys set-limit <key-id> unlimited'
echo " This would set or remove character usage limits for a key."
echo
echo " Set STT (speech-to-text) limit:"
echo " deepl admin keys set-limit <key-id> 1000000 --stt-limit 3600000"
echo
echo " Deactivate a key (irreversible!):"
echo " deepl admin keys deactivate <key-id> --yes"
echo
# 6. View organization usage
echo "6. Viewing organization usage analytics"
echo " Shows translation usage across all keys for a date range."
deepl admin usage --start 2024-01-01 --end 2024-12-31 || echo " (Admin API access required)"
echo
# 7. Usage grouped by key
echo "7. Usage grouped by key"
echo " Groups usage data by individual API key."
deepl admin usage --start 2024-01-01 --end 2024-12-31 --group-by key || echo " (Admin API access required)"
echo
# 8. Usage grouped by key and day
echo "8. Usage grouped by key and day"
echo " Provides daily usage breakdown per key."
deepl admin usage --start 2024-01-01 --end 2024-01-31 --group-by key_and_day || echo " (Admin API access required)"
echo
# 9. Usage in JSON format
echo "9. Usage analytics in JSON format"
deepl admin usage --start 2024-01-01 --end 2024-12-31 --format json || echo " (Admin API access required)"
echo
echo "=== All examples completed successfully! ==="