Package org.jdrupes.vmoperator.common
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 typeL
- 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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
K8sClusterGenericStub.GenericSupplier<O extends io.kubernetes.client.common.KubernetesObject,
L extends io.kubernetes.client.common.KubernetesListObject, R extends K8sClusterGenericStub<O, L>> A supplier for generic stubs. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionio.kubernetes.client.Discovery.APIResource
context()
Gets the context.static <O extends io.kubernetes.client.common.KubernetesObject,
L extends io.kubernetes.client.common.KubernetesListObject, R extends K8sClusterGenericStub<O, L>>
Rcreate
(Class<O> objectClass, Class<L> objectListClass, K8sClient client, io.kubernetes.client.Discovery.APIResource context, O model, K8sClusterGenericStub.GenericSupplier<O, L, R> provider) Get an object stub for a newly created object.void
delete()
Delete the Kubernetes object.static <O extends io.kubernetes.client.common.KubernetesObject,
L extends io.kubernetes.client.common.KubernetesListObject, R extends K8sClusterGenericStub<O, L>>
Rget
(Class<O> objectClass, Class<L> objectListClass, K8sClient client, io.kubernetes.client.apimachinery.GroupVersionKind gvk, String name, K8sClusterGenericStub.GenericSupplier<O, L, R> provider) Get an object stub.static <O extends io.kubernetes.client.common.KubernetesObject,
L extends io.kubernetes.client.common.KubernetesListObject, R extends K8sClusterGenericStub<O, L>>
Rget
(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.group()
Gets the group.kind()
Gets the kind.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) Get the stubs for the objects that match the criteria from the given options.model()
Retrieves and returns the current state of the object.name()
Gets the name.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.plural()
Gets the plural.toString()
updateStatus
(Function<O, Object> status) Updates the status.updateStatus
(O object, Function<O, Object> status) Updates the object’s status.version()
Gets the version.
-
Field Details
-
client
-
context
-
name
-
-
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 classobjectListClass
- the object list classclient
- the clientcontext
- the contextname
- the name
-
-
Method Details
-
context
Gets the context.- Returns:
- the context
-
group
Gets the group.- Returns:
- the group
-
version
Gets the version.- Returns:
- the version
-
kind
Gets the kind.- Returns:
- the kind
-
plural
Gets the plural.- Returns:
- the plural
-
name
Gets the name.- Returns:
- the name
-
delete
Delete the Kubernetes object.- Throws:
io.kubernetes.client.openapi.ApiException
- the API exception
-
model
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.ApiExceptionUpdates the object’s status.- Parameters:
object
- the current state of the object (passed tostatus
)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.ApiExceptionUpdates 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 typepatch
- the patchoptions
- 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 typepatch
- the patch- Returns:
- the kubernetes api response
- Throws:
io.kubernetes.client.openapi.ApiException
- the api exception
-
toString
-
get
public static <O extends io.kubernetes.client.common.KubernetesObject,L extends io.kubernetes.client.common.KubernetesListObject, R getR extends K8sClusterGenericStub<O, L>> (Class<O> objectClass, Class<L> objectListClass, K8sClient client, io.kubernetes.client.apimachinery.GroupVersionKind gvk, String name, K8sClusterGenericStub.GenericSupplier<O, L, throws io.kubernetes.client.openapi.ApiExceptionR> provider) 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 typeL
- the object list typeR
- the stub type- Parameters:
objectClass
- the object classobjectListClass
- the object list classclient
- the clientgvk
- the group, version and kindname
- the nameprovider
- 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 getR extends K8sClusterGenericStub<O, L>> (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 typeL
- the object list typeR
- the stub type- Parameters:
objectClass
- the object classobjectListClass
- the object list classclient
- the clientcontext
- the contextname
- the nameprovider
- 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 createR extends K8sClusterGenericStub<O, L>> (Class<O> objectClass, Class<L> objectListClass, K8sClient client, io.kubernetes.client.Discovery.APIResource context, O model, K8sClusterGenericStub.GenericSupplier<O, L, throws io.kubernetes.client.openapi.ApiExceptionR> provider) Get an object stub for a newly created object.- Type Parameters:
O
- the object typeL
- the object list typeR
- the stub type- Parameters:
objectClass
- the object classobjectListClass
- the object list classclient
- the clientcontext
- the contextmodel
- the modelprovider
- 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, Collection<R> listR extends K8sClusterGenericStub<O, L>> (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, throws io.kubernetes.client.openapi.ApiExceptionR> provider) Get the stubs for the objects that match the criteria from the given options.- Type Parameters:
O
- the object typeL
- the object list typeR
- the stub type- Parameters:
objectClass
- the object classobjectListClass
- the object list classclient
- the clientcontext
- the contextoptions
- the optionsprovider
- the provider- Returns:
- the collection
- Throws:
io.kubernetes.client.openapi.ApiException
- the api exception
-