
org.cdk8s.plus31.k8s.PodAffinityTerm Maven / Gradle / Ivy
package org.cdk8s.plus31.k8s;
/**
* Defines a set of pods (namely those matching the labelSelector relative to the given namespace(s)) that this pod should be co-located (affinity) or not co-located (anti-affinity) with, where co-located is defined as running on a node whose value of the label with key matches that of any node on which a pod of the set of pods is running.
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.104.0 (build e79254c)", date = "2024-10-12T12:14:17.694Z")
@software.amazon.jsii.Jsii(module = org.cdk8s.plus31.$Module.class, fqn = "cdk8s-plus-31.k8s.PodAffinityTerm")
@software.amazon.jsii.Jsii.Proxy(PodAffinityTerm.Jsii$Proxy.class)
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public interface PodAffinityTerm extends software.amazon.jsii.JsiiSerializable {
/**
* This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching the labelSelector in the specified namespaces, where co-located is defined as running on a node whose value of the label with key topologyKey matches that of any node on which any of the selected pods is running.
*
* Empty topologyKey is not allowed.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@org.jetbrains.annotations.NotNull java.lang.String getTopologyKey();
/**
* A label query over a set of resources, in this case pods.
*
* If it's null, this PodAffinityTerm matches with no Pods.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
default @org.jetbrains.annotations.Nullable org.cdk8s.plus31.k8s.LabelSelector getLabelSelector() {
return null;
}
/**
* MatchLabelKeys is a set of pod label keys to select which pods will be taken into consideration.
*
* The keys are used to lookup values from the incoming pod labels, those key-value labels are merged with labelSelector
as key in (value)
to select the group of existing pods which pods will be taken into consideration for the incoming pod's pod (anti) affinity. Keys that don't exist in the incoming pod labels will be ignored. The default value is empty. The same key is forbidden to exist in both matchLabelKeys and labelSelector. Also, matchLabelKeys cannot be set when labelSelector isn't set. This is a beta field and requires enabling MatchLabelKeysInPodAffinity feature gate (enabled by default).
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
default @org.jetbrains.annotations.Nullable java.util.List getMatchLabelKeys() {
return null;
}
/**
* MismatchLabelKeys is a set of pod label keys to select which pods will be taken into consideration.
*
* The keys are used to lookup values from the incoming pod labels, those key-value labels are merged with labelSelector
as key notin (value)
to select the group of existing pods which pods will be taken into consideration for the incoming pod's pod (anti) affinity. Keys that don't exist in the incoming pod labels will be ignored. The default value is empty. The same key is forbidden to exist in both mismatchLabelKeys and labelSelector. Also, mismatchLabelKeys cannot be set when labelSelector isn't set. This is a beta field and requires enabling MatchLabelKeysInPodAffinity feature gate (enabled by default).
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
default @org.jetbrains.annotations.Nullable java.util.List getMismatchLabelKeys() {
return null;
}
/**
* namespaces specifies a static list of namespace names that the term applies to.
*
* The term is applied to the union of the namespaces listed in this field and the ones selected by namespaceSelector. null or empty namespaces list and null namespaceSelector means "this pod's namespace".
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
default @org.jetbrains.annotations.Nullable java.util.List getNamespaces() {
return null;
}
/**
* A label query over the set of namespaces that the term applies to.
*
* The term is applied to the union of the namespaces selected by this field and the ones listed in the namespaces field. null selector and null or empty namespaces list means "this pod's namespace". An empty selector ({}) matches all namespaces.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
default @org.jetbrains.annotations.Nullable org.cdk8s.plus31.k8s.LabelSelector getNamespaceSelector() {
return null;
}
/**
* @return a {@link Builder} of {@link PodAffinityTerm}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
static Builder builder() {
return new Builder();
}
/**
* A builder for {@link PodAffinityTerm}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public static final class Builder implements software.amazon.jsii.Builder {
java.lang.String topologyKey;
org.cdk8s.plus31.k8s.LabelSelector labelSelector;
java.util.List matchLabelKeys;
java.util.List mismatchLabelKeys;
java.util.List namespaces;
org.cdk8s.plus31.k8s.LabelSelector namespaceSelector;
/**
* Sets the value of {@link PodAffinityTerm#getTopologyKey}
* @param topologyKey This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching the labelSelector in the specified namespaces, where co-located is defined as running on a node whose value of the label with key topologyKey matches that of any node on which any of the selected pods is running. This parameter is required.
* Empty topologyKey is not allowed.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder topologyKey(java.lang.String topologyKey) {
this.topologyKey = topologyKey;
return this;
}
/**
* Sets the value of {@link PodAffinityTerm#getLabelSelector}
* @param labelSelector A label query over a set of resources, in this case pods.
* If it's null, this PodAffinityTerm matches with no Pods.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder labelSelector(org.cdk8s.plus31.k8s.LabelSelector labelSelector) {
this.labelSelector = labelSelector;
return this;
}
/**
* Sets the value of {@link PodAffinityTerm#getMatchLabelKeys}
* @param matchLabelKeys MatchLabelKeys is a set of pod label keys to select which pods will be taken into consideration.
* The keys are used to lookup values from the incoming pod labels, those key-value labels are merged with labelSelector
as key in (value)
to select the group of existing pods which pods will be taken into consideration for the incoming pod's pod (anti) affinity. Keys that don't exist in the incoming pod labels will be ignored. The default value is empty. The same key is forbidden to exist in both matchLabelKeys and labelSelector. Also, matchLabelKeys cannot be set when labelSelector isn't set. This is a beta field and requires enabling MatchLabelKeysInPodAffinity feature gate (enabled by default).
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder matchLabelKeys(java.util.List matchLabelKeys) {
this.matchLabelKeys = matchLabelKeys;
return this;
}
/**
* Sets the value of {@link PodAffinityTerm#getMismatchLabelKeys}
* @param mismatchLabelKeys MismatchLabelKeys is a set of pod label keys to select which pods will be taken into consideration.
* The keys are used to lookup values from the incoming pod labels, those key-value labels are merged with labelSelector
as key notin (value)
to select the group of existing pods which pods will be taken into consideration for the incoming pod's pod (anti) affinity. Keys that don't exist in the incoming pod labels will be ignored. The default value is empty. The same key is forbidden to exist in both mismatchLabelKeys and labelSelector. Also, mismatchLabelKeys cannot be set when labelSelector isn't set. This is a beta field and requires enabling MatchLabelKeysInPodAffinity feature gate (enabled by default).
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder mismatchLabelKeys(java.util.List mismatchLabelKeys) {
this.mismatchLabelKeys = mismatchLabelKeys;
return this;
}
/**
* Sets the value of {@link PodAffinityTerm#getNamespaces}
* @param namespaces namespaces specifies a static list of namespace names that the term applies to.
* The term is applied to the union of the namespaces listed in this field and the ones selected by namespaceSelector. null or empty namespaces list and null namespaceSelector means "this pod's namespace".
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder namespaces(java.util.List namespaces) {
this.namespaces = namespaces;
return this;
}
/**
* Sets the value of {@link PodAffinityTerm#getNamespaceSelector}
* @param namespaceSelector A label query over the set of namespaces that the term applies to.
* The term is applied to the union of the namespaces selected by this field and the ones listed in the namespaces field. null selector and null or empty namespaces list means "this pod's namespace". An empty selector ({}) matches all namespaces.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder namespaceSelector(org.cdk8s.plus31.k8s.LabelSelector namespaceSelector) {
this.namespaceSelector = namespaceSelector;
return this;
}
/**
* Builds the configured instance.
* @return a new instance of {@link PodAffinityTerm}
* @throws NullPointerException if any required attribute was not provided
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@Override
public PodAffinityTerm build() {
return new Jsii$Proxy(this);
}
}
/**
* An implementation for {@link PodAffinityTerm}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@software.amazon.jsii.Internal
final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements PodAffinityTerm {
private final java.lang.String topologyKey;
private final org.cdk8s.plus31.k8s.LabelSelector labelSelector;
private final java.util.List matchLabelKeys;
private final java.util.List mismatchLabelKeys;
private final java.util.List namespaces;
private final org.cdk8s.plus31.k8s.LabelSelector namespaceSelector;
/**
* 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.topologyKey = software.amazon.jsii.Kernel.get(this, "topologyKey", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
this.labelSelector = software.amazon.jsii.Kernel.get(this, "labelSelector", software.amazon.jsii.NativeType.forClass(org.cdk8s.plus31.k8s.LabelSelector.class));
this.matchLabelKeys = software.amazon.jsii.Kernel.get(this, "matchLabelKeys", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class)));
this.mismatchLabelKeys = software.amazon.jsii.Kernel.get(this, "mismatchLabelKeys", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class)));
this.namespaces = software.amazon.jsii.Kernel.get(this, "namespaces", software.amazon.jsii.NativeType.listOf(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.plus31.k8s.LabelSelector.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.topologyKey = java.util.Objects.requireNonNull(builder.topologyKey, "topologyKey is required");
this.labelSelector = builder.labelSelector;
this.matchLabelKeys = builder.matchLabelKeys;
this.mismatchLabelKeys = builder.mismatchLabelKeys;
this.namespaces = builder.namespaces;
this.namespaceSelector = builder.namespaceSelector;
}
@Override
public final java.lang.String getTopologyKey() {
return this.topologyKey;
}
@Override
public final org.cdk8s.plus31.k8s.LabelSelector getLabelSelector() {
return this.labelSelector;
}
@Override
public final java.util.List getMatchLabelKeys() {
return this.matchLabelKeys;
}
@Override
public final java.util.List getMismatchLabelKeys() {
return this.mismatchLabelKeys;
}
@Override
public final java.util.List getNamespaces() {
return this.namespaces;
}
@Override
public final org.cdk8s.plus31.k8s.LabelSelector getNamespaceSelector() {
return this.namespaceSelector;
}
@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("topologyKey", om.valueToTree(this.getTopologyKey()));
if (this.getLabelSelector() != null) {
data.set("labelSelector", om.valueToTree(this.getLabelSelector()));
}
if (this.getMatchLabelKeys() != null) {
data.set("matchLabelKeys", om.valueToTree(this.getMatchLabelKeys()));
}
if (this.getMismatchLabelKeys() != null) {
data.set("mismatchLabelKeys", om.valueToTree(this.getMismatchLabelKeys()));
}
if (this.getNamespaces() != null) {
data.set("namespaces", om.valueToTree(this.getNamespaces()));
}
if (this.getNamespaceSelector() != null) {
data.set("namespaceSelector", om.valueToTree(this.getNamespaceSelector()));
}
final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
struct.set("fqn", om.valueToTree("cdk8s-plus-31.k8s.PodAffinityTerm"));
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;
PodAffinityTerm.Jsii$Proxy that = (PodAffinityTerm.Jsii$Proxy) o;
if (!topologyKey.equals(that.topologyKey)) return false;
if (this.labelSelector != null ? !this.labelSelector.equals(that.labelSelector) : that.labelSelector != null) return false;
if (this.matchLabelKeys != null ? !this.matchLabelKeys.equals(that.matchLabelKeys) : that.matchLabelKeys != null) return false;
if (this.mismatchLabelKeys != null ? !this.mismatchLabelKeys.equals(that.mismatchLabelKeys) : that.mismatchLabelKeys != null) return false;
if (this.namespaces != null ? !this.namespaces.equals(that.namespaces) : that.namespaces != null) return false;
return this.namespaceSelector != null ? this.namespaceSelector.equals(that.namespaceSelector) : that.namespaceSelector == null;
}
@Override
public final int hashCode() {
int result = this.topologyKey.hashCode();
result = 31 * result + (this.labelSelector != null ? this.labelSelector.hashCode() : 0);
result = 31 * result + (this.matchLabelKeys != null ? this.matchLabelKeys.hashCode() : 0);
result = 31 * result + (this.mismatchLabelKeys != null ? this.mismatchLabelKeys.hashCode() : 0);
result = 31 * result + (this.namespaces != null ? this.namespaces.hashCode() : 0);
result = 31 * result + (this.namespaceSelector != null ? this.namespaceSelector.hashCode() : 0);
return result;
}
}
}