forked from crestalnetwork/intentkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.sh
More file actions
executable file
·37 lines (30 loc) · 947 Bytes
/
create.sh
File metadata and controls
executable file
·37 lines (30 loc) · 947 Bytes
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
#!/bin/bash
# If you want to visit a remote server, modify it
BASE_URL="http://localhost:8000"
# Token is not required in local, if you set the ADMIN_AUTH_ENABLED and ADMIN_JWT_SECRET in a remote server, you put key here
TOKEN=""
print_usage() {
echo "Usage: sh create.sh AGENT_ID"
exit 1
}
# Check if correct number of arguments provided
if [ $# -ne 1 ]; then
print_usage
fi
AGENT_ID="$1"
echo "Creating agent [${AGENT_ID}] ..."
# Using the provided create command with escaped JSON
HTTP_STATUS=$(curl -s -w "%{http_code}" \
-X POST \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"id\":\"${AGENT_ID}\"}" \
"${BASE_URL}/agents" -o "${AGENT_ID}.response")
if [ $HTTP_STATUS -ge 400 ]; then
echo "Create failed with HTTP status ${HTTP_STATUS}"
cat "${AGENT_ID}.response"
rm "${AGENT_ID}.response"
exit 1
fi
rm "${AGENT_ID}.response"
echo "Create succeeded"