#!/usr/bin/env python3
# /// script
# requires-python = ">=3.12"
# dependencies = []
# ///
"""Static mapping from CloudFormation services to botocore services."""

import json

# CloudFormation service -> list of botocore services
CLOUDFORMATION_TO_BOTOCORE: dict[str, list[str]] = {
    "ACMPCA": ["acm-pca"],
    "AIOps": ["aiops"],
    "APS": ["amp"],  # Amazon Prometheus Service
    "ARCRegionSwitch": ["arc-region-switch"],
    "ARCZonalShift": ["arc-zonal-shift"],
    "AccessAnalyzer": ["accessanalyzer"],
    "AmazonMQ": ["mq"],
    "Amplify": ["amplify", "amplifybackend"],
    "AmplifyUIBuilder": ["amplifyuibuilder"],
    "ApiGateway": ["apigateway", "apigatewaymanagementapi"],
    "ApiGatewayV2": ["apigatewayv2"],
    "AppConfig": ["appconfig", "appconfigdata"],
    "AppFlow": ["appflow"],
    "AppIntegrations": ["appintegrations"],
    "AppMesh": ["appmesh"],
    "AppRunner": ["apprunner"],
    "AppStream": ["appstream"],
    "AppSync": ["appsync"],
    "AppTest": [],  # AWS Mainframe Modernization Application Testing - not in botocore yet
    "ApplicationAutoScaling": ["application-autoscaling"],
    "ApplicationInsights": ["application-insights"],
    "ApplicationSignals": ["application-signals"],
    "Athena": ["athena"],
    "AuditManager": ["auditmanager"],
    "AutoScaling": ["autoscaling"],
    "AutoScalingPlans": ["autoscaling-plans"],
    "B2BI": ["b2bi"],
    "BCMDataExports": ["bcm-data-exports"],
    "Backup": ["backup", "backupsearch"],
    "BackupGateway": ["backup-gateway"],
    "Batch": ["batch"],
    "Bedrock": ["bedrock", "bedrock-agent", "bedrock-agent-runtime", "bedrock-data-automation", "bedrock-data-automation-runtime", "bedrock-runtime"],
    "BedrockAgentCore": ["bedrock-agentcore", "bedrock-agentcore-control"],
    "Billing": ["billing"],
    "BillingConductor": ["billingconductor"],
    "Budgets": ["budgets"],
    "CE": ["ce"],  # Cost Explorer
    "CUR": ["cur"],  # Cost and Usage Reports
    "Cases": ["connectcases"],  # Amazon Connect Cases
    "Cassandra": ["keyspaces", "keyspacesstreams"],  # Amazon Keyspaces
    "CertificateManager": ["acm"],
    "Chatbot": ["chatbot"],
    "CleanRooms": ["cleanrooms"],
    "CleanRoomsML": ["cleanroomsml"],
    "Cloud9": ["cloud9"],
    "CloudFormation": ["cloudformation"],
    "CloudFront": ["cloudfront", "cloudfront-keyvaluestore"],
    "CloudTrail": ["cloudtrail", "cloudtrail-data"],
    "CloudWatch": ["cloudwatch"],
    "CodeArtifact": ["codeartifact"],
    "CodeBuild": ["codebuild"],
    "CodeCommit": ["codecommit"],
    "CodeConnections": ["codeconnections"],
    "CodeDeploy": ["codedeploy"],
    "CodeGuruProfiler": ["codeguruprofiler"],
    "CodeGuruReviewer": ["codeguru-reviewer"],
    "CodePipeline": ["codepipeline"],
    "CodeStar": [],  # No direct botocore service
    "CodeStarConnections": ["codestar-connections"],
    "CodeStarNotifications": ["codestar-notifications"],
    "Cognito": ["cognito-identity", "cognito-idp", "cognito-sync"],
    "Comprehend": ["comprehend"],
    "Config": ["config"],
    "Connect": ["connect", "connect-contact-lens", "connectparticipant"],
    "ConnectCampaigns": ["connectcampaigns"],
    "ConnectCampaignsV2": ["connectcampaignsv2"],
    "ControlTower": ["controltower"],
    "CustomerProfiles": ["customer-profiles"],
    "DAX": ["dax"],
    "DLM": ["dlm"],
    "DMS": ["dms"],
    "DSQL": ["dsql"],
    "DataBrew": ["databrew"],
    "DataPipeline": ["datapipeline"],
    "DataSync": ["datasync"],
    "DataZone": ["datazone"],
    "Deadline": ["deadline"],
    "Detective": ["detective"],
    "DevOpsAgent": [],  # Not in botocore
    "DevOpsGuru": ["devops-guru"],
    "DirectoryService": ["ds", "ds-data"],
    "DocDB": ["docdb"],
    "DocDBElastic": ["docdb-elastic"],
    "DynamoDB": ["dynamodb", "dynamodbstreams"],
    "EC2": ["ec2", "ec2-instance-connect"],
    "ECR": ["ecr", "ecr-public"],
    "ECS": ["ecs"],
    "EFS": ["efs"],
    "EKS": ["eks", "eks-auth"],
    "EMR": ["emr"],
    "EMRContainers": ["emr-containers"],
    "EMRServerless": ["emr-serverless"],
    "EVS": ["evs"],
    "ElastiCache": ["elasticache"],
    "ElasticBeanstalk": ["elasticbeanstalk"],
    "ElasticLoadBalancing": ["elb"],
    "ElasticLoadBalancingV2": ["elbv2"],
    "Elasticsearch": ["es"],
    "EntityResolution": ["entityresolution"],
    "EventSchemas": ["schemas"],
    "Events": ["events"],
    "Evidently": ["evidently"],
    "FIS": ["fis"],
    "FMS": ["fms"],
    "FSx": ["fsx"],
    "FinSpace": ["finspace", "finspace-data"],
    "Forecast": ["forecast", "forecastquery"],
    "FraudDetector": ["frauddetector"],
    "GameLift": ["gamelift", "gameliftstreams"],
    "GlobalAccelerator": ["globalaccelerator"],
    "Glue": ["glue"],
    "Grafana": ["grafana"],
    "Greengrass": ["greengrass"],
    "GreengrassV2": ["greengrassv2"],
    "GroundStation": ["groundstation"],
    "GuardDuty": ["guardduty"],
    "HealthImaging": ["medical-imaging"],
    "HealthLake": ["healthlake"],
    "IAM": ["iam"],
    "IVS": ["ivs", "ivs-realtime"],
    "IVSChat": ["ivschat"],
    "IdentityStore": ["identitystore"],
    "ImageBuilder": ["imagebuilder"],
    "Inspector": ["inspector", "inspector-scan"],
    "InspectorV2": ["inspector2"],
    "InternetMonitor": ["internetmonitor"],
    "Invoicing": ["invoicing"],
    "IoT": ["iot", "iot-data", "iot-jobs-data"],
    "IoTAnalytics": ["iotanalytics"],
    "IoTCoreDeviceAdvisor": ["iotdeviceadvisor"],
    "IoTEvents": ["iotevents", "iotevents-data"],
    "IoTFleetWise": ["iotfleetwise"],
    "IoTSiteWise": ["iotsitewise"],
    "IoTThingsGraph": ["iotthingsgraph"],
    "IoTTwinMaker": ["iottwinmaker"],
    "IoTWireless": ["iotwireless"],
    "KMS": ["kms"],
    "KafkaConnect": ["kafkaconnect"],
    "Kendra": ["kendra"],
    "KendraRanking": ["kendra-ranking"],
    "Kinesis": ["kinesis"],
    "KinesisAnalytics": ["kinesisanalytics"],
    "KinesisAnalyticsV2": ["kinesisanalyticsv2"],
    "KinesisFirehose": ["firehose"],
    "KinesisVideo": ["kinesisvideo", "kinesis-video-archived-media", "kinesis-video-media", "kinesis-video-signaling", "kinesis-video-webrtc-storage"],
    "LakeFormation": ["lakeformation"],
    "Lambda": ["lambda"],
    "LaunchWizard": ["launch-wizard"],
    "Lex": ["lex-models", "lex-runtime", "lexv2-models", "lexv2-runtime"],
    "LicenseManager": ["license-manager", "license-manager-linux-subscriptions", "license-manager-user-subscriptions"],
    "Lightsail": ["lightsail"],
    "Location": ["location", "geo-maps", "geo-places", "geo-routes"],
    "Logs": ["logs"],
    "LookoutEquipment": ["lookoutequipment"],
    "LookoutVision": [],  # Not in botocore
    "M2": ["m2"],
    "MPA": ["mpa"],
    "MSK": ["kafka"],
    "MWAA": ["mwaa"],
    "MWAAServerless": ["mwaa-serverless"],
    "Macie": ["macie2"],
    "ManagedBlockchain": ["managedblockchain", "managedblockchain-query"],
    "MediaConnect": ["mediaconnect"],
    "MediaConvert": ["mediaconvert"],
    "MediaLive": ["medialive"],
    "MediaPackage": ["mediapackage", "mediapackage-vod"],
    "MediaPackageV2": ["mediapackagev2"],
    "MediaStore": ["mediastore", "mediastore-data"],
    "MediaTailor": ["mediatailor"],
    "MemoryDB": ["memorydb"],
    "Neptune": ["neptune", "neptunedata"],
    "NeptuneGraph": ["neptune-graph"],
    "NetworkFirewall": ["network-firewall"],
    "NetworkManager": ["networkmanager", "networkmonitor"],
    "Notifications": ["notifications"],
    "NotificationsContacts": ["notificationscontacts"],
    "ODB": ["odb"],
    "OSIS": ["osis"],
    "Oam": ["oam"],
    "ObservabilityAdmin": ["observabilityadmin"],
    "Omics": ["omics"],
    "OpenSearchServerless": ["opensearchserverless"],
    "OpenSearchService": ["opensearch"],
    "OpsWorks": [],  # Not in botocore (deprecated)
    "Organizations": ["organizations"],
    "PCAConnectorAD": ["pca-connector-ad"],
    "PCAConnectorSCEP": ["pca-connector-scep"],
    "PCS": ["pcs"],
    "Panorama": ["panorama"],
    "PaymentCryptography": ["payment-cryptography", "payment-cryptography-data"],
    "Personalize": ["personalize", "personalize-events", "personalize-runtime"],
    "Pinpoint": ["pinpoint", "pinpoint-sms-voice", "pinpoint-sms-voice-v2"],
    "PinpointEmail": ["pinpoint-email"],
    "Pipes": ["pipes"],
    "Proton": ["proton"],
    "QBusiness": ["qbusiness", "qapps"],
    "QLDB": [],  # Not in botocore (deprecated)
    "QuickSight": ["quicksight"],
    "RAM": ["ram"],
    "RDS": ["rds", "rds-data"],
    "RTBFabric": ["rtbfabric"],
    "RUM": ["rum"],
    "Rbin": ["rbin"],
    "Redshift": ["redshift", "redshift-data"],
    "RedshiftServerless": ["redshift-serverless"],
    "RefactorSpaces": ["migration-hub-refactor-spaces"],
    "Rekognition": ["rekognition"],
    "ResilienceHub": ["resiliencehub"],
    "ResourceExplorer2": ["resource-explorer-2"],
    "ResourceGroups": ["resource-groups", "resourcegroupstaggingapi"],
    "RoboMaker": [],  # Not in botocore
    "RolesAnywhere": ["rolesanywhere"],
    "Route53": ["route53", "route53domains"],
    "Route53Profiles": ["route53profiles"],
    "Route53RecoveryControl": ["route53-recovery-cluster", "route53-recovery-control-config"],
    "Route53RecoveryReadiness": ["route53-recovery-readiness"],
    "Route53Resolver": ["route53resolver", "route53globalresolver"],
    "S3": ["s3", "s3api", "s3control"],
    "S3Express": ["s3"],  # Part of S3
    "S3ObjectLambda": ["s3"],  # Part of S3
    "S3Outposts": ["s3outposts"],
    "S3Tables": ["s3tables"],
    "S3Vectors": ["s3vectors"],
    "SDB": ["sdb"],
    "SES": ["ses", "sesv2"],
    "SNS": ["sns"],
    "SQS": ["sqs"],
    "SSM": ["ssm"],
    "SMSVOICE": ["sms-voice"],  # Note: might overlap with Pinpoint
    "SSMContacts": ["ssm-contacts"],
    "SSMGuiConnect": ["ssm-guiconnect"],
    "SSMIncidents": ["ssm-incidents"],
    "SSMQuickSetup": ["ssm-quicksetup"],
    "SSO": ["sso", "sso-admin", "sso-oidc"],
    "SageMaker": ["sagemaker", "sagemaker-a2i-runtime", "sagemaker-edge", "sagemaker-featurestore-runtime", "sagemaker-geospatial", "sagemaker-metrics", "sagemaker-runtime"],
    "Scheduler": ["scheduler"],
    "SecretsManager": ["secretsmanager"],
    "SecurityHub": ["securityhub"],
    "SecurityLake": ["securitylake"],
    "ServiceCatalog": ["servicecatalog"],
    "ServiceCatalogAppRegistry": ["servicecatalog-appregistry"],
    "ServiceDiscovery": ["servicediscovery"],
    "Shield": ["shield"],
    "Signer": ["signer"],
    "SimSpaceWeaver": ["simspaceweaver"],
    "StepFunctions": ["stepfunctions"],
    "SupportApp": ["support", "support-app"],
    "Synthetics": ["synthetics"],
    "SystemsManagerSAP": ["ssm-sap"],
    "Timestream": ["timestream-influxdb", "timestream-query", "timestream-write"],
    "Transfer": ["transfer"],
    "VerifiedPermissions": ["verifiedpermissions"],
    "VoiceID": ["voice-id"],
    "VpcLattice": ["vpc-lattice"],
    "WAF": ["waf"],
    "WAFRegional": ["waf-regional"],
    "WAFv2": ["wafv2"],
    "Wisdom": ["wisdom", "qconnect"],
    "WorkSpaces": ["workspaces"],
    "WorkSpacesThinClient": ["workspaces-thin-client"],
    "WorkSpacesWeb": ["workspaces-web"],
    "WorkspacesInstances": ["workspaces-instances"],
    "XRay": ["xray"],
}


def main():
    print(f"Mapped {len(CLOUDFORMATION_TO_BOTOCORE)} CloudFormation services")

    # Count total botocore services mapped
    total_botocore = sum(len(v) for v in CLOUDFORMATION_TO_BOTOCORE.values())
    print(f"Total botocore services mapped: {total_botocore}")

    with open("mapping_services.json", "w") as f:
        json.dump(CLOUDFORMATION_TO_BOTOCORE, f, indent=2, sort_keys=True)

    print("Saved to mapping_services.json")


if __name__ == "__main__":
    main()
