T - the resource typepublic class ResourceAdapter<T> extends Object implements Resource<T>
FieldValidateable.Validation| Constructor and Description |
|---|
ResourceAdapter() |
ResourceAdapter(Resource<T> resource) |
| Modifier and Type | Method and Description |
|---|---|
T |
accept(Consumer<T> function)
Issues a JSON patch against the item based upon the changes made by the function provided as argument
|
T |
create()
Creates an item
|
T |
create(T item)
Creates an item
|
T |
createOrReplace()
Creates a provided resource in a Kubernetes Cluster.
|
T |
createOrReplace(T item)
Creates a provided resource in a Kubernetes Cluster.
|
List<io.fabric8.kubernetes.api.model.StatusDetails> |
delete()
Deletes the resources at this context and returns the
StatusDetails of resources marked for deletion
as determined by the api server response(s). |
List<io.fabric8.kubernetes.api.model.StatusDetails> |
delete(T item)
Deletes an item
|
WritableOperation<T> |
dryRun()
Indicates that modifications should not be persisted.
|
WritableOperation<T> |
dryRun(boolean isDryRun)
Indicates whether modifications should not be persisted or not.
|
<V> T |
edit(Class<V> visitorType,
io.fabric8.kubernetes.api.builder.Visitor<V> visitor)
Issues a JSON patch against the item based upon the changes made to the object by the visitor.
|
T |
edit(UnaryOperator<T> function)
Issues a JSON patch against the item based upon the changes made to the object returned by the function.
|
T |
edit(io.fabric8.kubernetes.api.builder.Visitor... visitors)
Issues a JSON patch against the item based upon the changes made to the object by the visitors.
|
T |
editStatus(UnaryOperator<T> function)
Edit the status subresource
|
ServerSideApplicable<T> |
fieldManager(String manager)
FieldManager is a name associated with the actor or entity that is making these changes.
|
NonDeletingOperation<T> |
fieldValidation(FieldValidateable.Validation fieldValidation)
Instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields,
provided that the `ServerSideFieldValidation` feature gate is also enabled.
|
ServerSideApplicable<T> |
forceConflicts()
Force this request / fieldManager to take ownership over conflicting fields.
|
Gettable<T> |
fromServer() |
T |
get()
Get the current state from the api server.
|
Resource<T> |
getResource() |
SharedIndexInformer<T> |
inform()
Similar to a
Watch, but will attempt to handle failures after successfully started. |
SharedIndexInformer<T> |
inform(ResourceEventHandler<? super T> handler)
Similar to a
Watch, but will attempt to handle failures after successfully started. |
SharedIndexInformer<T> |
inform(ResourceEventHandler<? super T> handler,
long resync)
Similar to a
Watch, but will attempt to handle failures after successfully started. |
CompletableFuture<List<T>> |
informOnCondition(Predicate<List<T>> condition)
|
boolean |
isReady()
Check if the resource is ready.
|
T |
item()
Get the item used to create the current operation context if available.
|
ReplaceDeletable<T> |
lockResourceVersion() |
ReplaceDeletable<T> |
lockResourceVersion(String resourceVersion) |
T |
patch()
Update field(s) of a resource using a JSON patch which will be computed using the latest
server state as the base.
|
T |
patch(PatchContext patchContext)
Update field(s) of a resource using type specified in
PatchContext(defaults to strategic merge if not specified). |
T |
patch(PatchContext patchContext,
String patch)
Update field(s) of a resource using type specified in
PatchContext(defaults to strategic merge if not specified). |
T |
patch(PatchContext patchContext,
T item)
Update field(s) of a resource using type specified in
PatchContext(defaults to strategic merge if not specified). |
T |
patch(String patch)
Update field(s) of a resource using strategic merge patch.
|
T |
patch(T item)
Deprecated.
|
T |
patchStatus()
Does a PATCH request to the /status subresource ignoring changes to anything except the status stanza.
|
T |
patchStatus(T item)
|
T |
replace()
Replace the server's state with the given item.
|
T |
replace(T item)
|
T |
replaceStatus()
Similar to
Replaceable.replace(), but only affects the status subresource |
T |
replaceStatus(T item)
|
T |
require()
Perform a
Gettable.get(), but throws an exception if the server resource does not exist. |
SharedIndexInformer<T> |
runnableInformer(long resync)
Similar to a
Watch, but will attempt to handle failures after successfully started. |
io.fabric8.kubernetes.api.model.autoscaling.v1.Scale |
scale() |
T |
scale(int count)
Scale the resource to given count
|
T |
scale(int count,
boolean wait)
Scale the resource to given count
|
io.fabric8.kubernetes.api.model.autoscaling.v1.Scale |
scale(io.fabric8.kubernetes.api.model.autoscaling.v1.Scale scale) |
T |
serverSideApply() |
T |
update()
Update the server's state with the given item (PUT).
|
T |
updateStatus()
Similar to
Replaceable.update(), but only affects the status subresource |
T |
updateStatus(T item)
When the status subresource is enabled, the /status subresource for the custom resource is exposed.
|
T |
waitUntilCondition(Predicate<T> condition,
long amount,
TimeUnit timeUnit)
Wait for the given condition to be true.
|
T |
waitUntilReady(long amount,
TimeUnit timeUnit) |
Watch |
watch(io.fabric8.kubernetes.api.model.ListOptions options,
Watcher<T> watcher)
Watch returns
Watch interface that watches requested resource |
Watch |
watch(String resourceVersion,
Watcher<T> watcher)
Watch returns
Watch interface that watches requested resource from
specified resourceVersion |
Watch |
watch(Watcher<T> watcher)
Watch returns
Watch interface that watches requested resource |
PropagationPolicyConfigurable<? extends Deletable> |
withGracePeriod(long gracePeriodSeconds)
The duration in seconds before the object should be deleted.
|
Informable<T> |
withIndexers(Map<String,Function<T,List<String>>> indexers)
The indexers to add to
SharedIndexInformers created by subsequent inform calls; |
Informable<T> |
withLimit(Long limit)
Set the limit to the number of resources to list at one time.
|
GracePeriodConfigurable<? extends Deletable> |
withPropagationPolicy(io.fabric8.kubernetes.api.model.DeletionPropagation propagationPolicy)
Whether and how garbage collection will be performed.
|
Watchable<T> |
withResourceVersion(String resourceVersion) |
DeletableWithOptions |
withTimeout(long timeout,
TimeUnit unit)
Wait for the given operation timeout.
|
DeletableWithOptions |
withTimeoutInMillis(long timeoutInMillis)
Wait for the given operation timeout in milliseconds.
|
public List<io.fabric8.kubernetes.api.model.StatusDetails> delete()
DeletableStatusDetails of resources marked for deletion
as determined by the api server response(s).
It is not guaranteed that the returned list will contain all values marked for deletion - see Issue #3058
public boolean isReady()
Resourcepublic T get()
GettableResource.item()public ReplaceDeletable<T> lockResourceVersion(String resourceVersion)
lockResourceVersion in interface Resource<T>public WritableOperation<T> dryRun()
DryRunabledryRun in interface DryRunable<WritableOperation<T>>public Watchable<T> withResourceVersion(String resourceVersion)
withResourceVersion in interface WatchAndWaitable<T>public Gettable<T> fromServer()
fromServer in interface FromServerGettable<T>public T replaceStatus()
ReplaceableReplaceable.replace(), but only affects the status subresourcereplaceStatus in interface Replaceable<T>public T create()
CreateOrReplaceablecreate in interface CreateOrReplaceable<T>public PropagationPolicyConfigurable<? extends Deletable> withGracePeriod(long gracePeriodSeconds)
GracePeriodConfigurablewithGracePeriod in interface GracePeriodConfigurable<PropagationPolicyConfigurable<? extends Deletable>>gracePeriodSeconds - grace period integer value in secondspublic T createOrReplace()
CreateOrReplaceablecreateOrReplace in interface CreateOrReplaceable<T>public T editStatus(UnaryOperator<T> function)
EditReplacePatchableeditStatus in interface EditReplacePatchable<T>function - to produce a modified statuspublic T require() throws ResourceNotFoundException
ResourceGettable.get(), but throws an exception if the server resource does not exist.require in interface Resource<T>ResourceNotFoundException - if resource is absentpublic GracePeriodConfigurable<? extends Deletable> withPropagationPolicy(io.fabric8.kubernetes.api.model.DeletionPropagation propagationPolicy)
PropagationPolicyConfigurableThe default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy.
Acceptable values are:
'Orphan' - orphan the dependents;
'Background' - allow the garbage collector to delete the dependents in the background;
'Foreground' - a cascading policy that deletes all dependents in the foreground.
withPropagationPolicy in interface PropagationPolicyConfigurable<GracePeriodConfigurable<? extends Deletable>>propagationPolicy - propagation policy in form of string DeletionPropagationpublic Watch watch(Watcher<T> watcher)
WatchableWatch interface that watches requested resource@Deprecated public T patch(T item)
EditReplacePatchable
It is the same as calling EditReplacePatchable.patch(PatchContext, Object) with PatchType.JSON specified.
WARNING: If no context item is available the latest version of that resource will be used as the base to compute the diff. If you did not intend for the latest version to be your base, this may overwrite concurrent changes (between when you obtained your item and the current state) in an unexpected way.
Consider using edit, which allows for a known base, and a builder instead.
WARNING: For some resource types there is an attempt to make this operation more like
an apply by considering implicit server side state as not being part of the patch. This behavior will be
removed in future versions, you should instead construct the resource to be patched from a resource obtained
from the api server or use patch method that is tolerant to missing state, or
ServerSideApplicable.serverSideApply()
patch in interface EditReplacePatchable<T>item - to be patched with patched valuespublic T patchStatus(T item)
ItemWritableOperationpatchStatus in interface ItemWritableOperation<T>item - kubernetes objectpublic T edit(UnaryOperator<T> function)
EditReplacePatchableIt is generally convenient to use a Builder constructed off of the item.
edit in interface EditReplacePatchable<T>function - to modify the itempublic T waitUntilReady(long amount, TimeUnit timeUnit)
waitUntilReady in interface Waitable<T,T>public Watch watch(io.fabric8.kubernetes.api.model.ListOptions options, Watcher<T> watcher)
WatchableWatch interface that watches requested resource
The passed in options may be modified as a side-effect of this call.
Values that already exist at this context, such as the labels, fields,
and resourceVersion will be overridden on the passed in options regardless of initial values.
public T waitUntilCondition(Predicate<T> condition, long amount, TimeUnit timeUnit)
WaitableThe processing of events will be in the IO thread, blocking operations should be avoided.
If nothing exists, the condition will be tested with a null value.
waitUntilCondition in interface Waitable<T,T>public Informable<T> withIndexers(Map<String,Function<T,List<String>>> indexers)
InformableSharedIndexInformers created by subsequent inform calls;withIndexers in interface Informable<T>indexers - to customize the indexingInformablepublic WritableOperation<T> dryRun(boolean isDryRun)
DryRunabledryRun in interface DryRunable<WritableOperation<T>>isDryRun - whether dry run is enabled or disabledpublic T edit(io.fabric8.kubernetes.api.builder.Visitor... visitors)
EditReplacePatchableedit in interface EditReplacePatchable<T>visitors - to modify the Builderpublic T patch(PatchContext patchContext, T item)
EditReplacePatchablePatchContext(defaults to strategic merge if not specified).
PatchType.JSON - will create a JSON patch against the current item
PatchType.JSON_MERGE - will send the serialization of the item as a JSON MERGE patch.
Set the resourceVersion to null to prevent optimistic locking.
PatchType.STRATEGIC_MERGE - will send the serialization of the item as a STRATEGIC MERGE patch.
Set the resourceVersion to null to prevent optimistic locking.
PatchType.SERVER_SIDE_APPLY - will send the serialization of the item as a SERVER SIDE APPLY patch.
You may explicitly set the PatchContext.getFieldManager() as well to override the default.
ServerSideApplicable.serverSideApply()
patch in interface EditReplacePatchable<T>patchContext - PatchContext for patch requestitem - to be patched with patched valuespublic Informable<T> withLimit(Long limit)
InformableIf the list fails to complete it will be re-attempted with this limit, rather than falling back to the full list. You should ensure that your handlers are either async or fast acting to prevent long delays in list processing that may cause results to expire before reaching the end of the list.
WARNING As noted in the go client: "paginated lists are always served directly from etcd, which is significantly less efficient and may lead to serious performance and scalability problems."
withLimit in interface Informable<T>limit - of a items in a list fetchInformablepublic <V> T edit(Class<V> visitorType, io.fabric8.kubernetes.api.builder.Visitor<V> visitor)
EditReplacePatchableedit in interface EditReplacePatchable<T>visitorType - to create a TypedVisitorvisitor - to modify the Builderpublic Watch watch(String resourceVersion, Watcher<T> watcher)
WatchableWatch interface that watches requested resource from
specified resourceVersionpublic T accept(Consumer<T> function)
EditReplacePatchableaccept in interface EditReplacePatchable<T>function - to modify the itempublic SharedIndexInformer<T> inform()
InformableWatch, but will attempt to handle failures after successfully started.
and provides a store of all the current resources.
This returned informer will not support resync.
This call will be blocking for the initial list and watch.
You are expected to call stop to terminate the underlying Watch.
The processing of handler events will be in the client's Executor.
inform in interface Informable<T>SharedIndexInformerpublic T patch(String patch)
EditReplacePatchablepatch in interface EditReplacePatchable<T>patch - The patch to be applied to the resource JSON file.public T patch(PatchContext patchContext, String patch)
EditReplacePatchablePatchContext(defaults to strategic merge if not specified).patch in interface EditReplacePatchable<T>patchContext - PatchContext for patch requestpatch - The patch to be applied to the resource JSON file.public SharedIndexInformer<T> inform(ResourceEventHandler<? super T> handler)
InformableWatch, but will attempt to handle failures after successfully started.
and provides a store of all the current resources.
This returned informer will not support resync.
This call will be blocking for the initial list and watch.
You are expected to call stop to terminate the underlying Watch.
The processing of handler events will be in the client's Executor.
inform in interface Informable<T>handler - to notifySharedIndexInformerpublic SharedIndexInformer<T> inform(ResourceEventHandler<? super T> handler, long resync)
InformableWatch, but will attempt to handle failures after successfully started.
and provides a store of all the current resources.
This call will be blocking for the initial list and watch.
You are expected to call stop to terminate the underlying Watch.
The processing of handler events will be in the client's Executor.
inform in interface Informable<T>handler - to notifyresync - the resync period or 0 for no resyncSharedIndexInformerpublic SharedIndexInformer<T> runnableInformer(long resync)
InformableWatch, but will attempt to handle failures after successfully started.
and provides a store of all the current resources.
You are expected to call stop to terminate the underlying Watch.
runnableInformer in interface Informable<T>resync - the resync period or 0 for no resyncSharedIndexInformerpublic CompletableFuture<List<T>> informOnCondition(Predicate<List<T>> condition)
InformableFuture when the list at this context satisfies the given Predicate.
The predicate will be tested against the state of the underlying informer store on every event.
The returned future should be cancelled by the caller if not waiting for completion to close the underlying informer
The processing of events will be in the IO thread, blocking operations should be avoided.
informOnCondition in interface Informable<T>condition - the Predicate to testCompletableFuture of the list of items after the condition is metpublic T replace()
Replaceable
If Resource.lockResourceVersion(String) has been used to lock the resourceVersion,
this operation is effectively a single update attempt against that version.
If Resource.lockResourceVersion(String) has not been called, this operation
will be retried a number of times in the event of a conflict. If a resourceVersion has been set
on the item, the first update attempt will be made against that version. Subsequent attempts will fetch
the latest resourceVersion from the server.
replace in interface Replaceable<T>public T create(T item)
ItemWritableOperationcreate in interface ItemWritableOperation<T>item - to createCreateOrReplaceable.create()public T replace(T item)
ItemReplacablereplace in interface ItemReplacable<T>item - replacementpublic T createOrReplace(T item)
ItemWritableOperationcreateOrReplace in interface ItemWritableOperation<T>item - to create or replacepublic T replaceStatus(T item)
ItemReplacablereplaceStatus in interface ItemReplacable<T>item - replacementpublic List<io.fabric8.kubernetes.api.model.StatusDetails> delete(T item)
ItemWritableOperationdelete in interface ItemWritableOperation<T>public T updateStatus(T item)
ItemWritableOperationupdateStatus in interface ItemWritableOperation<T>item - kubernetes objectpublic ReplaceDeletable<T> lockResourceVersion()
lockResourceVersion in interface Resource<T>public T patchStatus()
EditReplacePatchable
This method has the same patching behavior as EditReplacePatchable.patch(PatchContext), with
PatchType.JSON_MERGE but against the status subresource.
Set the resourceVersion to null to prevent optimistic locking.
patchStatus in interface EditReplacePatchable<T>public T patch()
EditReplacePatchable
It is the same as calling EditReplacePatchable.patch(PatchContext) with PatchType.JSON specified.
WARNING: If you did not intend for the latest version to be your base, this may overwrite concurrent changes (between when you obtained your item and the current state) in an unexpected way.
Consider using edit instead.
WARNING: For some resource types there is an attempt to make this operation more like
an apply by considering implicit server side state as not being part of the patch. This behavior will be
removed in future versions, you should instead construct the resource to be patched from a resource obtained
from the api server or use patch method that is tolerant to missing state, or
ServerSideApplicable.serverSideApply()
patch in interface EditReplacePatchable<T>public T patch(PatchContext patchContext)
EditReplacePatchablePatchContext(defaults to strategic merge if not specified).
For use when you are providing a complete object to be patched: resource(item).patch(PatchContext.of(PatchType.SERVER_SIDE_APPLY))
PatchType.JSON - will create a JSON patch using the latest server state as the base
PatchType.JSON_MERGE - will send the serialization of the item as a JSON MERGE patch.
Set the resourceVersion to null to prevent optimistic locking.
PatchType.STRATEGIC_MERGE - will send the serialization of the item as a STRATEGIC MERGE patch.
Set the resourceVersion to null to prevent optimistic locking.
PatchType.SERVER_SIDE_APPLY - will send the serialization of the item as a SERVER SIDE APPLY patch.
You may explicitly set the PatchContext.getFieldManager() as well to override the default.
ServerSideApplicable.serverSideApply()
patch in interface EditReplacePatchable<T>patchContext - PatchContext for patch requestpublic NonDeletingOperation<T> fieldValidation(FieldValidateable.Validation fieldValidation)
FieldValidateablefieldValidation in interface FieldValidateable<NonDeletingOperation<T>>public ServerSideApplicable<T> fieldManager(String manager)
ServerSideApplicableThe value must be less than or 128 characters long, and only contain printable characters
the default value is "fabric8"
fieldManager in interface ServerSideApplicable<T>ServerSideApplicable for continued operationspublic ServerSideApplicable<T> forceConflicts()
ServerSideApplicableforceConflicts in interface ServerSideApplicable<T>ServerSideApplicable for continued operationspublic T serverSideApply()
serverSideApply in interface ServerSideApplicable<T>public T item()
Resourcepublic DeletableWithOptions withTimeout(long timeout, TimeUnit unit)
TimeoutablewithTimeout in interface DeletableWithOptionswithTimeout in interface Timeoutabletimeout - 0 indicates no waitpublic DeletableWithOptions withTimeoutInMillis(long timeoutInMillis)
TimeoutablewithTimeoutInMillis in interface DeletableWithOptionswithTimeoutInMillis in interface TimeoutabletimeoutInMillis - 0 indicates no waitpublic T update()
ReplaceableIf the resourceVersion is on the resource, the update will be performed with optimistic locking, and may result in a conflict (409 error). If no resourceVersion is on the resource, the latest resourceVersion will be obtained from the server prior to the update call - which may still be a conflict in a rare circumstance.
update in interface Replaceable<T>public T updateStatus()
ReplaceableReplaceable.update(), but only affects the status subresourceupdateStatus in interface Replaceable<T>public io.fabric8.kubernetes.api.model.autoscaling.v1.Scale scale()
public T scale(int count)
Scalablepublic T scale(int count, boolean wait)
ScalableCopyright © 2015–2023 Red Hat. All rights reserved.