Class OperationSupport
java.lang.Object
io.fabric8.kubernetes.client.dsl.base.OperationSupport
- Direct Known Subclasses:
BaseOperation,ClusterOperationsImpl,KubernetesListOperationsImpl,NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl,NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl,NodeMetricOperationsImpl,PodMetricOperationsImpl,RawCustomResourceOperationsImpl,SubjectAccessReviewDSLImpl
public class OperationSupport extends Object
-
Field Summary
Fields Modifier and Type Field Description protected StringapiGroupNameprotected StringapiGroupVersionprotected okhttp3.OkHttpClientclientprotected Configconfigprotected OperationContextcontextstatic okhttp3.MediaTypeJSONprotected static com.fasterxml.jackson.databind.ObjectMapperJSON_MAPPERstatic okhttp3.MediaTypeJSON_PATCHprotected Stringnameprotected Stringnamespaceprotected StringresourceTstatic okhttp3.MediaTypeSTRATEGIC_MERGE_JSON_PATCHprotected static com.fasterxml.jackson.databind.ObjectMapperYAML_MAPPER -
Constructor Summary
Constructors Constructor Description OperationSupport()OperationSupport(OperationContext ctx)OperationSupport(okhttp3.OkHttpClient client, Config config)OperationSupport(okhttp3.OkHttpClient client, Config config, String namespace, io.fabric8.kubernetes.api.model.DeletionPropagation propagationPolicy) -
Method Summary
Modifier and Type Method Description protected voidassertResponseCode(okhttp3.Request request, okhttp3.Response response)Checks if the response status code is the expected and throws the appropriate KubernetesClientException if not.protected <T> StringcheckName(T item)protected <T> StringcheckNamespace(T item)static io.fabric8.kubernetes.api.model.StatuscreateStatus(int statusCode, String message)static io.fabric8.kubernetes.api.model.StatuscreateStatus(okhttp3.Response response)StringgetAPIGroup()StringgetAPIVersion()ConfiggetConfig()StringgetName()StringgetNamespace()URLgetNamespacedUrl()URLgetNamespacedUrl(String namespace)<T> URLgetNamespacedUrl(T item)protected static <T> MapgetObjectValueAsMap(T object)StringgetResourceT()URLgetResourceUrl()URLgetResourceUrl(String namespace, String name)URLgetRootUrl()protected <T, I> ThandleCreate(I resource, Class<T> outputType)Create a resource.protected voidhandleDelete(URL requestUrl, long gracePeriodSeconds, io.fabric8.kubernetes.api.model.DeletionPropagation propagationPolicy, boolean cascading)protected <T> voidhandleDelete(T resource, long gracePeriodSeconds, io.fabric8.kubernetes.api.model.DeletionPropagation propagationPolicy, boolean cascading)protected io.fabric8.kubernetes.api.model.StatushandleDeploymentRollback(String resourceUrl, io.fabric8.kubernetes.api.model.extensions.DeploymentRollback deploymentRollback)Create rollback of a Deploymentprotected <T> ThandleGet(URL resourceUrl, Class<T> type)Send an http get.protected <T> ThandleGet(URL resourceUrl, Class<T> type, Map<String,String> parameters)Send an http, optionally performing placeholder substitution to the response.protected <T> ThandleMetric(String resourceUrl, Class<T> type)protected <T> ThandlePatch(T current, Map<String,Object> patchForUpdate, Class<T> type)Send an http patch and handle the response.protected <T> ThandlePatch(T current, T updated, Class<T> type)Send an http patch and handle the response.protected <T> ThandleReplace(T updated, Class<T> type)Replace a resource.protected <T> ThandleReplace(T updated, Class<T> type, Map<String,String> parameters)Replace a resource, optionally performing placeholder substitution to the response.protected <T> ThandleResponse(okhttp3.OkHttpClient client, okhttp3.Request.Builder requestBuilder, Class<T> type)Send an http request and handle the response.protected <T> ThandleResponse(okhttp3.OkHttpClient client, okhttp3.Request.Builder requestBuilder, Class<T> type, Map<String,String> parameters)Send an http request and handle the response, optionally performing placeholder substitution to the response.protected <T> ThandleResponse(okhttp3.Request.Builder requestBuilder, Class<T> type)Send an http request and handle the response.protected <T> ThandleResponse(okhttp3.Request.Builder requestBuilder, Class<T> type, Map<String,String> parameters)Send an http request and handle the response, optionally performing placeholder substitution to the response.protected io.fabric8.kubernetes.api.model.autoscaling.v1.ScalehandleScale(String resourceUrl, io.fabric8.kubernetes.api.model.autoscaling.v1.Scale scale)Replace Scale of specified Kubernetes Resourceprotected <T> ThandleStatusUpdate(T updated, Class<T> type)booleanisResourceNamespaced()static KubernetesClientExceptionrequestException(okhttp3.Request request, Exception e)static KubernetesClientExceptionrequestFailure(okhttp3.Request request, io.fabric8.kubernetes.api.model.Status status)protected static <T> Tunmarshal(InputStream is)protected static <T> Tunmarshal(InputStream is, com.fasterxml.jackson.core.type.TypeReference<T> type)protected static <T> Tunmarshal(InputStream is, Class<T> type)
-
Field Details
-
JSON
public static final okhttp3.MediaType JSON -
JSON_PATCH
public static final okhttp3.MediaType JSON_PATCH -
STRATEGIC_MERGE_JSON_PATCH
public static final okhttp3.MediaType STRATEGIC_MERGE_JSON_PATCH -
JSON_MAPPER
protected static final com.fasterxml.jackson.databind.ObjectMapper JSON_MAPPER -
YAML_MAPPER
protected static final com.fasterxml.jackson.databind.ObjectMapper YAML_MAPPER -
context
-
client
protected final okhttp3.OkHttpClient client -
config
-
resourceT
-
namespace
-
name
-
apiGroupName
-
apiGroupVersion
-
-
Constructor Details
-
OperationSupport
public OperationSupport() -
OperationSupport
-
OperationSupport
-
OperationSupport
-
-
Method Details
-
getAPIGroup
-
getAPIVersion
-
getResourceT
-
getNamespace
-
getName
-
isResourceNamespaced
public boolean isResourceNamespaced() -
getRootUrl
-
getNamespacedUrl
- Throws:
MalformedURLException
-
getNamespacedUrl
- Throws:
MalformedURLException
-
getNamespacedUrl
- Throws:
MalformedURLException
-
getResourceUrl
- Throws:
MalformedURLException
-
getResourceUrl
- Throws:
MalformedURLException
-
checkNamespace
-
checkName
-
handleMetric
protected <T> T handleMetric(String resourceUrl, Class<T> type) throws InterruptedException, IOException, ExecutionException -
handleDelete
protected <T> void handleDelete(T resource, long gracePeriodSeconds, io.fabric8.kubernetes.api.model.DeletionPropagation propagationPolicy, boolean cascading) throws ExecutionException, InterruptedException, IOException -
handleDelete
protected void handleDelete(URL requestUrl, long gracePeriodSeconds, io.fabric8.kubernetes.api.model.DeletionPropagation propagationPolicy, boolean cascading) throws ExecutionException, InterruptedException, IOException -
handleCreate
protected <T, I> T handleCreate(I resource, Class<T> outputType) throws ExecutionException, InterruptedException, KubernetesClientException, IOExceptionCreate a resource.- Type Parameters:
T- template argument for output typeI- template argument for resource- Parameters:
resource- resource providedoutputType- resource type you want as output- Returns:
- returns de-serialized version of apiserver response in form of type provided
- Throws:
ExecutionException- Execution ExceptionInterruptedException- Interrupted ExceptionKubernetesClientException- KubernetesClientExceptionIOException- IOException
-
handleReplace
protected <T> T handleReplace(T updated, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOExceptionReplace a resource.- Type Parameters:
T- template argument provided- Parameters:
updated- updated objecttype- type of the object provided- Returns:
- returns de-serialized version of api server response
- Throws:
ExecutionException- Execution ExceptionInterruptedException- Interrupted ExceptionKubernetesClientException- KubernetesClientExceptionIOException- IOException
-
handleReplace
protected <T> T handleReplace(T updated, Class<T> type, Map<String,String> parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOExceptionReplace a resource, optionally performing placeholder substitution to the response.- Type Parameters:
T- template argument provided- Parameters:
updated- updated objecttype- type of object providedparameters- a HashMap containing parameters for processing object- Returns:
- returns de-serialized version of api server response.
- Throws:
ExecutionException- Execution ExceptionInterruptedException- Interrupted ExceptionKubernetesClientException- KubernetesClientExceptionIOException- IOException
-
handleStatusUpdate
protected <T> T handleStatusUpdate(T updated, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOException -
handlePatch
protected <T> T handlePatch(T current, T updated, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOExceptionSend an http patch and handle the response.- Type Parameters:
T- template argument provided- Parameters:
current- current objectupdated- updated objecttype- type of object- Returns:
- returns de-serialized version of api server response
- Throws:
ExecutionException- Execution ExceptionInterruptedException- Interrupted ExceptionKubernetesClientException- KubernetesClientExceptionIOException- IOException
-
handlePatch
protected <T> T handlePatch(T current, Map<String,Object> patchForUpdate, Class<T> type) throws ExecutionException, InterruptedException, IOExceptionSend an http patch and handle the response.- Type Parameters:
T- template argument provided- Parameters:
current- current objectpatchForUpdate- updated object spec as json stringtype- type of object- Returns:
- returns de-serialized version of api server response
- Throws:
ExecutionException- Execution ExceptionInterruptedException- Interrupted ExceptionKubernetesClientException- KubernetesClientExceptionIOException- IOException
-
handleScale
protected io.fabric8.kubernetes.api.model.autoscaling.v1.Scale handleScale(String resourceUrl, io.fabric8.kubernetes.api.model.autoscaling.v1.Scale scale) throws ExecutionException, InterruptedException, KubernetesClientException, MalformedURLException, com.fasterxml.jackson.core.JsonProcessingException, IOExceptionReplace Scale of specified Kubernetes Resource- Parameters:
resourceUrl- Kubernetes resource URLscale- Scale object which we want to inject- Returns:
- updated Scale object
- Throws:
ExecutionException- in case of any execution exceptionInterruptedException- in case thread is interruptedKubernetesClientException- in case error from Kubernetes APIMalformedURLException- in case URL formed in invalidcom.fasterxml.jackson.core.JsonProcessingException- in case Json processing failsIOException- in some other I/O problem
-
handleDeploymentRollback
protected io.fabric8.kubernetes.api.model.Status handleDeploymentRollback(String resourceUrl, io.fabric8.kubernetes.api.model.extensions.DeploymentRollback deploymentRollback) throws ExecutionException, InterruptedException, KubernetesClientException, MalformedURLException, com.fasterxml.jackson.core.JsonProcessingException, IOExceptionCreate rollback of a Deployment- Parameters:
resourceUrl- resource urldeploymentRollback- DeploymentRollback resource- Returns:
- Status
- Throws:
ExecutionException- in case of any execution exceptionInterruptedException- in case thread is interruptedKubernetesClientException- in case error from Kubernetes APIMalformedURLException- in case URL formed in invalidcom.fasterxml.jackson.core.JsonProcessingException- in case Json processing failsIOException- in some other I/O problem
-
handleGet
protected <T> T handleGet(URL resourceUrl, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOExceptionSend an http get.- Type Parameters:
T- template argument provided- Parameters:
resourceUrl- resource URL to be processedtype- type of resource- Returns:
- returns a deserialized object as api server response of provided type.
- Throws:
ExecutionException- Execution ExceptionInterruptedException- Interrupted ExceptionKubernetesClientException- KubernetesClientExceptionIOException- IOException
-
handleGet
protected <T> T handleGet(URL resourceUrl, Class<T> type, Map<String,String> parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOExceptionSend an http, optionally performing placeholder substitution to the response.- Type Parameters:
T- template argument provided- Parameters:
resourceUrl- resource URL to be processedtype- type of resourceparameters- A HashMap of strings containing parameters to be passed in request- Returns:
- Returns a deserialized object as api server response of provided type.
- Throws:
ExecutionException- Execution ExceptionInterruptedException- Interrupted ExceptionKubernetesClientException- KubernetesClientExceptionIOException- IOException
-
handleResponse
protected <T> T handleResponse(okhttp3.Request.Builder requestBuilder, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOExceptionSend an http request and handle the response.- Type Parameters:
T- template argument provided- Parameters:
requestBuilder- Request Builder objecttype- type of resource- Returns:
- Returns a de-serialized object as api server response of provided type.
- Throws:
ExecutionException- Execution ExceptionInterruptedException- Interrupted ExceptionKubernetesClientException- KubernetesClientExceptionIOException- IOException
-
handleResponse
protected <T> T handleResponse(okhttp3.Request.Builder requestBuilder, Class<T> type, Map<String,String> parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOExceptionSend an http request and handle the response, optionally performing placeholder substitution to the response.- Type Parameters:
T- template argument provided- Parameters:
requestBuilder- request buildertype- type of objectparameters- a hashmap containing parameters- Returns:
- Returns a de-serialized object as api server response of provided type.
- Throws:
ExecutionException- Execution ExceptionInterruptedException- Interrupted ExceptionKubernetesClientException- KubernetesClientExceptionIOException- IOException
-
handleResponse
protected <T> T handleResponse(okhttp3.OkHttpClient client, okhttp3.Request.Builder requestBuilder, Class<T> type) throws ExecutionException, InterruptedException, KubernetesClientException, IOExceptionSend an http request and handle the response.- Type Parameters:
T- template argument provided- Parameters:
client- OkHttp client objectrequestBuilder- request buildertype- type of object- Returns:
- Returns a de-serialized object as api server response of provided type.
- Throws:
ExecutionException- Execution ExceptionInterruptedException- Interrupted ExceptionKubernetesClientException- KubernetesClientExceptionIOException- IOException
-
handleResponse
protected <T> T handleResponse(okhttp3.OkHttpClient client, okhttp3.Request.Builder requestBuilder, Class<T> type, Map<String,String> parameters) throws ExecutionException, InterruptedException, KubernetesClientException, IOExceptionSend an http request and handle the response, optionally performing placeholder substitution to the response.- Type Parameters:
T- Template argument provided- Parameters:
client- OkHttp client providedrequestBuilder- Request buildertype- Type of object providedparameters- A hashmap containing parameters- Returns:
- Returns a de-serialized object as api server response of provided type.
- Throws:
ExecutionException- Execution ExceptionInterruptedException- Interrupted ExceptionKubernetesClientException- KubernetesClientExceptionIOException- IOException
-
assertResponseCode
protected void assertResponseCode(okhttp3.Request request, okhttp3.Response response)Checks if the response status code is the expected and throws the appropriate KubernetesClientException if not.- Parameters:
request- The {#link Request} object.response- TheResponseobject.- Throws:
KubernetesClientException- When the response code is not the expected.
-
createStatus
public static io.fabric8.kubernetes.api.model.Status createStatus(okhttp3.Response response) -
createStatus
-
requestFailure
public static KubernetesClientException requestFailure(okhttp3.Request request, io.fabric8.kubernetes.api.model.Status status) -
requestException
-
unmarshal
- Throws:
KubernetesClientException
-
unmarshal
- Throws:
KubernetesClientException
-
unmarshal
protected static <T> T unmarshal(InputStream is, com.fasterxml.jackson.core.type.TypeReference<T> type) throws KubernetesClientException- Throws:
KubernetesClientException
-
getObjectValueAsMap
-
getConfig
-