Class CustomResource<S,​T>

  • Type Parameters:
    S - the class providing the Spec part of this CustomResource
    T - the class providing the Status 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 with Group and Version. Properties are set up automatically as follows: In addition, setApiVersion(String) and setKind(String) are overridden to not do anything since these values are set.
    See Also:
    Serialized Form
    • Field Detail

      • spec

        protected S spec
      • status

        protected T status
    • Constructor Detail

      • CustomResource

        public CustomResource()
    • Method Detail

      • 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 interface io.fabric8.kubernetes.api.model.HasMetadata
      • setApiVersion

        public void setApiVersion​(String version)
        Specified by:
        setApiVersion in interface io.fabric8.kubernetes.api.model.HasMetadata
      • getKind

        public String getKind()
        Specified by:
        getKind in interface io.fabric8.kubernetes.api.model.HasMetadata
      • setKind

        public void setKind​(String kind)
      • getMetadata

        public io.fabric8.kubernetes.api.model.ObjectMeta getMetadata()
        Specified by:
        getMetadata in interface io.fabric8.kubernetes.api.model.HasMetadata
      • setMetadata

        public void setMetadata​(io.fabric8.kubernetes.api.model.ObjectMeta metadata)
        Specified by:
        setMetadata in interface io.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 with Plural or computes a default value using the value returned by getSingular(Class) as input to Pluralize.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 the Singular annotation or computes a default value (lower-cased version of the value returned by HasMetadata.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 or Scope.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)