UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 3.59 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.EventBridgePutEvents=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var iam=()=>{var tmp=require("../../../aws-iam");return iam=()=>tmp,tmp},sfn=()=>{var tmp=require("../../../aws-stepfunctions");return sfn=()=>tmp,tmp},cdk=()=>{var tmp=require("../../../core");return cdk=()=>tmp,tmp},task_utils_1=()=>{var tmp=require("../private/task-utils");return task_utils_1=()=>tmp,tmp};class EventBridgePutEvents extends sfn().TaskStateBase{static jsonPath(scope,id,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_stepfunctions_tasks_EventBridgePutEventsJsonPathProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.jsonPath),error}return new EventBridgePutEvents(scope,id,props)}static jsonata(scope,id,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_stepfunctions_tasks_EventBridgePutEventsJsonataProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.jsonata),error}return new EventBridgePutEvents(scope,id,{...props,queryLanguage:sfn().QueryLanguage.JSONATA})}constructor(scope,id,props){super(scope,id,props),this.props=props;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_stepfunctions_tasks_EventBridgePutEventsProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,EventBridgePutEvents),error}if(this.integrationPattern=props.integrationPattern??sfn().IntegrationPattern.REQUEST_RESPONSE,(0,task_utils_1().validatePatternSupported)(this.integrationPattern,EventBridgePutEvents.SUPPORTED_INTEGRATION_PATTERNS),this.integrationPattern===sfn().IntegrationPattern.WAIT_FOR_TASK_TOKEN&&!sfn().FieldUtils.containsTaskToken(props.entries.map(entry=>entry.detail)))throw new(cdk()).ValidationError("Task Token is required in `entries`. Use JsonPath.taskToken to set the token.",this);this.validateEntries(),this.taskPolicies=[new(iam()).PolicyStatement({actions:["events:PutEvents"],resources:this.eventBusArns})]}get eventBusArns(){return this.props.entries.map(entry=>entry.eventBus?entry.eventBus.eventBusArn:cdk().Stack.of(this).formatArn({resource:"event-bus",resourceName:"default",arnFormat:cdk().ArnFormat.SLASH_RESOURCE_NAME,service:"events"}))}_renderTask(topLevelQueryLanguage){const queryLanguage=sfn()._getActualQueryLanguage(topLevelQueryLanguage,this.props.queryLanguage);return{Resource:(0,task_utils_1().integrationResourceArn)("events","putEvents",this.integrationPattern),...this._renderParametersOrArguments({Entries:this.renderEntries()},queryLanguage)}}renderEntries(){return this.props.entries.map(entry=>({Detail:entry.detail?.value,DetailType:entry.detailType,EventBusName:entry.eventBus?.eventBusArn,Source:entry.source}))}validateEntries(){if(this.props.entries.length<=0)throw new(cdk()).ValidationError("Value for property `entries` must be a non-empty array.",this);if(this.props.entries.some(e=>e.source.startsWith("aws.")))throw new(cdk()).ValidationError('Event source cannot start with "aws."',this)}}exports.EventBridgePutEvents=EventBridgePutEvents,_a=JSII_RTTI_SYMBOL_1,EventBridgePutEvents[_a]={fqn:"aws-cdk-lib.aws_stepfunctions_tasks.EventBridgePutEvents",version:"2.202.0"},EventBridgePutEvents.SUPPORTED_INTEGRATION_PATTERNS=[sfn().IntegrationPattern.REQUEST_RESPONSE,sfn().IntegrationPattern.WAIT_FOR_TASK_TOKEN];