Class OperationSupport
- java.lang.Object
-
- io.fabric8.kubernetes.client.dsl.base.OperationSupport
-
- Direct Known Subclasses:
BaseOperation,ClusterOperationsImpl,CreateOnlyResourceOperationsImpl,KubernetesListOperationsImpl,NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableImpl,NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl,NodeMetricOperationsImpl,PodMetricOperationsImpl,RawCustomResourceOperationsImpl
public class OperationSupport extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected StringapiGroupNameprotected StringapiGroupVersionprotected okhttp3.OkHttpClientclientprotected Configconfigprotected OperationContextcontextprotected booleandryRunstatic 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, long gracePeriodInSeconds)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods 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)URLgetResourceURLForWriteOperation(URL resourceURL)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 Detail
-
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
protected OperationContext context
-
client
protected final okhttp3.OkHttpClient client
-
config
protected final Config config
-
resourceT
protected final String resourceT
-
namespace
protected String namespace
-
name
protected String name
-
apiGroupName
protected String apiGroupName
-
apiGroupVersion
protected String apiGroupVersion
-
dryRun
protected boolean dryRun
-
-
Constructor Detail
-
OperationSupport
public OperationSupport()
-
OperationSupport
public OperationSupport(okhttp3.OkHttpClient client, Config config)
-
OperationSupport
public OperationSupport(okhttp3.OkHttpClient client, Config config, String namespace, io.fabric8.kubernetes.api.model.DeletionPropagation propagationPolicy, long gracePeriodInSeconds)
-
OperationSupport
public OperationSupport(OperationContext ctx)
-
-
Method Detail
-
getAPIGroup
public String getAPIGroup()
-
getAPIVersion
public String getAPIVersion()
-
getResourceT
public String getResourceT()
-
getNamespace
public String getNamespace()
-
getName
public String getName()
-
isResourceNamespaced
public boolean isResourceNamespaced()
-
getRootUrl
public URL getRootUrl()
-
getNamespacedUrl
public URL getNamespacedUrl(String namespace) throws MalformedURLException
- Throws:
MalformedURLException
-
getNamespacedUrl
public URL getNamespacedUrl() throws MalformedURLException
- Throws:
MalformedURLException
-
getNamespacedUrl
public <T> URL getNamespacedUrl(T item) throws MalformedURLException
- Throws:
MalformedURLException
-
getResourceUrl
public URL getResourceUrl(String namespace, String name) throws MalformedURLException
- Throws:
MalformedURLException
-
getResourceUrl
public URL getResourceUrl() throws MalformedURLException
- Throws:
MalformedURLException
-
getResourceURLForWriteOperation
public URL getResourceURLForWriteOperation(URL resourceURL) throws MalformedURLException
- Throws:
MalformedURLException
-
checkNamespace
protected <T> String checkNamespace(T item)
-
checkName
protected <T> String checkName(T item)
-
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, 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 ExceptionIOException- IOException
-
handleReplace
protected <T> T handleReplace(T updated, Class<T> type) throws ExecutionException, InterruptedException, 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 ExceptionIOException- IOException
-
handleReplace
protected <T> T handleReplace(T updated, Class<T> type, Map<String,String> parameters) throws ExecutionException, InterruptedException, 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 ExceptionIOException- 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, 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 ExceptionIOException- 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 ExceptionIOException- 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, IOException
Replace 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 interruptedIOException- 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, IOException
Create rollback of a Deployment- Parameters:
resourceUrl- resource urldeploymentRollback- DeploymentRollback resource- Returns:
- Status
- Throws:
ExecutionException- in case of any execution exceptionInterruptedException- in case thread is interruptedIOException- in some other I/O problem
-
handleGet
protected <T> T handleGet(URL resourceUrl, Class<T> type) throws ExecutionException, InterruptedException, IOException
Send 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 ExceptionIOException- IOException
-
handleGet
protected <T> T handleGet(URL resourceUrl, Class<T> type, Map<String,String> parameters) throws ExecutionException, InterruptedException, IOException
Send 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 ExceptionIOException- IOException
-
handleResponse
protected <T> T handleResponse(okhttp3.Request.Builder requestBuilder, Class<T> type) throws ExecutionException, InterruptedException, 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 ExceptionIOException- IOException
-
handleResponse
protected <T> T handleResponse(okhttp3.Request.Builder requestBuilder, Class<T> type, Map<String,String> parameters) throws ExecutionException, InterruptedException, 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 ExceptionIOException- IOException
-
handleResponse
protected <T> T handleResponse(okhttp3.OkHttpClient client, okhttp3.Request.Builder requestBuilder, Class<T> type) throws ExecutionException, InterruptedException, 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 ExceptionIOException- IOException
-
handleResponse
protected <T> T handleResponse(okhttp3.OkHttpClient client, okhttp3.Request.Builder requestBuilder, Class<T> type, Map<String,String> parameters) throws ExecutionException, InterruptedException, 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 ExceptionIOException- 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.
-
createStatus
public static io.fabric8.kubernetes.api.model.Status createStatus(okhttp3.Response response)
-
createStatus
public static io.fabric8.kubernetes.api.model.Status createStatus(int statusCode, String message)
-
requestFailure
public static KubernetesClientException requestFailure(okhttp3.Request request, io.fabric8.kubernetes.api.model.Status status)
-
requestException
public static KubernetesClientException requestException(okhttp3.Request request, Exception e)
-
unmarshal
protected static <T> T unmarshal(InputStream is)
-
unmarshal
protected static <T> T unmarshal(InputStream is, Class<T> type)
-
unmarshal
protected static <T> T unmarshal(InputStream is, com.fasterxml.jackson.core.type.TypeReference<T> type)
-
getObjectValueAsMap
protected static <T> Map getObjectValueAsMap(T object)
-
getConfig
public Config getConfig()
-
-