public class OperationSupport extends Object
Modifier and Type | Field and Description |
---|---|
protected String |
apiGroupName |
protected String |
apiGroupVersion |
protected Config |
config |
protected OperationContext |
context |
protected boolean |
dryRun |
protected HttpClient |
httpClient |
static String |
JSON |
protected static com.fasterxml.jackson.databind.ObjectMapper |
JSON_MAPPER |
static String |
JSON_MERGE_PATCH |
static String |
JSON_PATCH |
protected String |
name |
protected String |
namespace |
protected String |
resourceT |
static String |
STRATEGIC_MERGE_JSON_PATCH |
protected static com.fasterxml.jackson.databind.ObjectMapper |
YAML_MAPPER |
Constructor and Description |
---|
OperationSupport() |
OperationSupport(HttpClient client,
Config config) |
OperationSupport(OperationContext ctx) |
Modifier and Type | Method and Description |
---|---|
protected void |
assertResponseCode(HttpRequest request,
HttpResponse<?> response)
Checks if the response status code is the expected and throws the appropriate KubernetesClientException if not.
|
protected <T> String |
checkName(T item) |
protected <T> String |
checkNamespace(T item) |
static io.fabric8.kubernetes.api.model.Status |
createStatus(HttpResponse<?> response) |
static io.fabric8.kubernetes.api.model.Status |
createStatus(int statusCode,
String message) |
String |
getAPIGroupName() |
String |
getAPIGroupVersion() |
Config |
getConfig() |
String |
getName() |
String |
getNamespace() |
URL |
getNamespacedUrl() |
URL |
getNamespacedUrl(String namespace) |
<T> URL |
getNamespacedUrl(T item) |
protected static <T> Map |
getObjectValueAsMap(T object) |
String |
getResourceT() |
URL |
getResourceUrl() |
URL |
getResourceUrl(String namespace,
String name) |
URL |
getResourceUrl(String namespace,
String name,
boolean status) |
URL |
getResourceURLForPatchOperation(URL resourceUrl,
PatchContext patchContext) |
URL |
getResourceURLForWriteOperation(URL resourceURL) |
URL |
getRootUrl() |
protected <T,I> T |
handleCreate(I resource,
Class<T> outputType)
Create a resource.
|
protected <T> void |
handleDelete(T resource,
long gracePeriodSeconds,
io.fabric8.kubernetes.api.model.DeletionPropagation propagationPolicy,
String resourceVersion,
boolean cascading) |
protected void |
handleDelete(URL requestUrl,
long gracePeriodSeconds,
io.fabric8.kubernetes.api.model.DeletionPropagation propagationPolicy,
String resourceVersion,
boolean cascading) |
protected io.fabric8.kubernetes.api.model.Status |
handleDeploymentRollback(String resourceUrl,
io.fabric8.kubernetes.api.model.extensions.DeploymentRollback deploymentRollback)
Create rollback of a Deployment
|
protected <T> T |
handleGet(URL resourceUrl,
Class<T> type)
Send an http get.
|
protected <T> T |
handleGet(URL resourceUrl,
Class<T> type,
Map<String,String> parameters)
Send an http, optionally performing placeholder substitution to the response.
|
protected <T> T |
handleMetric(String resourceUrl,
Class<T> type) |
protected <T> T |
handlePatch(PatchContext patchContext,
T current,
String patchForUpdate,
Class<T> type,
boolean status)
Send an http patch and handle the response.
|
protected <T> T |
handlePatch(PatchContext patchContext,
T current,
T updated,
Class<T> type,
boolean status)
Send an http patch and handle the response.
|
protected <T> T |
handlePatch(T current,
Map<String,Object> patchForUpdate,
Class<T> type)
Send an http patch and handle the response.
|
protected <T> T |
handleRawGet(URL resourceUrl,
Class<T> type)
Send a raw get - where the type should be one of String, Reader, InputStream
NOTE: Currently does not utilize the retry logic |
protected <T> T |
handleResponse(HttpClient client,
HttpRequest.Builder requestBuilder,
Class<T> type)
Send an http request and handle the response.
|
protected <T> T |
handleResponse(HttpClient client,
HttpRequest.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> T |
handleResponse(HttpRequest.Builder requestBuilder,
Class<T> type)
Send an http request and handle the response.
|
protected <T> T |
handleResponse(HttpRequest.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.Scale |
handleScale(String resourceUrl,
io.fabric8.kubernetes.api.model.autoscaling.v1.Scale scale)
Replace Scale of specified Kubernetes Resource
|
protected <T> T |
handleUpdate(T updated,
Class<T> type,
boolean status)
Replace a resource.
|
protected <T> T |
handleUpdate(T updated,
Class<T> type,
Map<String,String> parameters,
boolean status)
Update a resource, optionally performing placeholder substitution to the response.
|
boolean |
isResourceNamespaced() |
static KubernetesClientException |
requestException(HttpRequest request,
Exception e) |
static KubernetesClientException |
requestException(HttpRequest request,
Throwable e,
String message) |
static KubernetesClientException |
requestFailure(HttpRequest request,
io.fabric8.kubernetes.api.model.Status status) |
static KubernetesClientException |
requestFailure(HttpRequest request,
io.fabric8.kubernetes.api.model.Status status,
String message) |
<R1> R1 |
restCall(Class<R1> result,
String... path) |
protected HttpResponse<InputStream> |
retryWithExponentialBackoff(HttpClient client,
HttpRequest request) |
protected static <T> T |
unmarshal(InputStream is) |
protected static <T> T |
unmarshal(InputStream is,
Class<T> type) |
protected static <T> T |
unmarshal(InputStream is,
com.fasterxml.jackson.core.type.TypeReference<T> type) |
public static final String JSON
public static final String JSON_PATCH
public static final String STRATEGIC_MERGE_JSON_PATCH
public static final String JSON_MERGE_PATCH
protected static final com.fasterxml.jackson.databind.ObjectMapper JSON_MAPPER
protected static final com.fasterxml.jackson.databind.ObjectMapper YAML_MAPPER
protected OperationContext context
protected final HttpClient httpClient
protected final Config config
protected final String resourceT
protected String namespace
protected String name
protected String apiGroupName
protected String apiGroupVersion
protected boolean dryRun
public OperationSupport()
public OperationSupport(HttpClient client, Config config)
public OperationSupport(OperationContext ctx)
public String getAPIGroupName()
public String getAPIGroupVersion()
public String getResourceT()
public String getNamespace()
public String getName()
public boolean isResourceNamespaced()
public URL getRootUrl()
public URL getNamespacedUrl(String namespace) throws MalformedURLException
MalformedURLException
public URL getNamespacedUrl() throws MalformedURLException
MalformedURLException
public <T> URL getNamespacedUrl(T item) throws MalformedURLException
MalformedURLException
public URL getResourceUrl(String namespace, String name) throws MalformedURLException
MalformedURLException
public URL getResourceUrl(String namespace, String name, boolean status) throws MalformedURLException
MalformedURLException
public URL getResourceUrl() throws MalformedURLException
MalformedURLException
public URL getResourceURLForWriteOperation(URL resourceURL) throws MalformedURLException
MalformedURLException
public URL getResourceURLForPatchOperation(URL resourceUrl, PatchContext patchContext) throws MalformedURLException
MalformedURLException
protected <T> String checkNamespace(T item)
protected <T> String checkName(T item)
protected <T> T handleMetric(String resourceUrl, Class<T> type) throws InterruptedException, IOException
InterruptedException
IOException
protected <T> void handleDelete(T resource, long gracePeriodSeconds, io.fabric8.kubernetes.api.model.DeletionPropagation propagationPolicy, String resourceVersion, boolean cascading) throws InterruptedException, IOException
InterruptedException
IOException
protected void handleDelete(URL requestUrl, long gracePeriodSeconds, io.fabric8.kubernetes.api.model.DeletionPropagation propagationPolicy, String resourceVersion, boolean cascading) throws InterruptedException, IOException
InterruptedException
IOException
protected <T,I> T handleCreate(I resource, Class<T> outputType) throws InterruptedException, IOException
T
- template argument for output typeI
- template argument for resourceresource
- resource providedoutputType
- resource type you want as outputInterruptedException
- Interrupted ExceptionIOException
- IOExceptionprotected <T> T handleUpdate(T updated, Class<T> type, boolean status) throws InterruptedException, IOException
T
- template argument providedupdated
- updated objecttype
- type of the object providedstatus
- if this is only the status subresourceInterruptedException
- Interrupted ExceptionIOException
- IOExceptionprotected <T> T handleUpdate(T updated, Class<T> type, Map<String,String> parameters, boolean status) throws InterruptedException, IOException
T
- template argument providedupdated
- updated objecttype
- type of object providedparameters
- a HashMap containing parameters for processing objectstatus
- if this is only the status subresourceInterruptedException
- Interrupted ExceptionIOException
- IOExceptionprotected <T> T handlePatch(PatchContext patchContext, T current, T updated, Class<T> type, boolean status) throws InterruptedException, IOException
T
- template argument providedpatchContext
- patch options for patch requestcurrent
- current objectupdated
- updated objecttype
- type of objectstatus
- if this is only the status subresourceInterruptedException
- Interrupted ExceptionIOException
- IOExceptionprotected <T> T handlePatch(T current, Map<String,Object> patchForUpdate, Class<T> type) throws InterruptedException, IOException
T
- template argument providedcurrent
- current objectpatchForUpdate
- updated object spec as json stringtype
- type of objectInterruptedException
- Interrupted ExceptionIOException
- IOExceptionprotected <T> T handlePatch(PatchContext patchContext, T current, String patchForUpdate, Class<T> type, boolean status) throws InterruptedException, IOException
T
- template argument providedpatchContext
- patch options for patch requestcurrent
- current objectpatchForUpdate
- Patch stringtype
- type of objectstatus
- if this is only the status subresourceInterruptedException
- Interrupted ExceptionIOException
- IOException in case of network errorsprotected io.fabric8.kubernetes.api.model.autoscaling.v1.Scale handleScale(String resourceUrl, io.fabric8.kubernetes.api.model.autoscaling.v1.Scale scale) throws InterruptedException, IOException
resourceUrl
- Kubernetes resource URLscale
- Scale object which we want to injectInterruptedException
- in case thread is interruptedIOException
- in some other I/O problemprotected io.fabric8.kubernetes.api.model.Status handleDeploymentRollback(String resourceUrl, io.fabric8.kubernetes.api.model.extensions.DeploymentRollback deploymentRollback) throws InterruptedException, IOException
resourceUrl
- resource urldeploymentRollback
- DeploymentRollback resourceInterruptedException
- in case thread is interruptedIOException
- in some other I/O problemprotected <T> T handleGet(URL resourceUrl, Class<T> type) throws InterruptedException, IOException
T
- template argument providedresourceUrl
- resource URL to be processedtype
- type of resourceInterruptedException
- Interrupted ExceptionIOException
- IOExceptionprotected <T> T handleRawGet(URL resourceUrl, Class<T> type) throws IOException
IOException
protected <T> T handleGet(URL resourceUrl, Class<T> type, Map<String,String> parameters) throws InterruptedException, IOException
T
- template argument providedresourceUrl
- resource URL to be processedtype
- type of resourceparameters
- A HashMap of strings containing parameters to be passed in requestInterruptedException
- Interrupted ExceptionIOException
- IOExceptionprotected <T> T handleResponse(HttpRequest.Builder requestBuilder, Class<T> type) throws InterruptedException, IOException
T
- template argument providedrequestBuilder
- Request Builder objecttype
- type of resourceInterruptedException
- Interrupted ExceptionIOException
- IOExceptionprotected <T> T handleResponse(HttpRequest.Builder requestBuilder, Class<T> type, Map<String,String> parameters) throws InterruptedException, IOException
T
- template argument providedrequestBuilder
- request buildertype
- type of objectparameters
- a hashmap containing parametersInterruptedException
- Interrupted ExceptionIOException
- IOExceptionprotected <T> T handleResponse(HttpClient client, HttpRequest.Builder requestBuilder, Class<T> type) throws InterruptedException, IOException
T
- template argument providedclient
- the clientrequestBuilder
- request buildertype
- type of objectInterruptedException
- Interrupted ExceptionIOException
- IOExceptionprotected <T> T handleResponse(HttpClient client, HttpRequest.Builder requestBuilder, Class<T> type, Map<String,String> parameters) throws InterruptedException, IOException
T
- Template argument providedclient
- the clientrequestBuilder
- Request buildertype
- Type of object providedparameters
- A hashmap containing parametersInterruptedException
- Interrupted ExceptionIOException
- IOExceptionprotected HttpResponse<InputStream> retryWithExponentialBackoff(HttpClient client, HttpRequest request) throws InterruptedException, IOException
InterruptedException
IOException
protected void assertResponseCode(HttpRequest request, HttpResponse<?> response)
request
- The {#link HttpRequest} object.response
- The HttpResponse
object.public static io.fabric8.kubernetes.api.model.Status createStatus(HttpResponse<?> response)
public static io.fabric8.kubernetes.api.model.Status createStatus(int statusCode, String message)
public static KubernetesClientException requestFailure(HttpRequest request, io.fabric8.kubernetes.api.model.Status status)
public static KubernetesClientException requestFailure(HttpRequest request, io.fabric8.kubernetes.api.model.Status status, String message)
public static KubernetesClientException requestException(HttpRequest request, Throwable e, String message)
public static KubernetesClientException requestException(HttpRequest request, Exception e)
protected static <T> T unmarshal(InputStream is)
protected static <T> T unmarshal(InputStream is, Class<T> type)
protected static <T> T unmarshal(InputStream is, com.fasterxml.jackson.core.type.TypeReference<T> type)
protected static <T> Map getObjectValueAsMap(T object)
public Config getConfig()
Copyright © 2015–2020 Red Hat. All rights reserved.