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 |
Constructor and Description |
---|
OperationSupport(Client client) |
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) |
protected <T> T |
correctNamespace(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) |
protected static <T> Map<String,Object> |
getObjectValueAsMap(T object) |
protected Map<String,String> |
getParameters() |
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 extends io.fabric8.kubernetes.api.model.HasMetadata> |
handleApproveOrDeny(T csr,
Class<T> type) |
protected <T,I> T |
handleCreate(I resource,
Class<T> outputType)
Create a resource.
|
protected io.fabric8.kubernetes.api.model.KubernetesResource |
handleDelete(URL requestUrl,
long gracePeriodSeconds,
io.fabric8.kubernetes.api.model.DeletionPropagation propagationPolicy,
String resourceVersion) |
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 |
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 |
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> CompletableFuture<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 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.
|
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 void |
retryWithExponentialBackoff(CompletableFuture<HttpResponse<byte[]>> result,
AtomicInteger numRetries,
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) |
protected <T> T |
waitForResult(CompletableFuture<T> future)
Waits for the provided
CompletableFuture to complete and returns the result in case of success. |
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 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(Client client)
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 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> T correctNamespace(T item)
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 io.fabric8.kubernetes.api.model.KubernetesResource handleDelete(URL requestUrl, long gracePeriodSeconds, io.fabric8.kubernetes.api.model.DeletionPropagation propagationPolicy, String resourceVersion) 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 IOException
T
- template argument providedupdated
- updated objecttype
- type of the object providedstatus
- if this is only the status subresourceIOException
- 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(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 extends io.fabric8.kubernetes.api.model.HasMetadata> T handleApproveOrDeny(T csr, Class<T> type) throws IOException, InterruptedException
IOException
InterruptedException
protected <T> T handleRawGet(URL resourceUrl, Class<T> type) throws IOException
IOException
protected <T> T waitForResult(CompletableFuture<T> future) throws IOException
CompletableFuture
to complete and returns the result in case of success.T
- the type of the resultfuture
- the CompletableFuture to wait forIOException
- in case there's an I/O problemprotected <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> CompletableFuture<T> handleResponse(HttpClient client, HttpRequest.Builder requestBuilder, Class<T> type, Map<String,String> parameters)
T
- Template argument providedclient
- the clientrequestBuilder
- Request buildertype
- Type of object providedparameters
- A hashmap containing parametersprotected void retryWithExponentialBackoff(CompletableFuture<HttpResponse<byte[]>> result, AtomicInteger numRetries, HttpClient client, HttpRequest request)
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)
public Config getConfig()
Copyright © 2015–2022 Red Hat. All rights reserved.