Class K8sGenericStub<O extends io.kubernetes.client.common.KubernetesObject,L extends io.kubernetes.client.common.KubernetesListObject>

java.lang.Object
org.jdrupes.vmoperator.common.K8sGenericStub<O,L>
Type Parameters:
O - the generic type
L - the generic type
Direct Known Subclasses:
K8sDynamicStubBase, K8sV1ConfigMapStub, K8sV1DeploymentStub, K8sV1PodStub, K8sV1SecretStub, K8sV1ServiceStub, K8sV1StatefulSetStub

public class K8sGenericStub<O extends io.kubernetes.client.common.KubernetesObject,L extends io.kubernetes.client.common.KubernetesListObject> extends Object
A stub for namespaced custom objects.

This stub provides the functions common to all Kubernetes objects, but uses variables for all types. This class should be used as base class only.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    K8sGenericStub.GenericSupplier<O extends io.kubernetes.client.common.KubernetesObject,L extends io.kubernetes.client.common.KubernetesListObject,R extends K8sGenericStub<O,L>>
    A supplier for generic stubs.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final K8sClient
     
    protected final io.kubernetes.client.Discovery.APIResource
     
    protected final String
     
    protected final String
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    K8sGenericStub(Class<O> objectClass, Class<L> objectListClass, K8sClient client, io.kubernetes.client.Discovery.APIResource context, String namespace, String name)
    Instantiates a new stub for the object specified.
  • Method Summary

    Modifier and Type
    Method
    Description
    static io.kubernetes.client.Discovery.APIResource
    apiResource(K8sClient client, io.kubernetes.client.apimachinery.GroupVersionKind gvk)
    Api resource.
    io.kubernetes.client.Discovery.APIResource
    Gets the context.
    static <O extends io.kubernetes.client.common.KubernetesObject, L extends io.kubernetes.client.common.KubernetesListObject, R extends K8sGenericStub<O, L>>
    R
    create(Class<O> objectClass, Class<L> objectListClass, K8sClient client, io.kubernetes.client.Discovery.APIResource context, O model, K8sGenericStub.GenericSupplier<O,L,R> provider)
    Get a namespaced object stub for a newly created object.
    void
    Delete the Kubernetes object.
    Gets the group.
    Gets the kind.
    static <O extends io.kubernetes.client.common.KubernetesObject, L extends io.kubernetes.client.common.KubernetesListObject, R extends K8sGenericStub<O, L>>
    Collection<R>
    list(Class<O> objectClass, Class<L> objectListClass, K8sClient client, io.kubernetes.client.Discovery.APIResource context, String namespace, io.kubernetes.client.util.generic.options.ListOptions options, K8sGenericStub.GenericSupplier<O,L,R> provider)
    Get the stubs for the objects in the given namespace that match the criteria from the given options.
    Retrieves and returns the current state of the object.
    Gets the name.
    Gets the namespace.
    patch(String patchType, io.kubernetes.client.custom.V1Patch patch)
    Patch the object using default options.
    patch(String patchType, io.kubernetes.client.custom.V1Patch patch, io.kubernetes.client.util.generic.options.PatchOptions options)
    Patch the object.
    Gets the plural.
     
    io.kubernetes.client.util.generic.KubernetesApiResponse<O>
    update(O object)
    Update the object.
    io.kubernetes.client.util.generic.KubernetesApiResponse<O>
    update(O object, io.kubernetes.client.util.generic.options.UpdateOptions options)
    Update the object.
    Updates the status.
    updateStatus(O object, Function<O,Object> status)
    Updates the object’s status.
    Gets the version.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • K8sGenericStub

      protected K8sGenericStub(Class<O> objectClass, Class<L> objectListClass, K8sClient client, io.kubernetes.client.Discovery.APIResource context, String namespace, String name)
      Instantiates a new stub for the object specified.

      If the object exists in the context specified, the version (see version() is bound to the existing object’s version. Else the stub is dangling with the version set to the context’s preferred version.

      Parameters:
      objectClass - the object class
      objectListClass - the object list class
      client - the client
      context - the context
      namespace - the namespace
      name - the name
  • Method Details

    • context

      public io.kubernetes.client.Discovery.APIResource context()
      Gets the context.
      Returns:
      the context
    • group

      public String group()
      Gets the group.
      Returns:
      the group
    • version

      public String version()
      Gets the version.
      Returns:
      the version
    • kind

      public String kind()
      Gets the kind.
      Returns:
      the kind
    • plural

      public String plural()
      Gets the plural.
      Returns:
      the plural
    • namespace

      public String namespace()
      Gets the namespace.
      Returns:
      the namespace
    • name

      public String name()
      Gets the name.
      Returns:
      the name
    • delete

      public void delete() throws io.kubernetes.client.openapi.ApiException
      Delete the Kubernetes object.
      Throws:
      io.kubernetes.client.openapi.ApiException - the API exception
    • model

      public Optional<O> model() throws io.kubernetes.client.openapi.ApiException
      Retrieves and returns the current state of the object.
      Returns:
      the object’s state
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception
    • updateStatus

      public Optional<O> updateStatus(O object, Function<O,Object> status) throws io.kubernetes.client.openapi.ApiException
      Updates the object’s status.
      Parameters:
      object - the current state of the object (passed to status)
      status - function that returns the new status
      Returns:
      the updated model or empty if not successful
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception
    • updateStatus

      public Optional<O> updateStatus(Function<O,Object> status) throws io.kubernetes.client.openapi.ApiException
      Updates the status.
      Parameters:
      status - the status
      Returns:
      the kubernetes api response the updated model or empty if not successful
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception
    • patch

      public Optional<O> patch(String patchType, io.kubernetes.client.custom.V1Patch patch, io.kubernetes.client.util.generic.options.PatchOptions options) throws io.kubernetes.client.openapi.ApiException
      Patch the object.
      Parameters:
      patchType - the patch type
      patch - the patch
      options - the options
      Returns:
      the kubernetes api response
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception
    • patch

      public Optional<O> patch(String patchType, io.kubernetes.client.custom.V1Patch patch) throws io.kubernetes.client.openapi.ApiException
      Patch the object using default options.
      Parameters:
      patchType - the patch type
      patch - the patch
      Returns:
      the kubernetes api response
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception
    • update

      public io.kubernetes.client.util.generic.KubernetesApiResponse<O> update(O object) throws io.kubernetes.client.openapi.ApiException
      Update the object.
      Parameters:
      object - the object
      Returns:
      the kubernetes api response
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception
    • update

      public io.kubernetes.client.util.generic.KubernetesApiResponse<O> update(O object, io.kubernetes.client.util.generic.options.UpdateOptions options) throws io.kubernetes.client.openapi.ApiException
      Update the object.
      Parameters:
      object - the object
      options - the options
      Returns:
      the kubernetes api response
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • create

      public static <O extends io.kubernetes.client.common.KubernetesObject, L extends io.kubernetes.client.common.KubernetesListObject, R extends K8sGenericStub<O, L>> R create(Class<O> objectClass, Class<L> objectListClass, K8sClient client, io.kubernetes.client.Discovery.APIResource context, O model, K8sGenericStub.GenericSupplier<O,L,R> provider) throws io.kubernetes.client.openapi.ApiException
      Get a namespaced object stub for a newly created object.
      Type Parameters:
      O - the object type
      L - the object list type
      R - the stub type
      Parameters:
      objectClass - the object class
      objectListClass - the object list class
      client - the client
      context - the context
      model - the model
      provider - the provider
      Returns:
      the stub if the object exists
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception
    • list

      public static <O extends io.kubernetes.client.common.KubernetesObject, L extends io.kubernetes.client.common.KubernetesListObject, R extends K8sGenericStub<O, L>> Collection<R> list(Class<O> objectClass, Class<L> objectListClass, K8sClient client, io.kubernetes.client.Discovery.APIResource context, String namespace, io.kubernetes.client.util.generic.options.ListOptions options, K8sGenericStub.GenericSupplier<O,L,R> provider) throws io.kubernetes.client.openapi.ApiException
      Get the stubs for the objects in the given namespace that match the criteria from the given options.
      Type Parameters:
      O - the object type
      L - the object list type
      R - the stub type
      Parameters:
      objectClass - the object class
      objectListClass - the object list class
      client - the client
      context - the context
      namespace - the namespace
      options - the options
      provider - the provider
      Returns:
      the collection
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception
    • apiResource

      public static io.kubernetes.client.Discovery.APIResource apiResource(K8sClient client, io.kubernetes.client.apimachinery.GroupVersionKind gvk) throws io.kubernetes.client.openapi.ApiException
      Api resource.
      Parameters:
      client - the client
      gvk - the gvk
      Returns:
      the API resource
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception