"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.PredefinedMetric=exports.TargetTrackingScalingPolicy=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var constructs_1=()=>{var tmp=require("constructs");return constructs_1=()=>tmp,tmp},autoscaling_generated_1=()=>{var tmp=require("./autoscaling.generated");return autoscaling_generated_1=()=>tmp,tmp};class TargetTrackingScalingPolicy extends constructs_1().Construct{constructor(scope,id,props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_autoscaling_TargetTrackingScalingPolicyProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,TargetTrackingScalingPolicy),error}if(props.customMetric===void 0==(props.predefinedMetric===void 0))throw new Error("Exactly one of 'customMetric' or 'predefinedMetric' must be specified.");if(props.predefinedMetric===PredefinedMetric.ALB_REQUEST_COUNT_PER_TARGET&&!props.resourceLabel)throw new Error("When tracking the ALBRequestCountPerTarget metric, the ALB identifier must be supplied in resourceLabel");if(props.customMetric&&!props.customMetric.toMetricConfig().metricStat)throw new Error("Only direct metrics are supported for Target Tracking. Use Step Scaling or supply a Metric object.");super(scope,id),this.resource=new(autoscaling_generated_1()).CfnScalingPolicy(this,"Resource",{policyType:"TargetTrackingScaling",autoScalingGroupName:props.autoScalingGroup.autoScalingGroupName,cooldown:props.cooldown&&props.cooldown.toSeconds().toString(),estimatedInstanceWarmup:props.estimatedInstanceWarmup&&props.estimatedInstanceWarmup.toSeconds(),targetTrackingConfiguration:{customizedMetricSpecification:renderCustomMetric(props.customMetric),disableScaleIn:props.disableScaleIn,predefinedMetricSpecification:props.predefinedMetric!==void 0?{predefinedMetricType:props.predefinedMetric,resourceLabel:props.resourceLabel}:void 0,targetValue:props.targetValue}}),this.scalingPolicyArn=this.resource.ref}}exports.TargetTrackingScalingPolicy=TargetTrackingScalingPolicy,_a=JSII_RTTI_SYMBOL_1,TargetTrackingScalingPolicy[_a]={fqn:"aws-cdk-lib.aws_autoscaling.TargetTrackingScalingPolicy",version:"2.159.0"};function renderCustomMetric(metric){if(!metric)return;const c=metric.toMetricConfig().metricStat;return{dimensions:c.dimensions,metricName:c.metricName,namespace:c.namespace,statistic:c.statistic,unit:c.unitFilter}}var PredefinedMetric;(function(PredefinedMetric2){PredefinedMetric2.ASG_AVERAGE_CPU_UTILIZATION="ASGAverageCPUUtilization",PredefinedMetric2.ASG_AVERAGE_NETWORK_IN="ASGAverageNetworkIn",PredefinedMetric2.ASG_AVERAGE_NETWORK_OUT="ASGAverageNetworkOut",PredefinedMetric2.ALB_REQUEST_COUNT_PER_TARGET="ALBRequestCountPerTarget"})(PredefinedMetric||(exports.PredefinedMetric=PredefinedMetric={}));
