#!/usr/bin/env bash
# Opt in to AWS review required for Claude Fable 5 and Fable 5.1 on Bedrock.
# Both are Anthropic Covered Models (30-day minimum retention of prompts/completions).
# Live model cards require mode aws_review — not provider_data_share (stale June 2026 string).
# Review https://docs.aws.amazon.com/bedrock/latest/userguide/data-retention.html
# and https://support.claude.com/en/articles/15425695-covered-models
# plus 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 aws_review 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": "aws_review"}'

echo ""
echo "Done. Confirm with your security team: Covered Models require 30-day input/output"
echo "retention and safety review. ZDR is not the default. Enterprise Frontier Safeguards"
echo "(EFS) rolls out in phases beginning fall 2026 — it is not generally available today."
echo "See abuse-detection docs on AWS and Anthropic Covered Models policy."
