Class GenericKubernetesApi<ApiType extends io.kubernetes.client.common.KubernetesObject,ApiListType extends io.kubernetes.client.common.KubernetesListObject>
- Type Parameters:
ApiType
- the api type parameterApiListType
- the api list type parameter
- Direct Known Subclasses:
DynamicKubernetesApi
1. there's a `V1ObjectMeta` field in the model along with its getter/setter. 2. there's a `V1ListMeta` field in the list model along with its getter/setter. - supports Gson serialization/deserialization. 3. the generic kubernetes api covers all the basic operations over the custom resources including {get, list, watch, create, update, patch, delete}.
The Generic kubernetes api is expected to have the following behaviors upon failures where
KubernetesApiResponse.isSuccess()
returns false:
- For kubernetes-defined failures, the server will return a V1Status
with 4xx/5xx
code. The status object will be nested in KubernetesApiResponse.getStatus()
- For the
other unknown reason (including network, JVM..), throws an unchecked exception.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionGenericKubernetesApi
(Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural) Instantiates a new Generic kubernetes api.GenericKubernetesApi
(Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural, io.kubernetes.client.openapi.ApiClient apiClient) Instantiates a new Generic kubernetes api.GenericKubernetesApi
(Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural, io.kubernetes.client.openapi.apis.CustomObjectsApi customObjectsApi) Instantiates a new Generic kubernetes api with the ApiClient specified. -
Method Summary
Modifier and TypeMethodDescriptionCreate kubernetes api response, if the namespace in the object is present, it will send a namespace-scoped requests, vice versa.create
(ApiType object, CreateOptions createOptions) Create kubernetes api response.create
(String namespace, ApiType object, CreateOptions createOptions) Delete kubernetes api response.delete
(String name, DeleteOptions deleteOptions) Delete kubernetes api response.Delete kubernetes api response under the namespace.delete
(String namespace, String name, DeleteOptions deleteOptions) Delete kubernetes api response.Get kubernetes api response.get
(String name, GetOptions getOptions) Get kubernetes api response.Get kubernetes api response under the namespace.get
(String namespace, String name, GetOptions getOptions) Get kubernetes api response.list()
List kubernetes api response cluster-scoped.list
(ListOptions listOptions) List kubernetes api response.List kubernetes api response under the namespace.list
(String namespace, ListOptions listOptions) List kubernetes api response.Patch kubernetes api response.patch
(String name, String patchType, io.kubernetes.client.custom.V1Patch patch, PatchOptions patchOptions) Patch kubernetes api response.Patch kubernetes api response under the namespace.patch
(String namespace, String name, String patchType, io.kubernetes.client.custom.V1Patch patch, PatchOptions patchOptions) Patch kubernetes api response.Create kubernetes api response, if the namespace in the object is present, it will send a namespace-scoped requests, vice versa.update
(ApiType object, UpdateOptions updateOptions) Update kubernetes api response.updateStatus
(ApiType object, Function<ApiType, Object> status) Create kubernetes api response, if the namespace in the object is present, it will send a namespace-scoped requests, vice versa.updateStatus
(ApiType object, Function<ApiType, Object> status, UpdateOptions updateOptions) Update status of kubernetes api response.watch()
Creates a cluster-scoped Watch on the resource.watch
(ListOptions listOptions) Watch watchable.Creates a namespace-scoped Watch on the resource.watch
(String namespace, ListOptions listOptions) Watch watchable.
-
Constructor Details
-
GenericKubernetesApi
public GenericKubernetesApi(Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural) Instantiates a new Generic kubernetes api.- Parameters:
apiTypeClass
- the api type classapiListTypeClass
- the api list type classapiGroup
- the api groupapiVersion
- the api versionresourcePlural
- the resource plural
-
GenericKubernetesApi
public GenericKubernetesApi(Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural, io.kubernetes.client.openapi.ApiClient apiClient) Instantiates a new Generic kubernetes api.- Parameters:
apiTypeClass
- the api type class, e.g. V1Job.classapiListTypeClass
- the api list type class e.g V1JobList.classapiGroup
- the api groupapiVersion
- the api versionresourcePlural
- the resource plural, e.g. "jobs"apiClient
- the api client
-
GenericKubernetesApi
public GenericKubernetesApi(Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural, io.kubernetes.client.openapi.apis.CustomObjectsApi customObjectsApi) Instantiates a new Generic kubernetes api with the ApiClient specified.- Parameters:
apiTypeClass
- the api type class, e.g. V1Job.classapiListTypeClass
- the api list type class e.g V1JobList.classapiGroup
- the api groupapiVersion
- the api versionresourcePlural
- the resource plural, e.g. "jobs"customObjectsApi
- the custom objects api
-
-
Method Details
-
get
Get kubernetes api response.- Parameters:
name
- the name- Returns:
- the kubernetes api response
-
get
Get kubernetes api response under the namespace.- Parameters:
namespace
- the namespacename
- the name- Returns:
- the kubernetes api response
-
list
List kubernetes api response cluster-scoped.- Returns:
- the kubernetes api response
-
list
List kubernetes api response under the namespace.- Parameters:
namespace
- the namespace- Returns:
- the kubernetes api response
-
create
Create kubernetes api response, if the namespace in the object is present, it will send a namespace-scoped requests, vice versa.- Parameters:
object
- the object- Returns:
- the kubernetes api response
-
update
Create kubernetes api response, if the namespace in the object is present, it will send a namespace-scoped requests, vice versa.- Parameters:
object
- the object- Returns:
- the kubernetes api response
-
patch
public KubernetesApiResponse<ApiType> patch(String name, String patchType, io.kubernetes.client.custom.V1Patch patch) Patch kubernetes api response.- Parameters:
name
- the namepatchType
- the patch type, supported values defined in V1Patchpatch
- the string patch content- Returns:
- the kubernetes api response
-
patch
public KubernetesApiResponse<ApiType> patch(String namespace, String name, String patchType, io.kubernetes.client.custom.V1Patch patch) Patch kubernetes api response under the namespace.- Parameters:
namespace
- the namespacename
- the namepatchType
- the patch type, supported values defined in V1Patchpatch
- the string patch content- Returns:
- the kubernetes api response
-
delete
Delete kubernetes api response.- Parameters:
name
- the name- Returns:
- the kubernetes api response
-
delete
Delete kubernetes api response under the namespace.- Parameters:
namespace
- the namespacename
- the name- Returns:
- the kubernetes api response
-
watch
Creates a cluster-scoped Watch on the resource.- Returns:
- the watchable
- Throws:
io.kubernetes.client.openapi.ApiException
- the api exception
-
watch
Creates a namespace-scoped Watch on the resource.- Parameters:
namespace
- the namespace- Returns:
- the watchable
- Throws:
io.kubernetes.client.openapi.ApiException
- the api exception
-
get
Get kubernetes api response.- Parameters:
name
- the namegetOptions
- the get options- Returns:
- the kubernetes api response
-
get
Get kubernetes api response.- Parameters:
namespace
- the namespacename
- the namegetOptions
- the get options- Returns:
- the kubernetes api response
-
list
List kubernetes api response.- Parameters:
listOptions
- the list options- Returns:
- the kubernetes api response
-
list
List kubernetes api response.- Parameters:
namespace
- the namespacelistOptions
- the list options- Returns:
- the kubernetes api response
-
create
Create kubernetes api response.- Parameters:
object
- the objectcreateOptions
- the create options- Returns:
- the kubernetes api response
-
create
public KubernetesApiResponse<ApiType> create(String namespace, ApiType object, CreateOptions createOptions) -
update
Update kubernetes api response.- Parameters:
object
- the objectupdateOptions
- the update options- Returns:
- the kubernetes api response
-
updateStatus
Create kubernetes api response, if the namespace in the object is present, it will send a namespace-scoped requests, vice versa.- Parameters:
object
- the objectstatus
- function to extract the status from the object- Returns:
- the kubernetes api response
-
updateStatus
public KubernetesApiResponse<ApiType> updateStatus(ApiType object, Function<ApiType, Object> status, UpdateOptions updateOptions) Update status of kubernetes api response.- Parameters:
object
- the objectstatus
- function to extract the status from the objectupdateOptions
- the update options- Returns:
- the kubernetes api response
-
patch
public KubernetesApiResponse<ApiType> patch(String name, String patchType, io.kubernetes.client.custom.V1Patch patch, PatchOptions patchOptions) Patch kubernetes api response.- Parameters:
name
- the namepatchType
- the patch typepatch
- the patchpatchOptions
- the patch options- Returns:
- the kubernetes api response
-
patch
public KubernetesApiResponse<ApiType> patch(String namespace, String name, String patchType, io.kubernetes.client.custom.V1Patch patch, PatchOptions patchOptions) Patch kubernetes api response.- Parameters:
namespace
- the namespacename
- the namepatchType
- the patch typepatch
- the patchpatchOptions
- the patch options- Returns:
- the kubernetes api response
-
delete
Delete kubernetes api response.- Parameters:
name
- the namedeleteOptions
- the delete options- Returns:
- the kubernetes api response
-
delete
public KubernetesApiResponse<ApiType> delete(String namespace, String name, DeleteOptions deleteOptions) Delete kubernetes api response.- Parameters:
namespace
- the namespacename
- the namedeleteOptions
- the delete options- Returns:
- the kubernetes api response
-
watch
public Watchable<ApiType> watch(ListOptions listOptions) throws io.kubernetes.client.openapi.ApiException Watch watchable.- Parameters:
listOptions
- the list options- Returns:
- the watchable
- Throws:
io.kubernetes.client.openapi.ApiException
- the api exception
-
watch
public Watchable<ApiType> watch(String namespace, ListOptions listOptions) throws io.kubernetes.client.openapi.ApiException Watch watchable.- Parameters:
namespace
- the namespacelistOptions
- the list options- Returns:
- the watchable
- Throws:
io.kubernetes.client.openapi.ApiException
- the api exception
-