Class PolicyCondition
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
A condition compares a request attribute against a value. Conditions are grouped
into the when and unless clauses of a statement, where the members of a clause
must all hold.
Comparisons are named for the type of value they accept, so each one takes a
concrete type rather than a union. Use allOf and anyOf to build a nested
boolean expression, which also makes the grouping explicit in the generated Cedar.
Example:
import software.amazon.awscdk.services.bedrockagentcore.PolicyAttribute;
import software.amazon.awscdk.services.bedrockagentcore.PolicyCondition;
// principal.department == "Engineering"
PolicyCondition.stringEquals(PolicyAttribute.principal("department"), "Engineering");
// (principal.department == "Engineering" || principal.department == "Support")
PolicyCondition.anyOf(List.of(PolicyCondition.stringEquals(PolicyAttribute.principal("department"), "Engineering"), PolicyCondition.stringEquals(PolicyAttribute.principal("department"), "Support")));
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPolicyCondition(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedPolicyCondition(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionstatic PolicyConditionallOf(List<? extends PolicyCondition> conditions) All of the given conditions must hold.static PolicyConditionanyOf(List<? extends PolicyCondition> conditions) At least one of the given conditions must hold.static PolicyConditionbooleanEquals(PolicyAttribute attribute, Boolean value) The attribute equals a boolean value.static PolicyConditionipInRange(PolicyAttribute attribute, String cidr) The attribute is an IP address inside the given CIDR range.static PolicyConditionnumberEquals(PolicyAttribute attribute, Number value) The attribute equals a number value.static PolicyConditionnumberGreaterThan(PolicyAttribute attribute, Number value) The attribute is greater than a number value.static PolicyConditionnumberGreaterThanOrEquals(PolicyAttribute attribute, Number value) The attribute is greater than or equal to a number value.static PolicyConditionnumberIn(PolicyAttribute attribute, List<? extends Number> values) The attribute is one of the given number values.static PolicyConditionnumberLessThan(PolicyAttribute attribute, Number value) The attribute is less than a number value.static PolicyConditionnumberLessThanOrEquals(PolicyAttribute attribute, Number value) The attribute is less than or equal to a number value.static PolicyConditionnumberNotEquals(PolicyAttribute attribute, Number value) The attribute does not equal a number value.static PolicyConditionsetContains(PolicyAttribute attribute, String value) The attribute is a set that contains the given value.static PolicyConditionstringEquals(PolicyAttribute attribute, String value) The attribute equals a string value.static PolicyConditionstringIn(PolicyAttribute attribute, List<String> values) The attribute is one of the given string values.static PolicyConditionstringNotEquals(PolicyAttribute attribute, String value) The attribute does not equal a string value.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
PolicyCondition
protected PolicyCondition(software.amazon.jsii.JsiiObjectRef objRef) -
PolicyCondition
protected PolicyCondition(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
-
-
Method Details
-
allOf
@Stability(Stable) @NotNull public static PolicyCondition allOf(@NotNull List<? extends PolicyCondition> conditions) All of the given conditions must hold.Renders as a parenthesised
&&group, so it can be nested insideanyOfwithout relying on operator precedence.- Parameters:
conditions-- The conditions to combine, at least one.
-
anyOf
@Stability(Stable) @NotNull public static PolicyCondition anyOf(@NotNull List<? extends PolicyCondition> conditions) At least one of the given conditions must hold.Renders as a parenthesised
||group, so it can be nested insideallOfor combined with the surrounding clause without relying on operator precedence.- Parameters:
conditions-- The conditions to combine, at least one.
-
booleanEquals
@Stability(Stable) @NotNull public static PolicyCondition booleanEquals(@NotNull PolicyAttribute attribute, @NotNull Boolean value) The attribute equals a boolean value.- Parameters:
attribute-- The attribute to compare.
value-- The value to compare against.
-
ipInRange
@Stability(Stable) @NotNull public static PolicyCondition ipInRange(@NotNull PolicyAttribute attribute, @NotNull String cidr) The attribute is an IP address inside the given CIDR range.- Parameters:
attribute-- The attribute holding an IP address.
cidr-- The range in CIDR notation, for example '192.168.1.0/24'.
-
numberEquals
@Stability(Stable) @NotNull public static PolicyCondition numberEquals(@NotNull PolicyAttribute attribute, @NotNull Number value) The attribute equals a number value.Cedar whole numbers are 64-bit signed integers, so the value must be an integer.
- Parameters:
attribute-- The attribute to compare.
value-- The value to compare against.
-
numberGreaterThan
@Stability(Stable) @NotNull public static PolicyCondition numberGreaterThan(@NotNull PolicyAttribute attribute, @NotNull Number value) The attribute is greater than a number value.- Parameters:
attribute-- The attribute to compare.
value-- The value to compare against.
-
numberGreaterThanOrEquals
@Stability(Stable) @NotNull public static PolicyCondition numberGreaterThanOrEquals(@NotNull PolicyAttribute attribute, @NotNull Number value) The attribute is greater than or equal to a number value.- Parameters:
attribute-- The attribute to compare.
value-- The value to compare against.
-
numberIn
@Stability(Stable) @NotNull public static PolicyCondition numberIn(@NotNull PolicyAttribute attribute, @NotNull List<? extends Number> values) The attribute is one of the given number values.- Parameters:
attribute-- The attribute to compare.
values-- The allowed values, at least one.
-
numberLessThan
@Stability(Stable) @NotNull public static PolicyCondition numberLessThan(@NotNull PolicyAttribute attribute, @NotNull Number value) The attribute is less than a number value.- Parameters:
attribute-- The attribute to compare.
value-- The value to compare against.
-
numberLessThanOrEquals
@Stability(Stable) @NotNull public static PolicyCondition numberLessThanOrEquals(@NotNull PolicyAttribute attribute, @NotNull Number value) The attribute is less than or equal to a number value.- Parameters:
attribute-- The attribute to compare.
value-- The value to compare against.
-
numberNotEquals
@Stability(Stable) @NotNull public static PolicyCondition numberNotEquals(@NotNull PolicyAttribute attribute, @NotNull Number value) The attribute does not equal a number value.- Parameters:
attribute-- The attribute to compare.
value-- The value to compare against.
-
setContains
@Stability(Stable) @NotNull public static PolicyCondition setContains(@NotNull PolicyAttribute attribute, @NotNull String value) The attribute is a set that contains the given value.Use this when the attribute itself holds a set, for example
principal.groups. To test a scalar attribute against a list of allowed values, usestringInornumberIninstead.- Parameters:
attribute-- The attribute holding a set.
value-- The member to look for.
-
stringEquals
@Stability(Stable) @NotNull public static PolicyCondition stringEquals(@NotNull PolicyAttribute attribute, @NotNull String value) The attribute equals a string value.- Parameters:
attribute-- The attribute to compare.
value-- The value to compare against.
-
stringIn
@Stability(Stable) @NotNull public static PolicyCondition stringIn(@NotNull PolicyAttribute attribute, @NotNull List<String> values) The attribute is one of the given string values.- Parameters:
attribute-- The attribute to compare.
values-- The allowed values, at least one.
-
stringNotEquals
@Stability(Stable) @NotNull public static PolicyCondition stringNotEquals(@NotNull PolicyAttribute attribute, @NotNull String value) The attribute does not equal a string value.- Parameters:
attribute-- The attribute to compare.
value-- The value to compare against.
-