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 |
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 String |
subresource |
Constructor and Description |
---|
OperationSupport(Client client) |
OperationSupport(OperationContext ctx) |
Modifier and Type | Method and Description |
---|---|
protected void |
addNamespacedUrlPathParts(List<String> parts,
String namespace,
String type) |
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,
KubernetesSerialization kubernetesSerialization) |
static io.fabric8.kubernetes.api.model.Status |
createStatus(int statusCode,
String message) |
String |
getAPIGroupName() |
String |
getAPIGroupVersion() |
Config |
getConfig() |
KubernetesSerialization |
getKubernetesSerialization() |
String |
getName() |
String |
getNamespace() |
URL |
getNamespacedUrl() |
URL |
getNamespacedUrl(String namespace) |
protected URL |
getNamespacedUrl(String namespace,
String type) |
OperationContext |
getOperationContext() |
RequestConfig |
getRequestConfig() |
String |
getResourceT() |
URL |
getResourceUrl() |
URL |
getResourceUrl(String namespace,
String name) |
URL |
getResourceUrl(String namespace,
String name,
String... subresources) |
URL |
getResourceURLForPatchOperation(URL resourceUrl,
PatchContext patchContext) |
URL |
getResourceURLForWriteOperation(URL resourceURL) |
protected List<String> |
getRootUrlParts() |
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)
Send an http patch and handle the response.
|
protected <T> T |
handlePatch(PatchContext patchContext,
T current,
T updated,
Class<T> type)
Send an http patch and handle the response.
|
<R1> R1 |
handleRaw(Class<R1> result,
String uri,
String method,
Object payload)
Send a raw request - where the type should be one of String, Reader, InputStream
|
protected <T> T |
handleRawGet(URL resourceUrl,
Class<T> type)
Send a raw get - where the type should be one of String, Reader, InputStream
|
protected <T> CompletableFuture<T> |
handleResponse(HttpClient client,
HttpRequest.Builder requestBuilder,
com.fasterxml.jackson.core.type.TypeReference<T> type)
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 |
handleScale(String resourceUrl,
T scale,
Class<T> scaleType)
Replace Scale of specified Kubernetes Resource
|
protected <T> T |
handleUpdate(T updated,
Class<T> type)
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 <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 OperationContext context
protected final HttpClient httpClient
protected final Config config
protected final String resourceT
protected String namespace
protected String name
protected String subresource
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()
protected URL getNamespacedUrl(String namespace, String type) throws MalformedURLException
MalformedURLException
public URL getNamespacedUrl(String namespace) throws MalformedURLException
MalformedURLException
protected void addNamespacedUrlPathParts(List<String> parts, String namespace, String type)
public URL getNamespacedUrl() throws MalformedURLException
MalformedURLException
public URL getResourceUrl(String namespace, String name, String... subresources) throws MalformedURLException
MalformedURLException
public URL getResourceUrl(String namespace, String name) 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) throws IOException
T
- template argument providedupdated
- updated objecttype
- type of the object providedIOException
- IOExceptionprotected <T> T handlePatch(PatchContext patchContext, T current, T updated, Class<T> type) throws InterruptedException, IOException
T
- template argument providedpatchContext
- patch options for patch requestcurrent
- current objectupdated
- updated objecttype
- type of objectInterruptedException
- Interrupted ExceptionIOException
- IOExceptionprotected <T> T handlePatch(PatchContext patchContext, T current, String patchForUpdate, Class<T> type) throws InterruptedException, IOException
T
- template argument providedpatchContext
- patch options for patch requestcurrent
- current objectpatchForUpdate
- Patch stringtype
- type of objectInterruptedException
- Interrupted ExceptionIOException
- IOException in case of network errorsprotected <T> T handleScale(String resourceUrl, T scale, Class<T> scaleType) 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 IOException
T
- template argument providedresourceUrl
- resource URL to be processedtype
- type of resourceIOException
- IOExceptionprotected <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 IOException
T
- template argument providedrequestBuilder
- Request Builder objecttype
- type of resourceIOException
- IOExceptionprotected <T> CompletableFuture<T> handleResponse(HttpClient client, HttpRequest.Builder requestBuilder, com.fasterxml.jackson.core.type.TypeReference<T> type)
T
- Template argument providedclient
- the clientrequestBuilder
- Request buildertype
- Type of object providedprotected 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, KubernetesSerialization kubernetesSerialization)
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)
public Config getConfig()
public OperationContext getOperationContext()
public RequestConfig getRequestConfig()
public <R1> R1 handleRaw(Class<R1> result, String uri, String method, Object payload)
public KubernetesSerialization getKubernetesSerialization()
Copyright © 2015–2023 Red Hat. All rights reserved.