UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 5.47 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.UnauthenticatedAction=exports.ListenerAction=void 0;const jsiiDeprecationWarnings=require("../../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),core_1=require("../../../core");class ListenerAction{constructor(actionJson,next){this.actionJson=actionJson,this.next=next;try{jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_CfnListener_ActionProperty(actionJson),jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_ListenerAction(next)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,ListenerAction),error}}static authenticateOidc(options){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_AuthenticateOidcOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.authenticateOidc),error}return new ListenerAction({type:"authenticate-oidc",authenticateOidcConfig:{authorizationEndpoint:options.authorizationEndpoint,clientId:options.clientId,clientSecret:options.clientSecret.unsafeUnwrap(),issuer:options.issuer,tokenEndpoint:options.tokenEndpoint,userInfoEndpoint:options.userInfoEndpoint,authenticationRequestExtraParams:options.authenticationRequestExtraParams,onUnauthenticatedRequest:options.onUnauthenticatedRequest,scope:options.scope,sessionCookieName:options.sessionCookieName,sessionTimeout:options.sessionTimeout?.toSeconds().toString()}},options.next)}static forward(targetGroups,options={}){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_ForwardOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.forward),error}if(targetGroups.length===0)throw new Error("Need at least one targetGroup in a ListenerAction.forward()");return targetGroups.length===1&&options.stickinessDuration===void 0?new TargetGroupListenerAction(targetGroups,{type:"forward",targetGroupArn:targetGroups[0].targetGroupArn}):new TargetGroupListenerAction(targetGroups,{type:"forward",forwardConfig:{targetGroups:targetGroups.map(g=>({targetGroupArn:g.targetGroupArn})),targetGroupStickinessConfig:options.stickinessDuration?{durationSeconds:options.stickinessDuration.toSeconds(),enabled:!0}:void 0}})}static weightedForward(targetGroups,options={}){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_ForwardOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.weightedForward),error}if(targetGroups.length===0)throw new Error("Need at least one targetGroup in a ListenerAction.weightedForward()");return new TargetGroupListenerAction(targetGroups.map(g=>g.targetGroup),{type:"forward",forwardConfig:{targetGroups:targetGroups.map(g=>({targetGroupArn:g.targetGroup.targetGroupArn,weight:g.weight})),targetGroupStickinessConfig:options.stickinessDuration?{durationSeconds:options.stickinessDuration.toSeconds(),enabled:!0}:void 0}})}static fixedResponse(statusCode,options={}){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_FixedResponseOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fixedResponse),error}return new ListenerAction({type:"fixed-response",fixedResponseConfig:{statusCode:core_1.Tokenization.stringifyNumber(statusCode),contentType:options.contentType,messageBody:options.messageBody}})}static redirect(options){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_RedirectOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.redirect),error}if([options.host,options.path,options.port,options.protocol,options.query].findIndex(x=>x!==void 0)===-1)throw new Error("To prevent redirect loops, set at least one of 'protocol', 'host', 'port', 'path', or 'query'.");return new ListenerAction({type:"redirect",redirectConfig:{statusCode:options.permanent?"HTTP_301":"HTTP_302",host:options.host,path:options.path,port:options.port,protocol:options.protocol,query:options.query}})}renderActions(){return this.renumber([this.actionJson,...this.next?.renderActions()??[]])}bind(scope,listener,associatingConstruct){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_elasticloadbalancingv2_IApplicationListener(listener)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}this.next?.bind(scope,listener,associatingConstruct)}renumber(actions){return actions.length<2?actions:actions.map((action,i)=>({...action,order:i+1}))}}exports.ListenerAction=ListenerAction,_a=JSII_RTTI_SYMBOL_1,ListenerAction[_a]={fqn:"aws-cdk-lib.aws_elasticloadbalancingv2.ListenerAction",version:"2.70.0"};var UnauthenticatedAction;(function(UnauthenticatedAction2){UnauthenticatedAction2.DENY="deny",UnauthenticatedAction2.ALLOW="allow",UnauthenticatedAction2.AUTHENTICATE="authenticate"})(UnauthenticatedAction=exports.UnauthenticatedAction||(exports.UnauthenticatedAction={}));class TargetGroupListenerAction extends ListenerAction{constructor(targetGroups,actionJson){super(actionJson),this.targetGroups=targetGroups}bind(_scope,listener,associatingConstruct){for(const tg of this.targetGroups)tg.registerListener(listener,associatingConstruct)}}