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 theSpec
part of this CustomResourceT
- the class providing theStatus
part 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 withGroup
andVersion
. 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 String
getApiVersion()
String
getCRDName()
static String
getCRDName(Class<? extends CustomResource> clazz)
Computes the name of the Custom Resource Definition (CRD) associated with the specified CustomResource.String
getGroup()
String
getKind()
io.fabric8.kubernetes.api.model.ObjectMeta
getMetadata()
String
getPlural()
static String
getPlural(Class<? extends io.fabric8.kubernetes.api.model.HasMetadata> clazz)
Retrieves the plural form associated with the specified CustomResource if annotated withPlural
or computes a default value using the value returned bygetSingular(Class)
as input toPluralize.toPlural(String)
.String
getScope()
Retrieves the scope that this CustomResource targetsstatic boolean
getServed(Class<? extends CustomResource> clazz)
String
getSingular()
static String
getSingular(Class<? extends io.fabric8.kubernetes.api.model.HasMetadata> clazz)
Retrieves the singular form associated with the specified CustomResource as defined by theSingular
annotation or computes a default value (lower-cased version of the value returned byHasMetadata.getKind(Class)
) if the annotation is not present.S
getSpec()
T
getStatus()
static boolean
getStorage(Class<? extends CustomResource> clazz)
String
getVersion()
protected S
initSpec()
Override to provide your own Spec instanceprotected T
initStatus()
Override to provide your own Status instanceboolean
isServed()
boolean
isStorage()
void
setApiVersion(String version)
void
setKind(String kind)
void
setMetadata(io.fabric8.kubernetes.api.model.ObjectMeta metadata)
void
setSpec(S spec)
void
setStatus(T status)
String
toString()
-
-
-
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
null
if 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
null
if the responsibility of instantiating the Status is left to users of this CustomResource
-
getApiVersion
public String getApiVersion()
- Specified by:
getApiVersion
in interfaceio.fabric8.kubernetes.api.model.HasMetadata
-
setApiVersion
public void setApiVersion(String version)
- Specified by:
setApiVersion
in interfaceio.fabric8.kubernetes.api.model.HasMetadata
-
getKind
public String getKind()
- Specified by:
getKind
in interfaceio.fabric8.kubernetes.api.model.HasMetadata
-
setKind
public void setKind(String kind)
-
getMetadata
public io.fabric8.kubernetes.api.model.ObjectMeta getMetadata()
- Specified by:
getMetadata
in interfaceio.fabric8.kubernetes.api.model.HasMetadata
-
setMetadata
public void setMetadata(io.fabric8.kubernetes.api.model.ObjectMeta metadata)
- Specified by:
setMetadata
in 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 withPlural
or 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
Plural
annotation 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 theSingular
annotation 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
Singular
annotation 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.CLUSTER
orScope.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)
-
-