"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpEventBridgeIntegration=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var apigwv2=()=>{var tmp=require("../../../aws-apigatewayv2");return apigwv2=()=>tmp,tmp},iam=()=>{var tmp=require("../../../aws-iam");return iam=()=>tmp,tmp},core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp};class HttpEventBridgeIntegration extends apigwv2().HttpRouteIntegration{props;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_apigatewayv2_integrations.HttpEventBridgeIntegration",version:"2.256.1"};subtype;constructor(id,props){super(id),this.props=props;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_apigatewayv2_integrations_HttpEventBridgeIntegrationProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,HttpEventBridgeIntegration),error}this.subtype=this.props.subtype??apigwv2().HttpIntegrationSubtype.EVENTBRIDGE_PUT_EVENTS}bind(options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_apigatewayv2_HttpRouteIntegrationBindOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}if(this.props.subtype&&!this.props.subtype.startsWith("EventBridge-"))throw new(core_1()).ValidationError((0,literal_string_1().lit)`SubtypeStart`,"Subtype must start with `EventBridge-`",options.scope);const invokeRole=new(iam()).Role(options.scope,"InvokeRole",{assumedBy:new(iam()).ServicePrincipal("apigateway.amazonaws.com")});invokeRole.addToPolicy(new(iam()).PolicyStatement({effect:iam().Effect.ALLOW,sid:"AllowEventBridgePutEvents",actions:["events:PutEvents"],resources:[this.props.eventBusRef.eventBusArn]}));const parameterMapping=this.props.parameterMapping??this.createDefaultParameterMapping(options.scope);return"EventBusName"in parameterMapping.mappings||parameterMapping.custom("EventBusName",this.props.eventBusRef.eventBusName),{payloadFormatVersion:apigwv2().PayloadFormatVersion.VERSION_1_0,type:apigwv2().HttpIntegrationType.AWS_PROXY,subtype:this.subtype,credentials:apigwv2().IntegrationCredentials.fromRole(invokeRole),connectionType:apigwv2().HttpConnectionType.INTERNET,parameterMapping}}createDefaultParameterMapping(scope){if(this.subtype===apigwv2().HttpIntegrationSubtype.EVENTBRIDGE_PUT_EVENTS)return new(apigwv2()).ParameterMapping().custom("Detail","$request.body.Detail").custom("DetailType","$request.body.DetailType").custom("Source","$request.body.Source").custom("EventBusName",this.props.eventBusRef.eventBusName);throw new(core_1()).ValidationError((0,literal_string_1().lit)`UnsupportedSubtype`,`Unsupported subtype: ${this.subtype}`,scope)}}exports.HttpEventBridgeIntegration=HttpEventBridgeIntegration;
