#!/bin/bash # Test Portainer Edge API endpoints echo "🚀 Testing Portainer Edge API" echo "URL: $PORTAINER_URL" echo "API Key: ***${PORTAINER_API_KEY: -4}" echo "" # Test edge environments echo "🌐 Testing Edge Environments..." curl -s -H "X-API-Key: $PORTAINER_API_KEY" \ "$PORTAINER_URL/api/endpoints?types=4" | jq '.[] | select(.Type == 4) | {name: .Name, id: .Id, status: .Status}' 2>/dev/null || echo "No edge environments found or jq not installed" echo "" # Test edge groups echo "👥 Testing Edge Groups..." curl -s -H "X-API-Key: $PORTAINER_API_KEY" \ "$PORTAINER_URL/api/edge_groups" | jq '.[0:3] | .[] | {name: .Name, id: .Id, dynamic: .Dynamic}' 2>/dev/null || echo "No edge groups found or jq not installed" echo "" # Test edge stacks echo "📚 Testing Edge Stacks..." curl -s -H "X-API-Key: $PORTAINER_API_KEY" \ "$PORTAINER_URL/api/edge_stacks" | jq '.[0:3] | .[] | {name: .Name, id: .Id, groups: .EdgeGroups}' 2>/dev/null || echo "No edge stacks found or jq not installed" echo "" # Test edge jobs echo "💼 Testing Edge Jobs..." curl -s -H "X-API-Key: $PORTAINER_API_KEY" \ "$PORTAINER_URL/api/edge_jobs" | jq '.[0:3] | .[] | {name: .Name, id: .Id, recurring: .Recurring}' 2>/dev/null || echo "No edge jobs found or jq not installed" echo "" # Test edge settings echo "⚙️ Testing Edge Settings..." curl -s -H "X-API-Key: $PORTAINER_API_KEY" \ "$PORTAINER_URL/api/settings" | jq '.Edge | {checkin: .CheckinInterval, command: .CommandInterval, ping: .PingInterval}' 2>/dev/null || echo "Failed to get edge settings or jq not installed" echo "" echo "✅ Edge API test completed!"