"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ManualApprovalAction=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),action_1=require("./action"),codepipeline=require("../../aws-codepipeline"),iam=require("../../aws-iam"),sns=require("../../aws-sns"),subs=require("../../aws-sns-subscriptions");class ManualApprovalAction extends action_1.Action{constructor(props){super({...props,category:codepipeline.ActionCategory.APPROVAL,provider:"Manual",artifactBounds:{minInputs:0,maxInputs:0,minOutputs:0,maxOutputs:0}});try{jsiiDeprecationWarnings.aws_cdk_lib_aws_codepipeline_actions_ManualApprovalActionProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,ManualApprovalAction),error}this.props=props}get notificationTopic(){return this._notificationTopic}grantManualApproval(grantable){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_iam_IGrantable(grantable)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.grantManualApproval),error}if(!this.stage)throw new Error("Cannot grant permissions before binding action to a stage");grantable.grantPrincipal.addToPrincipalPolicy(new iam.PolicyStatement({actions:["codepipeline:ListPipelines"],resources:["*"]})),grantable.grantPrincipal.addToPrincipalPolicy(new iam.PolicyStatement({actions:["codepipeline:GetPipeline","codepipeline:GetPipelineState","codepipeline:GetPipelineExecution"],resources:[this.stage.pipeline.pipelineArn]})),grantable.grantPrincipal.addToPrincipalPolicy(new iam.PolicyStatement({actions:["codepipeline:PutApprovalResult"],resources:[`${this.stage.pipeline.pipelineArn}/${this.stage.stageName}/${this.props.actionName}`]}))}bound(scope,stage,options){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_codepipeline_IStage(stage),jsiiDeprecationWarnings.aws_cdk_lib_aws_codepipeline_ActionBindOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bound),error}if(this.props.notificationTopic?this._notificationTopic=this.props.notificationTopic:(this.props.notifyEmails||[]).length>0&&(this._notificationTopic=new sns.Topic(scope,"TopicResource")),this._notificationTopic){this._notificationTopic.grantPublish(options.role);for(const notifyEmail of this.props.notifyEmails||[])this._notificationTopic.addSubscription(new subs.EmailSubscription(notifyEmail))}return this.stage=stage,{configuration:undefinedIfAllValuesAreEmpty({NotificationArn:this._notificationTopic?.topicArn,CustomData:this.props.additionalInformation,ExternalEntityLink:this.props.externalEntityLink})}}}exports.ManualApprovalAction=ManualApprovalAction,_a=JSII_RTTI_SYMBOL_1,ManualApprovalAction[_a]={fqn:"aws-cdk-lib.aws_codepipeline_actions.ManualApprovalAction",version:"2.96.1"};function undefinedIfAllValuesAreEmpty(object){return Object.values(object).some(v=>v!==void 0)?object:void 0}
