#!/usr/bin/env bash
# Opt in to Anthropic provider data sharing required for Claude Fable 5 on Bedrock.
# There is no console UI for this at launch — API only.
# Review https://docs.aws.amazon.com/bedrock/latest/userguide/data-retention.html
# and your legal/security policy before running in production.
#
# Usage:
#   export BEDROCK_API_KEY="..."   # Bedrock API key with data-retention permissions
#   export AWS_REGION="us-east-1"
#   ./data-retention-opt-in.sh
set -euo pipefail

REGION="${AWS_REGION:-us-east-1}"
API_KEY="${BEDROCK_API_KEY:?Set BEDROCK_API_KEY}"

echo "Setting data retention mode to provider_data_share in ${REGION}..."
curl -sS -X PUT "https://bedrock-mantle.${REGION}.api.aws/v1/data_retention" \
  -H "x-api-key: ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"mode": "provider_data_share"}'

echo ""
echo "Done. Confirm with your security team: Anthropic requires 30-day input/output"
echo "retention and human review for Fable 5. See abuse-detection docs on AWS."
