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

java.lang.Object
org.jdrupes.vmoperator.common.K8sClusterGenericStub<O,L>
Type Parameters:
O - the generic type
L - the generic type
Direct Known Subclasses:
K8sV1NodeStub

public class K8sClusterGenericStub<O extends io.kubernetes.client.common.KubernetesObject,L extends io.kubernetes.client.common.KubernetesListObject> extends Object
A stub for cluster scoped 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.

  • Field Details

  • Constructor Details

    • K8sClusterGenericStub

      protected K8sClusterGenericStub(Class<O> objectClass, Class<L> objectListClass, K8sClient client, io.kubernetes.client.Discovery.APIResource context, 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
      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
    • 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
    • toString

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

      public static <O extends io.kubernetes.client.common.KubernetesObject, L extends io.kubernetes.client.common.KubernetesListObject, R extends K8sClusterGenericStub<O, L>> R get(Class<O> objectClass, Class<L> objectListClass, K8sClient client, io.kubernetes.client.apimachinery.GroupVersionKind gvk, String name, K8sClusterGenericStub.GenericSupplier<O,L,R> provider) throws io.kubernetes.client.openapi.ApiException
      Get an object stub.

      If the version in parameter gvk is an empty string, the stub refers to the first object found with matching group and kind.

      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
      gvk - the group, version and kind
      name - the name
      provider - the provider
      Returns:
      the stub if the object exists
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception
    • get

      public static <O extends io.kubernetes.client.common.KubernetesObject, L extends io.kubernetes.client.common.KubernetesListObject, R extends K8sClusterGenericStub<O, L>> R get(Class<O> objectClass, Class<L> objectListClass, K8sClient client, io.kubernetes.client.Discovery.APIResource context, String name, K8sClusterGenericStub.GenericSupplier<O,L,R> provider)
      Get an object stub.
      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
      name - the name
      provider - the provider
      Returns:
      the stub if the object exists
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception
    • create

      public static <O extends io.kubernetes.client.common.KubernetesObject, L extends io.kubernetes.client.common.KubernetesListObject, R extends K8sClusterGenericStub<O, L>> R create(Class<O> objectClass, Class<L> objectListClass, K8sClient client, io.kubernetes.client.Discovery.APIResource context, O model, K8sClusterGenericStub.GenericSupplier<O,L,R> provider) throws io.kubernetes.client.openapi.ApiException
      Get an 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 K8sClusterGenericStub<O, L>> Collection<R> list(Class<O> objectClass, Class<L> objectListClass, K8sClient client, io.kubernetes.client.Discovery.APIResource context, io.kubernetes.client.util.generic.options.ListOptions options, K8sClusterGenericStub.GenericSupplier<O,L,R> provider) throws io.kubernetes.client.openapi.ApiException
      Get the stubs for the objects 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
      options - the options
      provider - the provider
      Returns:
      the collection
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception