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
HasMetadata.getSingular(Class)
- plural is set using
HasMetadata.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 boolean
equals(Object o)
String
getApiVersion()
static String[]
getCategories(Class<?> clazz)
Retrieves the categories associated with this CustomResource or an empty array if none was providedString
getCRDName()
static String
getCRDName(Class<?> clazz)
Computes the name of the Custom Resource Definition (CRD) associated with the specified CustomResource.static boolean
getDeprecated(Class<?> clazz)
String
getDeprecationWarning()
static String
getDeprecationWarning(Class<?> clazz)
String
getGroup()
String
getKind()
io.fabric8.kubernetes.api.model.ObjectMeta
getMetadata()
String
getPlural()
String
getScope()
Retrieves the scope that this CustomResource targetsstatic boolean
getServed(Class<?> clazz)
static String[]
getShortNames(Class<?> clazz)
Retrieves the short names associated with this CustomResource or an empty array if none was providedString
getSingular()
S
getSpec()
T
getStatus()
static boolean
getStorage(Class<?> clazz)
String
getVersion()
int
hashCode()
protected S
initSpec()
Override to provide your own Spec instanceprotected T
initStatus()
Override to provide your own Status instanceboolean
isDeprecated()
boolean
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()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.fabric8.kubernetes.api.model.HasMetadata
addFinalizer, addOwnerReference, addOwnerReference, getFinalizers, getFullResourceName, getOwnerReferenceFor, getOwnerReferenceFor, hasFinalizer, hasOwnerReferenceFor, hasOwnerReferenceFor, initNameAndNamespaceFrom, isFinalizerValid, isMarkedForDeletion, optionalMetadata, removeFinalizer, removeOwnerReference, removeOwnerReference
-
-
-
-
Method Detail
-
getServed
public static boolean getServed(Class<?> clazz)
-
getStorage
public static boolean getStorage(Class<?> clazz)
-
getDeprecated
public static boolean getDeprecated(Class<?> 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 String getPlural()
- Specified by:
getPlural
in interfaceio.fabric8.kubernetes.api.model.HasMetadata
-
getSingular
public String getSingular()
- Specified by:
getSingular
in interfaceio.fabric8.kubernetes.api.model.HasMetadata
-
getCRDName
public static String getCRDName(Class<?> 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()
-
getShortNames
public static String[] getShortNames(Class<?> clazz)
Retrieves the short names associated with this CustomResource or an empty array if none was provided- Parameters:
clazz
- the CustomResource class which short names we want to retrieve- Returns:
- the short names associated with this CustomResource or an empty array if none was provided
-
getCategories
public static String[] getCategories(Class<?> clazz)
Retrieves the categories associated with this CustomResource or an empty array if none was provided- Parameters:
clazz
- the CustomResource class for which the categories are to be retrieved- Returns:
- the categories associated with this CustomResource or an empty array if none was provided
-
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()
-
isDeprecated
public boolean isDeprecated()
-
getDeprecationWarning
public String getDeprecationWarning()
-
getSpec
public S getSpec()
-
setSpec
public void setSpec(S spec)
-
getStatus
public T getStatus()
-
setStatus
public void setStatus(T status)
-
-