Package io.fabric8.kubernetes.client
Class CustomResource<S,T>
- java.lang.Object
-
- io.fabric8.kubernetes.client.CustomResource<S,T>
-
- Type Parameters:
S- the class providing theSpecpart of this CustomResourceT- the class providing theStatuspart of this CustomResource
- All Implemented Interfaces:
io.fabric8.kubernetes.api.model.HasMetadata,io.fabric8.kubernetes.api.model.KubernetesResource,Serializable
public abstract class CustomResource<S,T> extends Object implements io.fabric8.kubernetes.api.model.HasMetadata
A base class for implementing a custom resource kind. Implementations must be annotated withGroupandVersion. Properties are set up automatically as follows:- group is set using
HasMetadata.getGroup(Class) - version is set using
HasMetadata.getVersion(Class) - singular is set using
getSingular(Class) - plural is set using
getPlural(Class) - computed CRD name using
getCRDName(Class)
setApiVersion(String)andsetKind(String)are overridden to not do anything since these values are set.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CustomResource()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetApiVersion()StringgetCRDName()static StringgetCRDName(Class<? extends CustomResource> clazz)Computes the name of the Custom Resource Definition (CRD) associated with the specified CustomResource.StringgetGroup()StringgetKind()io.fabric8.kubernetes.api.model.ObjectMetagetMetadata()StringgetPlural()static StringgetPlural(Class<? extends io.fabric8.kubernetes.api.model.HasMetadata> clazz)Retrieves the plural form associated with the specified CustomResource if annotated withPluralor computes a default value using the value returned bygetSingular(Class)as input toPluralize.toPlural(String).StringgetScope()Retrieves the scope that this CustomResource targetsstatic booleangetServed(Class<? extends CustomResource> clazz)StringgetSingular()static StringgetSingular(Class<? extends io.fabric8.kubernetes.api.model.HasMetadata> clazz)Retrieves the singular form associated with the specified CustomResource as defined by theSingularannotation or computes a default value (lower-cased version of the value returned byHasMetadata.getKind(Class)) if the annotation is not present.SgetSpec()TgetStatus()static booleangetStorage(Class<? extends CustomResource> clazz)StringgetVersion()protected SinitSpec()Override to provide your own Spec instanceprotected TinitStatus()Override to provide your own Status instancebooleanisServed()booleanisStorage()voidsetApiVersion(String version)voidsetKind(String kind)voidsetMetadata(io.fabric8.kubernetes.api.model.ObjectMeta metadata)voidsetSpec(S spec)voidsetStatus(T status)StringtoString()
-
-
-
Method Detail
-
getServed
public static boolean getServed(Class<? extends CustomResource> clazz)
-
getStorage
public static boolean getStorage(Class<? extends CustomResource> clazz)
-
initSpec
protected S initSpec()
Override to provide your own Spec instance- Returns:
- a new Spec instance or
nullif the responsibility of instantiating the Spec is left to users of this CustomResource
-
initStatus
protected T initStatus()
Override to provide your own Status instance- Returns:
- a new Status instance or
nullif the responsibility of instantiating the Status is left to users of this CustomResource
-
getApiVersion
public String getApiVersion()
- Specified by:
getApiVersionin interfaceio.fabric8.kubernetes.api.model.HasMetadata
-
setApiVersion
public void setApiVersion(String version)
- Specified by:
setApiVersionin interfaceio.fabric8.kubernetes.api.model.HasMetadata
-
getKind
public String getKind()
- Specified by:
getKindin interfaceio.fabric8.kubernetes.api.model.HasMetadata
-
setKind
public void setKind(String kind)
-
getMetadata
public io.fabric8.kubernetes.api.model.ObjectMeta getMetadata()
- Specified by:
getMetadatain interfaceio.fabric8.kubernetes.api.model.HasMetadata
-
setMetadata
public void setMetadata(io.fabric8.kubernetes.api.model.ObjectMeta metadata)
- Specified by:
setMetadatain interfaceio.fabric8.kubernetes.api.model.HasMetadata
-
getPlural
public static String getPlural(Class<? extends io.fabric8.kubernetes.api.model.HasMetadata> clazz)
Retrieves the plural form associated with the specified CustomResource if annotated withPluralor computes a default value using the value returned bygetSingular(Class)as input toPluralize.toPlural(String).- Parameters:
clazz- the CustomResource whose plural form we want to retrieve- Returns:
- the plural form defined by the
Pluralannotation or a computed default value
-
getPlural
public String getPlural()
-
getSingular
public static String getSingular(Class<? extends io.fabric8.kubernetes.api.model.HasMetadata> clazz)
Retrieves the singular form associated with the specified CustomResource as defined by theSingularannotation or computes a default value (lower-cased version of the value returned byHasMetadata.getKind(Class)) if the annotation is not present.- Parameters:
clazz- the CustomResource whose singular form we want to retrieve- Returns:
- the singular form defined by the
Singularannotation or a computed default value
-
getSingular
public String getSingular()
-
getCRDName
public static String getCRDName(Class<? extends CustomResource> clazz)
Computes the name of the Custom Resource Definition (CRD) associated with the specified CustomResource. See https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/ for more details.- Parameters:
clazz- the CustomResource whose CRD name we want to compute- Returns:
- the CRD name associated with the CustomResource
-
getCRDName
public String getCRDName()
-
getScope
public String getScope()
Retrieves the scope that this CustomResource targets- Returns:
- the scope that this CustomResource targets. Possible values are
Scope.CLUSTERorScope.NAMESPACED.
-
getGroup
public String getGroup()
-
getVersion
public String getVersion()
-
isServed
public boolean isServed()
-
isStorage
public boolean isStorage()
-
getSpec
public S getSpec()
-
setSpec
public void setSpec(S spec)
-
getStatus
public T getStatus()
-
setStatus
public void setStatus(T status)
-
-