"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.BedrockInvokeModel=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},core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},task_utils_1=()=>{var tmp=require("../private/task-utils");return task_utils_1=()=>tmp,tmp};class BedrockInvokeModel extends sfn().TaskStateBase{constructor(scope,id,props){super(scope,id,props),this.props=props;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_stepfunctions_tasks_BedrockInvokeModelProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,BedrockInvokeModel),error}this.integrationPattern=props.integrationPattern??sfn().IntegrationPattern.REQUEST_RESPONSE,(0,task_utils_1().validatePatternSupported)(this.integrationPattern,BedrockInvokeModel.SUPPORTED_INTEGRATION_PATTERNS);const isBodySpecified=props.body!==void 0,isInputSpecified=props.input!==void 0&&props.input.s3Location!==void 0;if(isBodySpecified&&isInputSpecified)throw new Error("Either `body` or `input` must be specified, but not both.");if(!isBodySpecified&&!isInputSpecified)throw new Error("Either `body` or `input` must be specified.");if(props.input?.s3Location?.objectVersion!==void 0)throw new Error("Input S3 object version is not supported.");if(props.output?.s3Location?.objectVersion!==void 0)throw new Error("Output S3 object version is not supported.");this.taskPolicies=this.renderPolicyStatements()}renderPolicyStatements(){const policyStatements=[new(iam()).PolicyStatement({actions:["bedrock:InvokeModel"],resources:[this.props.model.modelArn]})];return this.props.input!==void 0&&this.props.input.s3Location!==void 0&&policyStatements.push(new(iam()).PolicyStatement({actions:["s3:GetObject"],resources:[core_1().Stack.of(this).formatArn({region:"",account:"",service:"s3",resource:this.props.input?.s3Location?.bucketName,resourceName:this.props.input?.s3Location?.objectKey})]})),this.props.output!==void 0&&this.props.output.s3Location!==void 0&&policyStatements.push(new(iam()).PolicyStatement({actions:["s3:PutObject"],resources:[core_1().Stack.of(this).formatArn({region:"",account:"",service:"s3",resource:this.props.output?.s3Location?.bucketName,resourceName:this.props.output?.s3Location?.objectKey})]})),policyStatements}_renderTask(){return{Resource:(0,task_utils_1().integrationResourceArn)("bedrock","invokeModel"),Parameters:sfn().FieldUtils.renderObject({ModelId:this.props.model.modelArn,Accept:this.props.accept,ContentType:this.props.contentType,Body:this.props.body?.value,Input:this.props.input?.s3Location?{S3Uri:`s3://${this.props.input.s3Location.bucketName}/${this.props.input.s3Location.objectKey}`}:void 0,Output:this.props.output?.s3Location?{S3Uri:`s3://${this.props.output.s3Location.bucketName}/${this.props.output.s3Location.objectKey}`}:void 0})}}}exports.BedrockInvokeModel=BedrockInvokeModel,_a=JSII_RTTI_SYMBOL_1,BedrockInvokeModel[_a]={fqn:"aws-cdk-lib.aws_stepfunctions_tasks.BedrockInvokeModel",version:"2.148.1"},BedrockInvokeModel.SUPPORTED_INTEGRATION_PATTERNS=[sfn().IntegrationPattern.REQUEST_RESPONSE];
