#!/bin/bash
# Gradual traffic switching automation
# Switches traffic in increments with validation pauses
ORG_ID="your-org-id"
ENV_ID="your-env-id"
DEPLOYMENT_ID="your-deployment-id"
TOKEN="your-access-token"
BASE_URL="https://anypoint.mulesoft.com/amc/application-manager/api/v2"
for PERCENT in 10 25 50 75 100; do
echo "Switching to ${PERCENT}% traffic..."
curl -X PUT \
"${BASE_URL}/organizations/${ORG_ID}/environments/${ENV_ID}/deployments/${DEPLOYMENT_ID}/upgradedata/trafficswitching" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"switchedTraffic\": ${PERCENT}}"
echo "Traffic at ${PERCENT}%. Monitor for errors before you proceed."
echo "Press Enter to continue to next increment..."
read -r
done