UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 3.06 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GatewayCustomClaim=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var core_1=()=>{var tmp=require("../../../../core");return core_1=()=>tmp,tmp},errors_1=()=>{var tmp=require("../../../../core/lib/errors");return errors_1=()=>tmp,tmp},helpers_internal_1=()=>{var tmp=require("../../../../core/lib/helpers-internal");return helpers_internal_1=()=>tmp,tmp},custom_claim_helpers_1=()=>{var tmp=require("../../common/custom-claim-helpers");return custom_claim_helpers_1=()=>tmp,tmp},types_1=()=>{var tmp=require("../../common/types");return types_1=()=>tmp,tmp};class GatewayCustomClaim{name;valueType;operator;value;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_bedrockagentcore.GatewayCustomClaim",version:"2.257.0"};static withStringValue(name,value){return new GatewayCustomClaim(name,types_1().CustomClaimValueType.STRING,types_1().CustomClaimOperator.EQUALS,value)}static withStringArrayValue(name,values,operator=types_1().CustomClaimOperator.CONTAINS){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_bedrockagentcore_CustomClaimOperator(operator)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.withStringArrayValue),error}if(operator!==types_1().CustomClaimOperator.CONTAINS&&operator!==types_1().CustomClaimOperator.CONTAINS_ANY)throw new(errors_1()).UnscopedValidationError((0,helpers_internal_1().lit)`CustomClaimOperatorInvalid`,`Custom claim '${name}': STRING_ARRAY type only supports CONTAINS or CONTAINS_ANY operators, got ${operator}`);return new GatewayCustomClaim(name,types_1().CustomClaimValueType.STRING_ARRAY,operator,values)}constructor(name,valueType,operator,value){if(this.name=name,this.valueType=valueType,this.operator=operator,this.value=value,!core_1().Token.isUnresolved(value)){if(valueType===types_1().CustomClaimValueType.STRING&&typeof value!="string")throw new(errors_1()).UnscopedValidationError((0,helpers_internal_1().lit)`CustomClaimStringTypeInvalid`,`Custom claim '${name}': STRING type requires a string value, got ${typeof value}`);if(valueType===types_1().CustomClaimValueType.STRING_ARRAY&&!Array.isArray(value))throw new(errors_1()).UnscopedValidationError((0,helpers_internal_1().lit)`CustomClaimStringArrayTypeInvalid`,`Custom claim '${name}': STRING_ARRAY type requires an array value, got ${typeof value}`)}}_render(){if(this.operator===types_1().CustomClaimOperator.CONTAINS){const values=this.value;if(!core_1().Token.isUnresolved(values[0])&&values.length!==1)throw new(errors_1()).UnscopedValidationError((0,helpers_internal_1().lit)`CustomClaimContainsOperatorInvalid`,`Custom claim '${this.name}': CONTAINS operator requires exactly one value, got ${values.length} values`)}return(0,custom_claim_helpers_1().renderCustomClaim)(this.name,this.valueType,this.operator,this.value)}}exports.GatewayCustomClaim=GatewayCustomClaim;