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 |
createOr(Function<NonDeletingOperation<T>,T> conflictAction)
Alternative to
CreateOrReplaceable.createOrReplace() . |
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
Updatable.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()
Perform a Kubernetes server-side apply operation.
|
EditReplacePatchable<T> |
subresource(String subresource)
Provides edit, patch, and replace methods for the given subresource
|
NonDeletingOperation<T> |
unlock()
Removes the resource version from the current item.
|
T |
update()
Update the server's state with the given item (PUT).
|
T |
updateStatus()
Similar to
Updatable.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)
For resources other than Node, Deployment, ReplicaSet, StatefulSet, Pod, ReplicationController, and DeploymentConfig
readiness is simply an existence check.
|
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
SharedIndexInformer s 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) |
Deletable |
withTimeout(long timeout,
TimeUnit unit)
Perform the delete operation as blocking, waiting for finalizers, for up to the given timeout
|
Deletable |
withTimeoutInMillis(long timeoutInMillis)
Perform the delete operation as blocking, waiting for finalizers, for up to the given timeout
|
public List<io.fabric8.kubernetes.api.model.StatusDetails> delete()
Deletable
StatusDetails
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()
Resource
Note: for resources other than Node, Deployment, ReplicaSet, StatefulSet, Pod, ReplicationController, and DeploymentConfig readiness is simply an existence check.
Also note this obtains the latest version of the resource from the server even if the context item is present.
public T get()
Gettable
Resource.item()
public ReplaceDeletable<T> lockResourceVersion(String resourceVersion)
lockResourceVersion
in interface Resource<T>
public WritableOperation<T> dryRun()
DryRunable
dryRun
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()
Replaceable
Updatable.replace()
, but only affects the status subresourcereplaceStatus
in interface Replaceable<T>
public T create()
CreateOrReplaceable
create
in interface CreateOrReplaceable<T>
public PropagationPolicyConfigurable<? extends Deletable> withGracePeriod(long gracePeriodSeconds)
GracePeriodConfigurable
withGracePeriod
in interface GracePeriodConfigurable<PropagationPolicyConfigurable<? extends Deletable>>
gracePeriodSeconds
- grace period integer value in secondspublic T createOrReplace()
CreateOrReplaceable
createOrReplace
in interface CreateOrReplaceable<T>
public T editStatus(UnaryOperator<T> function)
NonDeletingOperation
editStatus
in interface NonDeletingOperation<T>
function
- to produce a modified statuspublic T require() throws ResourceNotFoundException
Resource
Gettable.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)
PropagationPolicyConfigurable
The 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 DeletionPropagation
public Watch watch(Watcher<T> watcher)
Watchable
Watch
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)
ItemWritableOperation
patchStatus
in interface ItemWritableOperation<T>
item
- kubernetes objectpublic T edit(UnaryOperator<T> function)
EditReplacePatchable
It 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)
Waitable
Waitable.waitUntilCondition(Predicate, long, TimeUnit)
when dealing with
more complex situations or other types.waitUntilReady
in interface Waitable<T,T>
public Watch watch(io.fabric8.kubernetes.api.model.ListOptions options, Watcher<T> watcher)
Watchable
Watch
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)
Waitable
The 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)
Informable
SharedIndexInformer
s created by subsequent inform calls;withIndexers
in interface Informable<T>
indexers
- to customize the indexingInformable
public WritableOperation<T> dryRun(boolean isDryRun)
DryRunable
dryRun
in interface DryRunable<WritableOperation<T>>
isDryRun
- whether dry run is enabled or disabledpublic T edit(io.fabric8.kubernetes.api.builder.Visitor... visitors)
EditReplacePatchable
edit
in interface EditReplacePatchable<T>
visitors
- to modify the Builderpublic T patch(PatchContext patchContext, T item)
EditReplacePatchable
PatchContext
(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)
Informable
If 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 fetchInformable
public <V> T edit(Class<V> visitorType, io.fabric8.kubernetes.api.builder.Visitor<V> visitor)
EditReplacePatchable
edit
in interface EditReplacePatchable<T>
visitorType
- to create a TypedVisitor
visitor
- to modify the Builderpublic Watch watch(String resourceVersion, Watcher<T> watcher)
Watchable
Watch
interface that watches requested resource from
specified resourceVersionpublic T accept(Consumer<T> function)
EditReplacePatchable
accept
in interface EditReplacePatchable<T>
function
- to modify the itempublic SharedIndexInformer<T> inform()
Informable
Watch
, 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>
SharedIndexInformer
public T patch(String patch)
EditReplacePatchable
patch
in interface EditReplacePatchable<T>
patch
- The patch to be applied to the resource JSON file.public T patch(PatchContext patchContext, String patch)
EditReplacePatchable
PatchContext
(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)
Informable
Watch
, 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 notifySharedIndexInformer
public SharedIndexInformer<T> inform(ResourceEventHandler<? super T> handler, long resync)
Informable
Watch
, 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 resyncSharedIndexInformer
public SharedIndexInformer<T> runnableInformer(long resync)
Informable
Watch
, 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 resyncSharedIndexInformer
public CompletableFuture<List<T>> informOnCondition(Predicate<List<T>> condition)
Informable
Future
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()
Updatable
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 Updatable<T>
public T create(T item)
ItemWritableOperation
create
in interface ItemWritableOperation<T>
item
- to createCreateOrReplaceable.create()
public T replace(T item)
ItemReplacable
replace
in interface ItemReplacable<T>
item
- replacementpublic T createOrReplace(T item)
ItemWritableOperation
createOrReplace
in interface ItemWritableOperation<T>
item
- to create or replacepublic T replaceStatus(T item)
ItemReplacable
replaceStatus
in interface ItemReplacable<T>
item
- replacementpublic List<io.fabric8.kubernetes.api.model.StatusDetails> delete(T item)
ItemWritableOperation
delete
in interface ItemWritableOperation<T>
public T updateStatus(T item)
ItemWritableOperation
updateStatus
in interface ItemWritableOperation<T>
item
- kubernetes objectpublic ReplaceDeletable<T> lockResourceVersion()
lockResourceVersion
in interface Resource<T>
public T patchStatus()
NonDeletingOperation
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 NonDeletingOperation<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)
EditReplacePatchable
PatchContext
(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)
FieldValidateable
fieldValidation
in interface FieldValidateable<NonDeletingOperation<T>>
public ServerSideApplicable<T> fieldManager(String manager)
ServerSideApplicable
The 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()
ServerSideApplicable
forceConflicts
in interface ServerSideApplicable<T>
ServerSideApplicable
for continued operationspublic T serverSideApply()
ServerSideApplicable
application/apply-patch+yaml
Content-Type.serverSideApply
in interface ServerSideApplicable<T>
public T item()
Resource
public Deletable withTimeout(long timeout, TimeUnit unit)
Deletable
withTimeout
in interface Deletable
withTimeout
in interface Timeoutable
timeout
- 0 indicates no waitpublic Deletable withTimeoutInMillis(long timeoutInMillis)
Deletable
withTimeoutInMillis
in interface Deletable
withTimeoutInMillis
in interface Timeoutable
timeoutInMillis
- 0 indicates no waitpublic T update()
Updatable
If 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.
public T updateStatus()
Replaceable
Updatable.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)
Scalable
public T scale(int count, boolean wait)
Scalable
public io.fabric8.kubernetes.api.model.autoscaling.v1.Scale scale(io.fabric8.kubernetes.api.model.autoscaling.v1.Scale scale)
public T createOr(Function<NonDeletingOperation<T>,T> conflictAction)
NonDeletingOperation
CreateOrReplaceable.createOrReplace()
.
Will attempt a create, and if that fails will perform the conflictAction.
Most commonly the conflictAction will be NonDeletingOperation::update or NonDeletingOperation::patch, but you are free to provide whatever Function suits your needs.
createOr
in interface NonDeletingOperation<T>
conflictAction
- to be performed it the create fails with a conflictpublic NonDeletingOperation<T> unlock()
NonDeletingOperation
unlock
in interface NonDeletingOperation<T>
public EditReplacePatchable<T> subresource(String subresource)
NonDeletingOperation
subresource
in interface NonDeletingOperation<T>
Copyright © 2015–2024 Red Hat. All rights reserved.