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

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

package org.cdk8s.plus23.k8s;

/**
 * ValidatingWebhook describes an admission webhook and the resources and operations it applies to.
 */
@javax.annotation.Generated(value = "jsii-pacmak/1.75.0 (build 63bb957)", date = "2023-02-21T09:46:04.075Z")
@software.amazon.jsii.Jsii(module = org.cdk8s.plus23.$Module.class, fqn = "cdk8s-plus-23.k8s.ValidatingWebhook")
@software.amazon.jsii.Jsii.Proxy(ValidatingWebhook.Jsii$Proxy.class)
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public interface ValidatingWebhook extends software.amazon.jsii.JsiiSerializable {

    /**
     * AdmissionReviewVersions is an ordered list of preferred `AdmissionReview` versions the Webhook expects.
     * 

* API server will try to use first version in the list which it supports. If none of the versions specified in this list supported by API server, validation will fail for this object. If a persisted webhook configuration specifies allowed versions and does not include any versions known to the API Server, calls to the webhook will fail and be subject to the failure policy. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @org.jetbrains.annotations.NotNull java.util.List getAdmissionReviewVersions(); /** * ClientConfig defines how to communicate with the hook. *

* Required */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @org.jetbrains.annotations.NotNull org.cdk8s.plus23.k8s.WebhookClientConfig getClientConfig(); /** * The name of the admission webhook. *

* Name should be fully qualified, e.g., imagepolicy.kubernetes.io, where "imagepolicy" is the name of the webhook, and kubernetes.io is the name of the organization. Required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @org.jetbrains.annotations.NotNull java.lang.String getName(); /** * SideEffects states whether this webhook has side effects. *

* Acceptable values are: None, NoneOnDryRun (webhooks created via v1beta1 may also specify Some or Unknown). Webhooks with side effects MUST implement a reconciliation system, since a request may be rejected by a future step in the admission chain and the side effects therefore need to be undone. Requests with the dryRun attribute will be auto-rejected if they match a webhook with sideEffects == Unknown or Some. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @org.jetbrains.annotations.NotNull java.lang.String getSideEffects(); /** * FailurePolicy defines how unrecognized errors from the admission endpoint are handled - allowed values are Ignore or Fail. *

* Defaults to Fail. *

* Default: Fail. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) default @org.jetbrains.annotations.Nullable java.lang.String getFailurePolicy() { return null; } /** * matchPolicy defines how the "rules" list is used to match incoming requests. Allowed values are "Exact" or "Equivalent". *

*

    *
  • Exact: match a request only if it exactly matches a specified rule. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, but "rules" only included apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"], a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the webhook.
  • *
  • Equivalent: match a request if modifies a resource listed in rules, even via another API group or version. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, and "rules" only included apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"], a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the webhook.
  • *
*

* Defaults to "Equivalent" *

* Default: Equivalent" */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) default @org.jetbrains.annotations.Nullable java.lang.String getMatchPolicy() { return null; } /** * NamespaceSelector decides whether to run the webhook on an object based on whether the namespace for that object matches the selector. *

* If the object itself is a namespace, the matching is performed on object.metadata.labels. If the object is another cluster scoped resource, it never skips the webhook. *

* For example, to run the webhook on any objects whose namespace is not associated with "runlevel" of "0" or "1"; you will set the selector as follows: "namespaceSelector": { * "matchExpressions": [ * { * "key": "runlevel", * "operator": "NotIn", * "values": [ * "0", * "1" * ] * } * ] * } *

* If instead you want to only run the webhook on any objects whose namespace is associated with the "environment" of "prod" or "staging"; you will set the selector as follows: "namespaceSelector": { * "matchExpressions": [ * { * "key": "environment", * "operator": "In", * "values": [ * "prod", * "staging" * ] * } * ] * } *

* See https://kubernetes.io/docs/concepts/overview/working-with-objects/labels for more examples of label selectors. *

* Default to the empty LabelSelector, which matches everything. *

* Default: the empty LabelSelector, which matches everything. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) default @org.jetbrains.annotations.Nullable org.cdk8s.plus23.k8s.LabelSelector getNamespaceSelector() { return null; } /** * ObjectSelector decides whether to run the webhook based on if the object has matching labels. *

* objectSelector is evaluated against both the oldObject and newObject that would be sent to the webhook, and is considered to match if either object matches the selector. A null object (oldObject in the case of create, or newObject in the case of delete) or an object that cannot have labels (like a DeploymentRollback or a PodProxyOptions object) is not considered to match. Use the object selector only if the webhook is opt-in, because end users may skip the admission webhook by setting the labels. Default to the empty LabelSelector, which matches everything. *

* Default: the empty LabelSelector, which matches everything. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) default @org.jetbrains.annotations.Nullable org.cdk8s.plus23.k8s.LabelSelector getObjectSelector() { return null; } /** * Rules describes what operations on what resources/subresources the webhook cares about. *

* The webhook cares about an operation if it matches any Rule. However, in order to prevent ValidatingAdmissionWebhooks and MutatingAdmissionWebhooks from putting the cluster in a state which cannot be recovered from without completely disabling the plugin, ValidatingAdmissionWebhooks and MutatingAdmissionWebhooks are never called on admission requests for ValidatingWebhookConfiguration and MutatingWebhookConfiguration objects. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) default @org.jetbrains.annotations.Nullable java.util.List getRules() { return null; } /** * TimeoutSeconds specifies the timeout for this webhook. *

* After the timeout passes, the webhook call will be ignored or the API call will fail based on the failure policy. The timeout value must be between 1 and 30 seconds. Default to 10 seconds. *

* Default: 10 seconds. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) default @org.jetbrains.annotations.Nullable java.lang.Number getTimeoutSeconds() { return null; } /** * @return a {@link Builder} of {@link ValidatingWebhook} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) static Builder builder() { return new Builder(); } /** * A builder for {@link ValidatingWebhook} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public static final class Builder implements software.amazon.jsii.Builder { java.util.List admissionReviewVersions; org.cdk8s.plus23.k8s.WebhookClientConfig clientConfig; java.lang.String name; java.lang.String sideEffects; java.lang.String failurePolicy; java.lang.String matchPolicy; org.cdk8s.plus23.k8s.LabelSelector namespaceSelector; org.cdk8s.plus23.k8s.LabelSelector objectSelector; java.util.List rules; java.lang.Number timeoutSeconds; /** * Sets the value of {@link ValidatingWebhook#getAdmissionReviewVersions} * @param admissionReviewVersions AdmissionReviewVersions is an ordered list of preferred `AdmissionReview` versions the Webhook expects. This parameter is required. * API server will try to use first version in the list which it supports. If none of the versions specified in this list supported by API server, validation will fail for this object. If a persisted webhook configuration specifies allowed versions and does not include any versions known to the API Server, calls to the webhook will fail and be subject to the failure policy. * @return {@code this} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder admissionReviewVersions(java.util.List admissionReviewVersions) { this.admissionReviewVersions = admissionReviewVersions; return this; } /** * Sets the value of {@link ValidatingWebhook#getClientConfig} * @param clientConfig ClientConfig defines how to communicate with the hook. This parameter is required. * Required * @return {@code this} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder clientConfig(org.cdk8s.plus23.k8s.WebhookClientConfig clientConfig) { this.clientConfig = clientConfig; return this; } /** * Sets the value of {@link ValidatingWebhook#getName} * @param name The name of the admission webhook. This parameter is required. * Name should be fully qualified, e.g., imagepolicy.kubernetes.io, where "imagepolicy" is the name of the webhook, and kubernetes.io is the name of the organization. Required. * @return {@code this} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder name(java.lang.String name) { this.name = name; return this; } /** * Sets the value of {@link ValidatingWebhook#getSideEffects} * @param sideEffects SideEffects states whether this webhook has side effects. This parameter is required. * Acceptable values are: None, NoneOnDryRun (webhooks created via v1beta1 may also specify Some or Unknown). Webhooks with side effects MUST implement a reconciliation system, since a request may be rejected by a future step in the admission chain and the side effects therefore need to be undone. Requests with the dryRun attribute will be auto-rejected if they match a webhook with sideEffects == Unknown or Some. * @return {@code this} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder sideEffects(java.lang.String sideEffects) { this.sideEffects = sideEffects; return this; } /** * Sets the value of {@link ValidatingWebhook#getFailurePolicy} * @param failurePolicy FailurePolicy defines how unrecognized errors from the admission endpoint are handled - allowed values are Ignore or Fail. * Defaults to Fail. * @return {@code this} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder failurePolicy(java.lang.String failurePolicy) { this.failurePolicy = failurePolicy; return this; } /** * Sets the value of {@link ValidatingWebhook#getMatchPolicy} * @param matchPolicy matchPolicy defines how the "rules" list is used to match incoming requests. Allowed values are "Exact" or "Equivalent". *

    *
  • Exact: match a request only if it exactly matches a specified rule. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, but "rules" only included apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"], a request to apps/v1beta1 or extensions/v1beta1 would not be sent to the webhook.
  • *
  • Equivalent: match a request if modifies a resource listed in rules, even via another API group or version. For example, if deployments can be modified via apps/v1, apps/v1beta1, and extensions/v1beta1, and "rules" only included apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"], a request to apps/v1beta1 or extensions/v1beta1 would be converted to apps/v1 and sent to the webhook.
  • *
*

* Defaults to "Equivalent" * @return {@code this} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder matchPolicy(java.lang.String matchPolicy) { this.matchPolicy = matchPolicy; return this; } /** * Sets the value of {@link ValidatingWebhook#getNamespaceSelector} * @param namespaceSelector NamespaceSelector decides whether to run the webhook on an object based on whether the namespace for that object matches the selector. * If the object itself is a namespace, the matching is performed on object.metadata.labels. If the object is another cluster scoped resource, it never skips the webhook. *

* For example, to run the webhook on any objects whose namespace is not associated with "runlevel" of "0" or "1"; you will set the selector as follows: "namespaceSelector": { * "matchExpressions": [ * { * "key": "runlevel", * "operator": "NotIn", * "values": [ * "0", * "1" * ] * } * ] * } *

* If instead you want to only run the webhook on any objects whose namespace is associated with the "environment" of "prod" or "staging"; you will set the selector as follows: "namespaceSelector": { * "matchExpressions": [ * { * "key": "environment", * "operator": "In", * "values": [ * "prod", * "staging" * ] * } * ] * } *

* See https://kubernetes.io/docs/concepts/overview/working-with-objects/labels for more examples of label selectors. *

* Default to the empty LabelSelector, which matches everything. * @return {@code this} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder namespaceSelector(org.cdk8s.plus23.k8s.LabelSelector namespaceSelector) { this.namespaceSelector = namespaceSelector; return this; } /** * Sets the value of {@link ValidatingWebhook#getObjectSelector} * @param objectSelector ObjectSelector decides whether to run the webhook based on if the object has matching labels. * objectSelector is evaluated against both the oldObject and newObject that would be sent to the webhook, and is considered to match if either object matches the selector. A null object (oldObject in the case of create, or newObject in the case of delete) or an object that cannot have labels (like a DeploymentRollback or a PodProxyOptions object) is not considered to match. Use the object selector only if the webhook is opt-in, because end users may skip the admission webhook by setting the labels. Default to the empty LabelSelector, which matches everything. * @return {@code this} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder objectSelector(org.cdk8s.plus23.k8s.LabelSelector objectSelector) { this.objectSelector = objectSelector; return this; } /** * Sets the value of {@link ValidatingWebhook#getRules} * @param rules Rules describes what operations on what resources/subresources the webhook cares about. * The webhook cares about an operation if it matches any Rule. However, in order to prevent ValidatingAdmissionWebhooks and MutatingAdmissionWebhooks from putting the cluster in a state which cannot be recovered from without completely disabling the plugin, ValidatingAdmissionWebhooks and MutatingAdmissionWebhooks are never called on admission requests for ValidatingWebhookConfiguration and MutatingWebhookConfiguration objects. * @return {@code this} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @SuppressWarnings("unchecked") public Builder rules(java.util.List rules) { this.rules = (java.util.List)rules; return this; } /** * Sets the value of {@link ValidatingWebhook#getTimeoutSeconds} * @param timeoutSeconds TimeoutSeconds specifies the timeout for this webhook. * After the timeout passes, the webhook call will be ignored or the API call will fail based on the failure policy. The timeout value must be between 1 and 30 seconds. Default to 10 seconds. * @return {@code this} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) public Builder timeoutSeconds(java.lang.Number timeoutSeconds) { this.timeoutSeconds = timeoutSeconds; return this; } /** * Builds the configured instance. * @return a new instance of {@link ValidatingWebhook} * @throws NullPointerException if any required attribute was not provided */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @Override public ValidatingWebhook build() { return new Jsii$Proxy(this); } } /** * An implementation for {@link ValidatingWebhook} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) @software.amazon.jsii.Internal final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements ValidatingWebhook { private final java.util.List admissionReviewVersions; private final org.cdk8s.plus23.k8s.WebhookClientConfig clientConfig; private final java.lang.String name; private final java.lang.String sideEffects; private final java.lang.String failurePolicy; private final java.lang.String matchPolicy; private final org.cdk8s.plus23.k8s.LabelSelector namespaceSelector; private final org.cdk8s.plus23.k8s.LabelSelector objectSelector; private final java.util.List rules; private final java.lang.Number timeoutSeconds; /** * 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.admissionReviewVersions = software.amazon.jsii.Kernel.get(this, "admissionReviewVersions", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class))); this.clientConfig = software.amazon.jsii.Kernel.get(this, "clientConfig", software.amazon.jsii.NativeType.forClass(org.cdk8s.plus23.k8s.WebhookClientConfig.class)); this.name = software.amazon.jsii.Kernel.get(this, "name", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); this.sideEffects = software.amazon.jsii.Kernel.get(this, "sideEffects", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); this.failurePolicy = software.amazon.jsii.Kernel.get(this, "failurePolicy", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); this.matchPolicy = software.amazon.jsii.Kernel.get(this, "matchPolicy", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); this.namespaceSelector = software.amazon.jsii.Kernel.get(this, "namespaceSelector", software.amazon.jsii.NativeType.forClass(org.cdk8s.plus23.k8s.LabelSelector.class)); this.objectSelector = software.amazon.jsii.Kernel.get(this, "objectSelector", software.amazon.jsii.NativeType.forClass(org.cdk8s.plus23.k8s.LabelSelector.class)); this.rules = software.amazon.jsii.Kernel.get(this, "rules", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(org.cdk8s.plus23.k8s.RuleWithOperations.class))); this.timeoutSeconds = software.amazon.jsii.Kernel.get(this, "timeoutSeconds", software.amazon.jsii.NativeType.forClass(java.lang.Number.class)); } /** * Constructor that initializes the object based on literal property values passed by the {@link Builder}. */ @SuppressWarnings("unchecked") protected Jsii$Proxy(final Builder builder) { super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); this.admissionReviewVersions = java.util.Objects.requireNonNull(builder.admissionReviewVersions, "admissionReviewVersions is required"); this.clientConfig = java.util.Objects.requireNonNull(builder.clientConfig, "clientConfig is required"); this.name = java.util.Objects.requireNonNull(builder.name, "name is required"); this.sideEffects = java.util.Objects.requireNonNull(builder.sideEffects, "sideEffects is required"); this.failurePolicy = builder.failurePolicy; this.matchPolicy = builder.matchPolicy; this.namespaceSelector = builder.namespaceSelector; this.objectSelector = builder.objectSelector; this.rules = (java.util.List)builder.rules; this.timeoutSeconds = builder.timeoutSeconds; } @Override public final java.util.List getAdmissionReviewVersions() { return this.admissionReviewVersions; } @Override public final org.cdk8s.plus23.k8s.WebhookClientConfig getClientConfig() { return this.clientConfig; } @Override public final java.lang.String getName() { return this.name; } @Override public final java.lang.String getSideEffects() { return this.sideEffects; } @Override public final java.lang.String getFailurePolicy() { return this.failurePolicy; } @Override public final java.lang.String getMatchPolicy() { return this.matchPolicy; } @Override public final org.cdk8s.plus23.k8s.LabelSelector getNamespaceSelector() { return this.namespaceSelector; } @Override public final org.cdk8s.plus23.k8s.LabelSelector getObjectSelector() { return this.objectSelector; } @Override public final java.util.List getRules() { return this.rules; } @Override public final java.lang.Number getTimeoutSeconds() { return this.timeoutSeconds; } @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("admissionReviewVersions", om.valueToTree(this.getAdmissionReviewVersions())); data.set("clientConfig", om.valueToTree(this.getClientConfig())); data.set("name", om.valueToTree(this.getName())); data.set("sideEffects", om.valueToTree(this.getSideEffects())); if (this.getFailurePolicy() != null) { data.set("failurePolicy", om.valueToTree(this.getFailurePolicy())); } if (this.getMatchPolicy() != null) { data.set("matchPolicy", om.valueToTree(this.getMatchPolicy())); } if (this.getNamespaceSelector() != null) { data.set("namespaceSelector", om.valueToTree(this.getNamespaceSelector())); } if (this.getObjectSelector() != null) { data.set("objectSelector", om.valueToTree(this.getObjectSelector())); } if (this.getRules() != null) { data.set("rules", om.valueToTree(this.getRules())); } if (this.getTimeoutSeconds() != null) { data.set("timeoutSeconds", om.valueToTree(this.getTimeoutSeconds())); } 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.ValidatingWebhook")); 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; ValidatingWebhook.Jsii$Proxy that = (ValidatingWebhook.Jsii$Proxy) o; if (!admissionReviewVersions.equals(that.admissionReviewVersions)) return false; if (!clientConfig.equals(that.clientConfig)) return false; if (!name.equals(that.name)) return false; if (!sideEffects.equals(that.sideEffects)) return false; if (this.failurePolicy != null ? !this.failurePolicy.equals(that.failurePolicy) : that.failurePolicy != null) return false; if (this.matchPolicy != null ? !this.matchPolicy.equals(that.matchPolicy) : that.matchPolicy != null) return false; if (this.namespaceSelector != null ? !this.namespaceSelector.equals(that.namespaceSelector) : that.namespaceSelector != null) return false; if (this.objectSelector != null ? !this.objectSelector.equals(that.objectSelector) : that.objectSelector != null) return false; if (this.rules != null ? !this.rules.equals(that.rules) : that.rules != null) return false; return this.timeoutSeconds != null ? this.timeoutSeconds.equals(that.timeoutSeconds) : that.timeoutSeconds == null; } @Override public final int hashCode() { int result = this.admissionReviewVersions.hashCode(); result = 31 * result + (this.clientConfig.hashCode()); result = 31 * result + (this.name.hashCode()); result = 31 * result + (this.sideEffects.hashCode()); result = 31 * result + (this.failurePolicy != null ? this.failurePolicy.hashCode() : 0); result = 31 * result + (this.matchPolicy != null ? this.matchPolicy.hashCode() : 0); result = 31 * result + (this.namespaceSelector != null ? this.namespaceSelector.hashCode() : 0); result = 31 * result + (this.objectSelector != null ? this.objectSelector.hashCode() : 0); result = 31 * result + (this.rules != null ? this.rules.hashCode() : 0); result = 31 * result + (this.timeoutSeconds != null ? this.timeoutSeconds.hashCode() : 0); return result; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy