"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.JobQueue=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),batch_generated_1=require("./batch.generated"),core_1=require("../../core");class JobQueue extends core_1.Resource{static fromJobQueueArn(scope,id,jobQueueArn){const stack=core_1.Stack.of(scope);class Import extends core_1.Resource{constructor(){super(...arguments),this.computeEnvironments=[],this.priority=1,this.jobQueueArn=jobQueueArn,this.jobQueueName=stack.splitArn(jobQueueArn,core_1.ArnFormat.SLASH_RESOURCE_NAME).resourceName}addComputeEnvironment(_computeEnvironment,_order){throw new Error(`cannot add ComputeEnvironments to imported JobQueue '${id}'`)}}return new Import(scope,id)}constructor(scope,id,props){super(scope,id,{physicalName:props?.jobQueueName});try{jsiiDeprecationWarnings.aws_cdk_lib_aws_batch_JobQueueProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,JobQueue),error}this.computeEnvironments=props?.computeEnvironments??[],this.priority=props?.priority??1,this.enabled=props?.enabled,this.schedulingPolicy=props?.schedulingPolicy;const resource=new batch_generated_1.CfnJobQueue(this,"Resource",{computeEnvironmentOrder:core_1.Lazy.any({produce:()=>this.computeEnvironments.map(ce=>({computeEnvironment:ce.computeEnvironment.computeEnvironmentArn,order:ce.order}))}),priority:this.priority,jobQueueName:props?.jobQueueName,state:this.enabled??!0?"ENABLED":"DISABLED",schedulingPolicyArn:this.schedulingPolicy?.schedulingPolicyArn});this.jobQueueArn=this.getResourceArnAttribute(resource.attrJobQueueArn,{service:"batch",resource:"job-queue",resourceName:this.physicalName}),this.jobQueueName=core_1.Stack.of(this).splitArn(this.jobQueueArn,core_1.ArnFormat.SLASH_RESOURCE_NAME).resourceName,this.node.addValidation({validate:()=>validateOrderedComputeEnvironments(this.computeEnvironments)})}addComputeEnvironment(computeEnvironment,order){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_batch_IComputeEnvironment(computeEnvironment)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addComputeEnvironment),error}this.computeEnvironments.push({computeEnvironment,order})}}exports.JobQueue=JobQueue,_a=JSII_RTTI_SYMBOL_1,JobQueue[_a]={fqn:"aws-cdk-lib.aws_batch.JobQueue",version:"2.96.1"};function validateOrderedComputeEnvironments(computeEnvironments){const seenOrders=[];for(const ce of computeEnvironments){if(seenOrders.includes(ce.order))return["assigns the same order to different ComputeEnvironments"];seenOrders.push(ce.order)}return seenOrders.length===0?["This JobQueue does not link any ComputeEnvironments"]:[]}
