All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cdk8s.plus23.k8s.ValidationRule Maven / Gradle / Ivy

package org.cdk8s.plus23.k8s;

/**
 * ValidationRule describes a validation rule written in the CEL expression language.
 */
@javax.annotation.Generated(value = "jsii-pacmak/1.75.0 (build 63bb957)", date = "2023-02-21T09:46:04.076Z")
@software.amazon.jsii.Jsii(module = org.cdk8s.plus23.$Module.class, fqn = "cdk8s-plus-23.k8s.ValidationRule")
@software.amazon.jsii.Jsii.Proxy(ValidationRule.Jsii$Proxy.class)
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public interface ValidationRule extends software.amazon.jsii.JsiiSerializable {

    /**
     * Rule represents the expression which will be evaluated by CEL.
     * 

* ref: https://github.com/google/cel-spec The Rule is scoped to the location of the x-kubernetes-validations extension in the schema. The self variable in the CEL expression is bound to the scoped value. Example: - Rule scoped to the root of a resource with a status subresource: {"rule": "self.status.actual <= self.spec.maxDesired"} *

* If the Rule is scoped to an object with properties, the accessible properties of the object are field selectable via self.field and field presence can be checked via has(self.field). Null valued fields are treated as absent fields in CEL expressions. If the Rule is scoped to an object with additionalProperties (i.e. a map) the value of the map are accessible via self[mapKey], map containment can be checked via mapKey in self and all entries of the map are accessible via CEL macros and functions such as self.all(...). If the Rule is scoped to an array, the elements of the array are accessible via self[i] and also by macros and functions. If the Rule is scoped to a scalar, self is bound to the scalar value. Examples: - Rule scoped to a map of objects: {"rule": "self.components['Widget'].priority < 10"} - Rule scoped to a list of integers: {"rule": "self.values.all(value, value >= 0 && value < 100)"} - Rule scoped to a string value: {"rule": "self.startsWith('kube')"} *

* The apiVersion, kind, metadata.name and metadata.generateName are always accessible from the root of the object and from any x-kubernetes-embedded-resource annotated objects. No other metadata properties are accessible. *

* Unknown data preserved in custom resources via x-kubernetes-preserve-unknown-fields is not accessible in CEL expressions. This includes: - Unknown field values that are preserved by object schemas with x-kubernetes-preserve-unknown-fields. - Object properties where the property schema is of an "unknown type". An "unknown type" is recursively defined as: *

*

    *
  • A schema with no type and x-kubernetes-preserve-unknown-fields set to true
  • *
  • An array where the items schema is of an "unknown type"
  • *
  • An object where the additionalProperties schema is of an "unknown type"
  • *
*

* Only property names of the form [a-zA-Z_.-/][a-zA-Z0-9_.-/]* are accessible. Accessible property names are escaped according to the following rules when accessed in the expression: - '' escapes to 'underscores' - '.' escapes to 'dot' - '-' escapes to 'dash' - '/' escapes to 'slash' - Property names that exactly match a CEL RESERVED keyword escape to '{keyword}__'. The keywords are: * "true", "false", "null", "in", "as", "break", "const", "continue", "else", "for", "function", "if", * "import", "let", "loop", "package", "namespace", "return". * Examples: *

*

    *
  • Rule accessing a property named "namespace": {"rule": "self.namespace > 0"}
  • *
  • Rule accessing a property named "x-prop": {"rule": "self.x__dash__prop > 0"}
  • *
  • Rule accessing a property named "redact__d": {"rule": "self.redact__underscores__d > 0"}
  • *
*

* Equality on arrays with x-kubernetes-list-type of 'set' or 'map' ignores element order, i.e. [1, 2] == [2, 1]. Concatenation on arrays with x-kubernetes-list-type use the semantics of the list type: *

*

    *
  • 'set': X + Y performs a union where the array positions of all elements in X are preserved and * non-intersecting elements in Y are appended, retaining their partial order.
  • *
  • 'map': X + Y performs a merge where the array positions of all keys in X are preserved but the values * are overwritten by values in Y when the key sets of X and Y intersect. Elements in Y with * non-intersecting keys are appended, retaining their partial order.
  • *
*/ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @org.jetbrains.annotations.NotNull java.lang.String getRule(); /** * Message represents the message displayed when validation fails. *

* The message is required if the Rule contains line breaks. The message must not contain line breaks. If unset, the message is "failed rule: {Rule}". e.g. "must be a URL with the host matching spec.host" */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) default @org.jetbrains.annotations.Nullable java.lang.String getMessage() { return null; } /** * @return a {@link Builder} of {@link ValidationRule} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) static Builder builder() { return new Builder(); } /** * A builder for {@link ValidationRule} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public static final class Builder implements software.amazon.jsii.Builder { java.lang.String rule; java.lang.String message; /** * Sets the value of {@link ValidationRule#getRule} * @param rule Rule represents the expression which will be evaluated by CEL. This parameter is required. * ref: https://github.com/google/cel-spec The Rule is scoped to the location of the x-kubernetes-validations extension in the schema. The self variable in the CEL expression is bound to the scoped value. Example: - Rule scoped to the root of a resource with a status subresource: {"rule": "self.status.actual <= self.spec.maxDesired"} *

* If the Rule is scoped to an object with properties, the accessible properties of the object are field selectable via self.field and field presence can be checked via has(self.field). Null valued fields are treated as absent fields in CEL expressions. If the Rule is scoped to an object with additionalProperties (i.e. a map) the value of the map are accessible via self[mapKey], map containment can be checked via mapKey in self and all entries of the map are accessible via CEL macros and functions such as self.all(...). If the Rule is scoped to an array, the elements of the array are accessible via self[i] and also by macros and functions. If the Rule is scoped to a scalar, self is bound to the scalar value. Examples: - Rule scoped to a map of objects: {"rule": "self.components['Widget'].priority < 10"} - Rule scoped to a list of integers: {"rule": "self.values.all(value, value >= 0 && value < 100)"} - Rule scoped to a string value: {"rule": "self.startsWith('kube')"} *

* The apiVersion, kind, metadata.name and metadata.generateName are always accessible from the root of the object and from any x-kubernetes-embedded-resource annotated objects. No other metadata properties are accessible. *

* Unknown data preserved in custom resources via x-kubernetes-preserve-unknown-fields is not accessible in CEL expressions. This includes: - Unknown field values that are preserved by object schemas with x-kubernetes-preserve-unknown-fields. - Object properties where the property schema is of an "unknown type". An "unknown type" is recursively defined as: *

*

    *
  • A schema with no type and x-kubernetes-preserve-unknown-fields set to true
  • *
  • An array where the items schema is of an "unknown type"
  • *
  • An object where the additionalProperties schema is of an "unknown type"
  • *
*

* Only property names of the form [a-zA-Z_.-/][a-zA-Z0-9_.-/]* are accessible. Accessible property names are escaped according to the following rules when accessed in the expression: - '' escapes to 'underscores' - '.' escapes to 'dot' - '-' escapes to 'dash' - '/' escapes to 'slash' - Property names that exactly match a CEL RESERVED keyword escape to '{keyword}__'. The keywords are: * "true", "false", "null", "in", "as", "break", "const", "continue", "else", "for", "function", "if", * "import", "let", "loop", "package", "namespace", "return". * Examples: *

*

    *
  • Rule accessing a property named "namespace": {"rule": "self.namespace > 0"}
  • *
  • Rule accessing a property named "x-prop": {"rule": "self.x__dash__prop > 0"}
  • *
  • Rule accessing a property named "redact__d": {"rule": "self.redact__underscores__d > 0"}
  • *
*

* Equality on arrays with x-kubernetes-list-type of 'set' or 'map' ignores element order, i.e. [1, 2] == [2, 1]. Concatenation on arrays with x-kubernetes-list-type use the semantics of the list type: *

*

    *
  • 'set': X + Y performs a union where the array positions of all elements in X are preserved and * non-intersecting elements in Y are appended, retaining their partial order.
  • *
  • 'map': X + Y performs a merge where the array positions of all keys in X are preserved but the values * are overwritten by values in Y when the key sets of X and Y intersect. Elements in Y with * non-intersecting keys are appended, retaining their partial order.
  • *
* @return {@code this} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder rule(java.lang.String rule) { this.rule = rule; return this; } /** * Sets the value of {@link ValidationRule#getMessage} * @param message Message represents the message displayed when validation fails. * The message is required if the Rule contains line breaks. The message must not contain line breaks. If unset, the message is "failed rule: {Rule}". e.g. "must be a URL with the host matching spec.host" * @return {@code this} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder message(java.lang.String message) { this.message = message; return this; } /** * Builds the configured instance. * @return a new instance of {@link ValidationRule} * @throws NullPointerException if any required attribute was not provided */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @Override public ValidationRule build() { return new Jsii$Proxy(this); } } /** * An implementation for {@link ValidationRule} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @software.amazon.jsii.Internal final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements ValidationRule { private final java.lang.String rule; private final java.lang.String message; /** * Constructor that initializes the object based on values retrieved from the JsiiObject. * @param objRef Reference to the JSII managed object. */ protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) { super(objRef); this.rule = software.amazon.jsii.Kernel.get(this, "rule", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); this.message = software.amazon.jsii.Kernel.get(this, "message", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); } /** * Constructor that initializes the object based on literal property values passed by the {@link Builder}. */ protected Jsii$Proxy(final Builder builder) { super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); this.rule = java.util.Objects.requireNonNull(builder.rule, "rule is required"); this.message = builder.message; } @Override public final java.lang.String getRule() { return this.rule; } @Override public final java.lang.String getMessage() { return this.message; } @Override @software.amazon.jsii.Internal public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() { final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE; final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); data.set("rule", om.valueToTree(this.getRule())); if (this.getMessage() != null) { data.set("message", om.valueToTree(this.getMessage())); } final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); struct.set("fqn", om.valueToTree("cdk8s-plus-23.k8s.ValidationRule")); struct.set("data", data); final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); obj.set("$jsii.struct", struct); return obj; } @Override public final boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ValidationRule.Jsii$Proxy that = (ValidationRule.Jsii$Proxy) o; if (!rule.equals(that.rule)) return false; return this.message != null ? this.message.equals(that.message) : that.message == null; } @Override public final int hashCode() { int result = this.rule.hashCode(); result = 31 * result + (this.message != null ? this.message.hashCode() : 0); return result; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy