"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.GatewayRoute=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),appmesh_generated_1=require("./appmesh.generated"),utils_1=require("./private/utils"),virtual_gateway_1=require("./virtual-gateway"),cdk=require("../../core");class GatewayRoute extends cdk.Resource{static fromGatewayRouteArn(scope,id,gatewayRouteArn){return new class extends cdk.Resource{constructor(){super(...arguments),this.gatewayRouteArn=gatewayRouteArn,this.gatewayRouteName=cdk.Fn.select(4,cdk.Fn.split("/",cdk.Stack.of(scope).splitArn(gatewayRouteArn,cdk.ArnFormat.SLASH_RESOURCE_NAME).resourceName)),this.virtualGateway=virtual_gateway_1.VirtualGateway.fromVirtualGatewayArn(this,"virtualGateway",gatewayRouteArn)}}(scope,id)}static fromGatewayRouteAttributes(scope,id,attrs){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_appmesh_GatewayRouteAttributes(attrs)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromGatewayRouteAttributes),error}return new class extends cdk.Resource{constructor(){super(...arguments),this.gatewayRouteName=attrs.gatewayRouteName,this.gatewayRouteArn=cdk.Stack.of(scope).formatArn({service:"appmesh",resource:`mesh/${attrs.virtualGateway.mesh.meshName}/virtualGateway/${attrs.virtualGateway.virtualGatewayName}/gatewayRoute`,resourceName:this.gatewayRouteName}),this.virtualGateway=attrs.virtualGateway}}(scope,id)}constructor(scope,id,props){super(scope,id,{physicalName:props.gatewayRouteName||cdk.Lazy.string({produce:()=>cdk.Names.uniqueId(this)})});try{jsiiDeprecationWarnings.aws_cdk_lib_aws_appmesh_GatewayRouteProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,GatewayRoute),error}this.virtualGateway=props.virtualGateway;const routeSpecConfig=props.routeSpec.bind(this),gatewayRoute=new appmesh_generated_1.CfnGatewayRoute(this,"Resource",{gatewayRouteName:this.physicalName,meshName:props.virtualGateway.mesh.meshName,meshOwner:(0,utils_1.renderMeshOwner)(this.env.account,this.virtualGateway.mesh.env.account),spec:{httpRoute:routeSpecConfig.httpSpecConfig,http2Route:routeSpecConfig.http2SpecConfig,grpcRoute:routeSpecConfig.grpcSpecConfig,priority:routeSpecConfig.priority},virtualGatewayName:this.virtualGateway.virtualGatewayName});this.gatewayRouteName=this.getResourceNameAttribute(gatewayRoute.attrGatewayRouteName),this.gatewayRouteArn=this.getResourceArnAttribute(gatewayRoute.ref,{service:"appmesh",resource:`mesh/${props.virtualGateway.mesh.meshName}/virtualRouter/${this.virtualGateway.virtualGatewayName}/gatewayRoute`,resourceName:this.physicalName}),this.node.addValidation({validate(){if(cdk.Resource.isOwnedResource(props.virtualGateway)){const listeners=props.virtualGateway.node.defaultChild.spec.listeners;if(Array.isArray(listeners)&&listeners.length>1)return["Gateway route must define a match port if the parent Virtual Gateway has multiple listeners."]}return[]}})}}exports.GatewayRoute=GatewayRoute,_a=JSII_RTTI_SYMBOL_1,GatewayRoute[_a]={fqn:"aws-cdk-lib.aws_appmesh.GatewayRoute",version:"2.96.1"};
