Package io.kubernetes.client.util
Class ModelMapper
java.lang.Object
io.kubernetes.client.util.ModelMapper
Model mapper loads pre-built kubernetes models from classpath and manages their mapping between
their apiVersion and kind.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddModelMap(String apiGroupVersion, String kind, Class<?> clazz) Deprecated.static voidaddModelMap(String group, String version, String kind, Class<?> clazz) Deprecated.static voidaddModelMap(String group, String version, String kind, String resourceNamePlural, Boolean isNamespacedResource, Class<? extends io.kubernetes.client.common.KubernetesObject> objClass) Registering concrete model classes by its group, version, kind and isNamespaced (e.g.static voidaddModelMap(String group, String version, String kind, String resourceNamePlural, Boolean isNamespacedResource, Class<? extends io.kubernetes.client.common.KubernetesObject> objClass, Class<? extends io.kubernetes.client.common.KubernetesListObject> objListClass) static voidaddModelMap(String group, String version, String kind, String resourceNamePlural, Class<? extends io.kubernetes.client.common.KubernetesObject> objClass, Class<? extends io.kubernetes.client.common.KubernetesListObject> objListClass) Registering concrete model classes by its group, version and kind (e.g.static Discovery.APIResourcestatic Class<?>getApiTypeClass(String apiGroupVersion, String kind) Gets the model classes by given apiGroupVersion (e.g.static Class<?>getApiTypeClass(String group, String version, String kind) Gets the model classes by given group, version and kind (e.g.static GroupVersionKindgetGroupVersionKindByClass(Class<?> clazz) Gets the GVK by the given model class.static GroupVersionResourcegetGroupVersionResourceByClass(Class<?> clazz) Gets the GVK by the given model class.static GroupVersionKindgroupVersionKindFromApiVersionAndKind(String apiVersion, String kind) Find GroupVersionKind from fields in a Kubernetes Resourcestatic booleanstatic BooleanisNamespaced(Class<?> clazz) Checks whether the class is connected with a namespaced kubernetes resource.static Class<?>preBuiltGetApiTypeClass(String group, String version, String kind) static GroupVersionKindpreBuiltGetGroupVersionKindByClass(Class<?> clazz) static Set<Discovery.APIResource>Refreshes the model mapping by syncing up w/the api discovery info from the kubernetes apiserver.static Set<Discovery.APIResource>Refreshes the model mapping by syncing up w/the api discovery info from the kubernetes apiserver.
-
Field Details
-
DEFAULT_DISCOVERY_REFRESH_INTERVAL
-
-
Constructor Details
-
ModelMapper
public ModelMapper()
-
-
Method Details
-
addModelMap
Deprecated.Registering concrete model classes by its apiGroupVersion (e.g. "apps/v1") and kind (e.g. "Deployment").Note that the the so-called apiGroupVersion equals to the "apiVersion" in the kubenretes resource yamls.
-
addModelMap
@Deprecated public static void addModelMap(String group, String version, String kind, Class<?> clazz) Deprecated.Registering concrete model classes by its group, version and kind (e.g. "apps", "v1", "Deployment")- Parameters:
group- the groupversion- the versionkind- the kindclazz- the clazz
-
addModelMap
public static void addModelMap(String group, String version, String kind, String resourceNamePlural, Class<? extends io.kubernetes.client.common.KubernetesObject> objClass, Class<? extends io.kubernetes.client.common.KubernetesListObject> objListClass) Registering concrete model classes by its group, version and kind (e.g. "apps", "v1", "Deployment")- Parameters:
group- the groupversion- the versionkind- the kindresourceNamePlural- the resource name pluralobjClass- the clazz
-
addModelMap
public static void addModelMap(String group, String version, String kind, String resourceNamePlural, Boolean isNamespacedResource, Class<? extends io.kubernetes.client.common.KubernetesObject> objClass) Registering concrete model classes by its group, version, kind and isNamespaced (e.g. "apps", "v1", "Deployment", true).- Parameters:
group- the groupversion- the versionkind- the kindresourceNamePlural- the resource name pluralisNamespacedResource- the is namespaced resourceobjClass- the clazz
-
addModelMap
-
getApiTypeClass
Gets the model classes by given apiGroupVersion (e.g. "apps/v1") and kind (e.g. "Deployment").- Parameters:
apiGroupVersion- the api versionkind- the kind- Returns:
- the api type class
-
getApiTypeClass
Gets the model classes by given group, version and kind (e.g. "apps", ""v1", "Deployment").- Parameters:
group- the groupversion- the versionkind- the kind- Returns:
- the api type class
-
getGroupVersionKindByClass
Gets the GVK by the given model class.- Parameters:
clazz- the clazz- Returns:
- the group version kind by class
-
getGroupVersionResourceByClass
Gets the GVK by the given model class.- Parameters:
clazz- the clazz- Returns:
- the group version kind by class
-
refresh
public static Set<Discovery.APIResource> refresh(Discovery discovery) throws io.kubernetes.client.openapi.ApiException Refreshes the model mapping by syncing up w/the api discovery info from the kubernetes apiserver. These mapping will be cached forDEFAULT_DISCOVERY_REFRESH_INTERVAL.- Parameters:
discovery- the discovery- Returns:
- the set
- Throws:
io.kubernetes.client.openapi.ApiException- the api exception
-
refresh
public static Set<Discovery.APIResource> refresh(Discovery discovery, Duration refreshInterval) throws io.kubernetes.client.openapi.ApiException Refreshes the model mapping by syncing up w/the api discovery info from the kubernetes apiserver.Note: if model mappings can be incomplete if this method is never called.
- Parameters:
discovery- the discovery- Returns:
- the api-discovery set
- Throws:
io.kubernetes.client.openapi.ApiException- the api exception
-
isApiDiscoveryRefreshed
public static boolean isApiDiscoveryRefreshed() -
preBuiltGetApiTypeClass
-
preBuiltGetGroupVersionKindByClass
-
isNamespaced
Checks whether the class is connected with a namespaced kubernetes resource.- Parameters:
clazz- the clazz- Returns:
- the boolean
-
groupVersionKindFromApiVersionAndKind
public static GroupVersionKind groupVersionKindFromApiVersionAndKind(String apiVersion, String kind) Find GroupVersionKind from fields in a Kubernetes Resource- Parameters:
apiVersion- The apiVersion field from the objectkind- The kind for the object- Returns:
- the GroupVersionKind
-
findApiResourceByGroupVersionKind
-