"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Universal=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var target_1=()=>{var tmp=require("./target");return target_1=()=>tmp,tmp},aws_iam_1=()=>{var tmp=require("../../aws-iam");return aws_iam_1=()=>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},helpers_internal_1=()=>{var tmp=require("../../custom-resources/lib/helpers-internal");return helpers_internal_1=()=>tmp,tmp};const NOT_SUPPORTED_ACTION_PREFIX=["get","describe","list","poll","receive","search","scan","query","select","read","lookup","discover","validate","batchGet","batchDescribe","batchRead","transactGet","adminGet","adminList","testMigration","retrieve","testConnection","translateDocument","isAuthorized","invokeModel"];class Universal extends target_1().ScheduleTargetBase{props;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_scheduler_targets.Universal",version:"2.256.1"};constructor(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_scheduler_targets_UniversalTargetProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,Universal),error}const service=props.service,action=props.action;if(!core_1().Token.isUnresolved(service)&&service!==service.toLowerCase())throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`MustBeServiceLowercase`,`API service must be lowercase, got: ${service}`);if(!core_1().Token.isUnresolved(action)&&!action.startsWith(action[0]?.toLowerCase()))throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`MustBeActionCamelcase`,`API action must be camelCase, got: ${action}`);if(!core_1().Token.isUnresolved(action)&&NOT_SUPPORTED_ACTION_PREFIX.some(prefix=>action.startsWith(prefix)))throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`ReadOnlyActionSupportedEventbridge`,`Read-only API action is not supported by EventBridge Scheduler: ${service}:${action}`);const arn=`arn:${core_1().Aws.PARTITION}:scheduler:::aws-sdk:${service}:${action}`;super(props,arn),this.props=props}addTargetActionToRole(role){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_iam_IRole(role)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addTargetActionToRole),error}if(!this.props.policyStatements?.length){core_1().Annotations.of(role).addWarningV2("@aws-cdk/aws-scheduler-targets:defaultWildcardResourcePolicy","Default policy with * for resources is used. Use custom policy for better security posture."),role.addToPrincipalPolicy(new(aws_iam_1()).PolicyStatement({actions:[(0,helpers_internal_1().awsSdkToIamAction)(this.props.service,this.props.action)],resources:["*"]}));return}for(const statement of this.props.policyStatements)role.addToPrincipalPolicy(statement)}}exports.Universal=Universal;
