Class ResourceAdapter<T>
- java.lang.Object
-
- io.fabric8.kubernetes.client.extension.ResourceAdapter<T>
-
- Type Parameters:
T
- the resource type
- All Implemented Interfaces:
CreateOrReplaceable<T>
,Deletable
,DeletableWithOptions
,DryRunable<WritableOperation<T>>
,EditReplacePatchable<T>
,FieldValidateable<NonDeletingOperation<T>>
,Gettable<T>
,Informable<T>
,ItemReplacable<T>
,ItemWritableOperation<T>
,NonDeletingOperation<T>
,Replaceable<T>
,ReplaceDeletable<T>
,Resource<T>
,Scalable<T>
,ServerSideApplicable<T>
,Timeoutable
,Updatable<T>
,Waitable<T,T>
,Watchable<T>
,WatchAndWaitable<T>
,WritableOperation<T>
,FromServerGettable<T>
,GracePeriodConfigurable<PropagationPolicyConfigurable<? extends Deletable>>
,PropagationPolicyConfigurable<GracePeriodConfigurable<? extends Deletable>>
- Direct Known Subclasses:
ExtensibleResourceAdapter
public class ResourceAdapter<T> extends Object implements Resource<T>
Base for overriding a Resource
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.fabric8.kubernetes.client.dsl.FieldValidateable
FieldValidateable.Validation
-
-
Constructor Summary
Constructors Constructor Description ResourceAdapter()
ResourceAdapter(Resource<T> resource)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description T
accept(Consumer<T> function)
Issues a JSON patch against the item based upon the changes made by the function provided as argumentT
create()
Creates an itemT
create(T item)
Creates an itemT
createOr(Function<NonDeletingOperation<T>,T> conflictAction)
Alternative toCreateOrReplaceable.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 theStatusDetails
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 itemWritableOperation<T>
dryRun()
Indicates that modifications should not be persisted.WritableOperation<T>
dryRun(boolean isDryRun)
Indicates whether modifications should not be persisted or not.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.<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
editStatus(UnaryOperator<T> function)
Edit the status subresourceServerSideApplicable<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 aWatch
, but will attempt to handle failures after successfully started.SharedIndexInformer<T>
inform(ResourceEventHandler<? super T> handler)
Similar to aWatch
, but will attempt to handle failures after successfully started.SharedIndexInformer<T>
inform(ResourceEventHandler<? super T> handler, long resync)
Similar to aWatch
, 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 inPatchContext
(defaults to strategic merge if not specified).T
patch(PatchContext patchContext, String patch)
Update field(s) of a resource using type specified inPatchContext
(defaults to strategic merge if not specified).T
patch(PatchContext patchContext, T item)
Update field(s) of a resource using type specified inPatchContext
(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 toUpdatable.replace()
, but only affects the status subresourceT
replaceStatus(T item)
T
require()
Perform aGettable.get()
, but throws an exception if the server resource does not exist.SharedIndexInformer<T>
runnableInformer(long resync)
Similar to aWatch
, 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 countT
scale(int count, boolean wait)
Scale the resource to given countio.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 subresourceNonDeletingOperation<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 toUpdatable.update()
, but only affects the status subresourceT
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 returnsWatch
interface that watches requested resourceWatch
watch(Watcher<T> watcher)
Watch returnsWatch
interface that watches requested resourceWatch
watch(String resourceVersion, Watcher<T> watcher)
Watch returnsWatch
interface that watches requested resource from specified resourceVersionPropagationPolicyConfigurable<? 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 toSharedIndexInformer
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 timeoutDeletable
withTimeoutInMillis(long timeoutInMillis)
Perform the delete operation as blocking, waiting for finalizers, for up to the given timeout
-
-
-
Method Detail
-
delete
public List<io.fabric8.kubernetes.api.model.StatusDetails> delete()
Description copied from interface:Deletable
Deletes the resources at this context and returns theStatusDetails
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
-
isReady
public boolean isReady()
Description copied from interface:Resource
Check if the resource is ready. If no readiness check exists, this is just an existence check.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.
-
get
public T get()
Description copied from interface:Gettable
Get the current state from the api server. See alsoResource.item()
-
lockResourceVersion
public ReplaceDeletable<T> lockResourceVersion(String resourceVersion)
- Specified by:
lockResourceVersion
in interfaceResource<T>
-
dryRun
public WritableOperation<T> dryRun()
Description copied from interface:DryRunable
Indicates that modifications should not be persisted. All dry run stages will be processed. the request is still processed as typical request: the fields are defaulted, the object is validated, it goes through the validation admission chain, and through the mutating admission chain, and then the final object is returned to the user as it normally would, without being persisted.- Specified by:
dryRun
in interfaceDryRunable<T>
- Returns:
- write operations which are applicable for dry run
-
withResourceVersion
public Watchable<T> withResourceVersion(String resourceVersion)
- Specified by:
withResourceVersion
in interfaceWatchAndWaitable<T>
-
fromServer
public Gettable<T> fromServer()
- Specified by:
fromServer
in interfaceFromServerGettable<T>
-
replaceStatus
public T replaceStatus()
Description copied from interface:Replaceable
Similar toUpdatable.replace()
, but only affects the status subresource- Specified by:
replaceStatus
in interfaceReplaceable<T>
- Returns:
- returns deserialized version of api server response
- See Also:
- Migration FAQ
-
create
public T create()
Description copied from interface:CreateOrReplaceable
Creates an item- Specified by:
create
in interfaceCreateOrReplaceable<T>
- Returns:
- the item from the api server
-
withGracePeriod
public PropagationPolicyConfigurable<? extends Deletable> withGracePeriod(long gracePeriodSeconds)
Description copied from interface:GracePeriodConfigurable
The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately.- Specified by:
withGracePeriod
in interfaceGracePeriodConfigurable<T>
- Parameters:
gracePeriodSeconds
- grace period integer value in seconds- Returns:
- the object for which grace period is configured
-
createOrReplace
public T createOrReplace()
Description copied from interface:CreateOrReplaceable
Creates a provided resource in a Kubernetes Cluster. If creation fails with a HTTP_CONFLICT, it tries to replace resource.- Specified by:
createOrReplace
in interfaceCreateOrReplaceable<T>
- Returns:
- created item returned in kubernetes api response
- See Also:
- Migration FAQ
-
editStatus
public T editStatus(UnaryOperator<T> function)
Description copied from interface:NonDeletingOperation
Edit the status subresource- Specified by:
editStatus
in interfaceNonDeletingOperation<T>
- Parameters:
function
- to produce a modified status- Returns:
- updated object
-
require
public T require() throws ResourceNotFoundException
Description copied from interface:Resource
Perform aGettable.get()
, but throws an exception if the server resource does not exist.- Specified by:
require
in interfaceResource<T>
- Returns:
- the item or throws an exception if the item doesn't exist.
- Throws:
ResourceNotFoundException
- if resource is absent
-
withPropagationPolicy
public GracePeriodConfigurable<? extends Deletable> withPropagationPolicy(io.fabric8.kubernetes.api.model.DeletionPropagation propagationPolicy)
Description copied from interface:PropagationPolicyConfigurable
Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both.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.- Specified by:
withPropagationPolicy
in interfacePropagationPolicyConfigurable<T>
- Parameters:
propagationPolicy
- propagation policy in form of stringDeletionPropagation
- Returns:
- resource
-
watch
public Watch watch(Watcher<T> watcher)
Description copied from interface:Watchable
Watch returnsWatch
interface that watches requested resource
-
patch
@Deprecated public T patch(T item)
Deprecated.Description copied from interface:EditReplacePatchable
Update field(s) of a resource using a JSON patch. The patch is computed against the context item.It is the same as calling
EditReplacePatchable.patch(PatchContext, Object)
withPatchType.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()
- Specified by:
patch
in interfaceEditReplacePatchable<T>
- Parameters:
item
- to be patched with patched values- Returns:
- returns deserialized version of api server response
-
patchStatus
public T patchStatus(T item)
Description copied from interface:ItemWritableOperation
- Specified by:
patchStatus
in interfaceItemWritableOperation<T>
- Parameters:
item
- kubernetes object- Returns:
- updated object
-
edit
public T edit(UnaryOperator<T> function)
Description copied from interface:EditReplacePatchable
Issues a JSON patch against the item based upon the changes made to the object returned by the function.It is generally convenient to use a Builder constructed off of the item.
- Specified by:
edit
in interfaceEditReplacePatchable<T>
- Parameters:
function
- to modify the item- Returns:
- returns deserialized version of api server response
-
waitUntilReady
public T waitUntilReady(long amount, TimeUnit timeUnit)
Description copied from interface:Waitable
For resources other than Node, Deployment, ReplicaSet, StatefulSet, Pod, ReplicationController, and DeploymentConfig readiness is simply an existence check.
Consider using the more generalWaitable.waitUntilCondition(Predicate, long, TimeUnit)
when dealing with more complex situations or other types.- Specified by:
waitUntilReady
in interfaceWaitable<T,T>
-
watch
public Watch watch(io.fabric8.kubernetes.api.model.ListOptions options, Watcher<T> watcher)
Description copied from interface:Watchable
Watch returnsWatch
interface that watches requested resourceThe 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.
-
waitUntilCondition
public T waitUntilCondition(Predicate<T> condition, long amount, TimeUnit timeUnit)
Description copied from interface:Waitable
Wait for the given condition to be true.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.
- Specified by:
waitUntilCondition
in interfaceWaitable<T,T>
- Returns:
- the result that passes the given condition
-
withIndexers
public Informable<T> withIndexers(Map<String,Function<T,List<String>>> indexers)
Description copied from interface:Informable
The indexers to add toSharedIndexInformer
s created by subsequent inform calls;- Specified by:
withIndexers
in interfaceInformable<T>
- Parameters:
indexers
- to customize the indexing- Returns:
- the current
Informable
-
dryRun
public WritableOperation<T> dryRun(boolean isDryRun)
Description copied from interface:DryRunable
Indicates whether modifications should not be persisted or not. If enabled, All dry run stages will be processed. the request is still processed as typical request: the fields are defaulted, the object is validated, it goes through the validation admission chain, and through the mutating admission chain, and then the final object is returned to the user as it normally would, without being persisted.- Specified by:
dryRun
in interfaceDryRunable<T>
- Parameters:
isDryRun
- whether dry run is enabled or disabled- Returns:
- write operations which are applicable for dry run
-
edit
public T edit(io.fabric8.kubernetes.api.builder.Visitor... visitors)
Description copied from interface:EditReplacePatchable
Issues a JSON patch against the item based upon the changes made to the object by the visitors.- Specified by:
edit
in interfaceEditReplacePatchable<T>
- Parameters:
visitors
- to modify the Builder- Returns:
- returns deserialized version of api server response
-
patch
public T patch(PatchContext patchContext, T item)
Description copied from interface:EditReplacePatchable
Update field(s) of a resource using type specified inPatchContext
(defaults to strategic merge if not specified).PatchType.JSON
- will create a JSON patch against the current itemPatchType.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 thePatchContext.getFieldManager()
as well to override the default.
ServerSideApplicable.serverSideApply()
- Specified by:
patch
in interfaceEditReplacePatchable<T>
- Parameters:
patchContext
-PatchContext
for patch requestitem
- to be patched with patched values- Returns:
- returns deserialized version of api server response
-
withLimit
public Informable<T> withLimit(Long limit)
Description copied from interface:Informable
Set the limit to the number of resources to list at one time. This means that longer lists will take multiple requests to fetch.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."
- Specified by:
withLimit
in interfaceInformable<T>
- Parameters:
limit
- of a items in a list fetch- Returns:
- the current
Informable
-
edit
public <V> T edit(Class<V> visitorType, io.fabric8.kubernetes.api.builder.Visitor<V> visitor)
Description copied from interface:EditReplacePatchable
Issues a JSON patch against the item based upon the changes made to the object by the visitor.- Specified by:
edit
in interfaceEditReplacePatchable<T>
- Parameters:
visitorType
- to create aTypedVisitor
visitor
- to modify the Builder- Returns:
- returns deserialized version of api server response
-
watch
public Watch watch(String resourceVersion, Watcher<T> watcher)
Description copied from interface:Watchable
Watch returnsWatch
interface that watches requested resource from specified resourceVersion
-
accept
public T accept(Consumer<T> function)
Description copied from interface:EditReplacePatchable
Issues a JSON patch against the item based upon the changes made by the function provided as argument- Specified by:
accept
in interfaceEditReplacePatchable<T>
- Parameters:
function
- to modify the item- Returns:
- returns deserialized version of api server response
-
inform
public SharedIndexInformer<T> inform()
Description copied from interface:Informable
Similar to aWatch
, 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
.- Specified by:
inform
in interfaceInformable<T>
- Returns:
- a running
SharedIndexInformer
-
patch
public T patch(String patch)
Description copied from interface:EditReplacePatchable
Update field(s) of a resource using strategic merge patch.- Specified by:
patch
in interfaceEditReplacePatchable<T>
- Parameters:
patch
- The patch to be applied to the resource JSON file.- Returns:
- returns deserialized version of api server response
-
patch
public T patch(PatchContext patchContext, String patch)
Description copied from interface:EditReplacePatchable
Update field(s) of a resource using type specified inPatchContext
(defaults to strategic merge if not specified).- Specified by:
patch
in interfaceEditReplacePatchable<T>
- Parameters:
patchContext
-PatchContext
for patch requestpatch
- The patch to be applied to the resource JSON file.- Returns:
- updated object
-
inform
public SharedIndexInformer<T> inform(ResourceEventHandler<? super T> handler)
Description copied from interface:Informable
Similar to aWatch
, 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
.- Specified by:
inform
in interfaceInformable<T>
- Parameters:
handler
- to notify- Returns:
- a running
SharedIndexInformer
-
inform
public SharedIndexInformer<T> inform(ResourceEventHandler<? super T> handler, long resync)
Description copied from interface:Informable
Similar to aWatch
, 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
.- Specified by:
inform
in interfaceInformable<T>
- Parameters:
handler
- to notifyresync
- the resync period or 0 for no resync- Returns:
- a running
SharedIndexInformer
-
runnableInformer
public SharedIndexInformer<T> runnableInformer(long resync)
Description copied from interface:Informable
Similar to aWatch
, 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.
- Specified by:
runnableInformer
in interfaceInformable<T>
- Parameters:
resync
- the resync period or 0 for no resync- Returns:
- a non-running
SharedIndexInformer
-
informOnCondition
public CompletableFuture<List<T>> informOnCondition(Predicate<List<T>> condition)
Description copied from interface:Informable
Return aFuture
when the list at this context satisfies the givenPredicate
. 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 informerThe processing of events will be in the IO thread, blocking operations should be avoided.
- Specified by:
informOnCondition
in interfaceInformable<T>
- Parameters:
condition
- thePredicate
to test- Returns:
- a
CompletableFuture
of the list of items after the condition is met
-
replace
public T replace()
Description copied from interface:Updatable
Replace the server's state with the given item.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.- Specified by:
replace
in interfaceUpdatable<T>
- Returns:
- returns deserialized version of api server response
- See Also:
- Migration FAQ
-
create
public T create(T item)
Description copied from interface:ItemWritableOperation
Creates an item- Specified by:
create
in interfaceItemWritableOperation<T>
- Parameters:
item
- to create- Returns:
- the item from the api server
- See Also:
CreateOrReplaceable.create()
-
replace
public T replace(T item)
Description copied from interface:ItemReplacable
- Specified by:
replace
in interfaceItemReplacable<T>
- Parameters:
item
- replacement- Returns:
- the replaced item from the api server
-
createOrReplace
public T createOrReplace(T item)
Description copied from interface:ItemWritableOperation
Creates a provided resource in a Kubernetes Cluster. If creation fails with a HTTP_CONFLICT, it tries to replace resource.- Specified by:
createOrReplace
in interfaceItemWritableOperation<T>
- Parameters:
item
- to create or replace- Returns:
- created or replaced item returned in kubernetes api response
-
replaceStatus
public T replaceStatus(T item)
Description copied from interface:ItemReplacable
- Specified by:
replaceStatus
in interfaceItemReplacable<T>
- Parameters:
item
- replacement- Returns:
- the replaced item from the api server
-
delete
public List<io.fabric8.kubernetes.api.model.StatusDetails> delete(T item)
Description copied from interface:ItemWritableOperation
Deletes an item- Specified by:
delete
in interfaceItemWritableOperation<T>
- Returns:
-
updateStatus
public T updateStatus(T item)
Description copied from interface:ItemWritableOperation
When the status subresource is enabled, the /status subresource for the custom resource is exposed. It does a PUT requests to the /status subresource take a resource object and ignore changes to anything except the status stanza.- Specified by:
updateStatus
in interfaceItemWritableOperation<T>
- Parameters:
item
- kubernetes object- Returns:
- updated object
-
lockResourceVersion
public ReplaceDeletable<T> lockResourceVersion()
- Specified by:
lockResourceVersion
in interfaceResource<T>
-
patchStatus
public T patchStatus()
Description copied from interface:NonDeletingOperation
Does a PATCH request to the /status subresource ignoring changes to anything except the status stanza.This method has the same patching behavior as
EditReplacePatchable.patch(PatchContext)
, withPatchType.JSON_MERGE
but against the status subresource.Set the resourceVersion to null to prevent optimistic locking.
- Specified by:
patchStatus
in interfaceNonDeletingOperation<T>
- Returns:
- updated object
-
patch
public T patch()
Description copied from interface:EditReplacePatchable
Update field(s) of a resource using a JSON patch which will be computed using the latest server state as the base.It is the same as calling
EditReplacePatchable.patch(PatchContext)
withPatchType.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()
- Specified by:
patch
in interfaceEditReplacePatchable<T>
- Returns:
- returns deserialized version of api server response
-
patch
public T patch(PatchContext patchContext)
Description copied from interface:EditReplacePatchable
Update field(s) of a resource using type specified inPatchContext
(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 basePatchType.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 thePatchContext.getFieldManager()
as well to override the default.
ServerSideApplicable.serverSideApply()
- Specified by:
patch
in interfaceEditReplacePatchable<T>
- Parameters:
patchContext
-PatchContext
for patch request- Returns:
- returns deserialized version of api server response
-
fieldValidation
public NonDeletingOperation<T> fieldValidation(FieldValidateable.Validation fieldValidation)
Description copied from interface:FieldValidateable
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.- Specified by:
fieldValidation
in interfaceFieldValidateable<T>
- Returns:
- write operations where field validation is applicable.
-
fieldManager
public ServerSideApplicable<T> fieldManager(String manager)
Description copied from interface:ServerSideApplicable
FieldManager is a name associated with the actor or entity that is making these changes.The value must be less than or 128 characters long, and only contain printable characters
the default value is "fabric8"
- Specified by:
fieldManager
in interfaceServerSideApplicable<T>
- Returns:
ServerSideApplicable
for continued operations
-
forceConflicts
public ServerSideApplicable<T> forceConflicts()
Description copied from interface:ServerSideApplicable
Force this request / fieldManager to take ownership over conflicting fields.- Specified by:
forceConflicts
in interfaceServerSideApplicable<T>
- Returns:
ServerSideApplicable
for continued operations
-
serverSideApply
public T serverSideApply()
Description copied from interface:ServerSideApplicable
Perform a Kubernetes server-side apply operation. Under the hood it's an HTTP PATCH operation using theapplication/apply-patch+yaml
Content-Type.- Specified by:
serverSideApply
in interfaceServerSideApplicable<T>
- Returns:
- the patched item from the API server.
- See Also:
- Kubernetes User Guide: Server-Side Apply
-
item
public T item()
Description copied from interface:Resource
Get the item used to create the current operation context if available.
-
withTimeout
public Deletable withTimeout(long timeout, TimeUnit unit)
Description copied from interface:Deletable
Perform the delete operation as blocking, waiting for finalizers, for up to the given timeout- Specified by:
withTimeout
in interfaceDeletable
- Specified by:
withTimeout
in interfaceTimeoutable
- Parameters:
timeout
- 0 indicates no wait
-
withTimeoutInMillis
public Deletable withTimeoutInMillis(long timeoutInMillis)
Description copied from interface:Deletable
Perform the delete operation as blocking, waiting for finalizers, for up to the given timeout- Specified by:
withTimeoutInMillis
in interfaceDeletable
- Specified by:
withTimeoutInMillis
in interfaceTimeoutable
- Parameters:
timeoutInMillis
- 0 indicates no wait
-
update
public T update()
Description copied from interface:Updatable
Update the server's state with the given item (PUT).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.
-
updateStatus
public T updateStatus()
Description copied from interface:Replaceable
Similar toUpdatable.update()
, but only affects the status subresource- Specified by:
updateStatus
in interfaceReplaceable<T>
- Returns:
- returns deserialized version of api server response
-
scale
public io.fabric8.kubernetes.api.model.autoscaling.v1.Scale scale()
-
scale
public T scale(int count)
Description copied from interface:Scalable
Scale the resource to given count
-
scale
public T scale(int count, boolean wait)
Description copied from interface:Scalable
Scale the resource to given count
-
scale
public io.fabric8.kubernetes.api.model.autoscaling.v1.Scale scale(io.fabric8.kubernetes.api.model.autoscaling.v1.Scale scale)
-
createOr
public T createOr(Function<NonDeletingOperation<T>,T> conflictAction)
Description copied from interface:NonDeletingOperation
Alternative toCreateOrReplaceable.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.
- Specified by:
createOr
in interfaceNonDeletingOperation<T>
- Parameters:
conflictAction
- to be performed it the create fails with a conflict- Returns:
-
unlock
public NonDeletingOperation<T> unlock()
Description copied from interface:NonDeletingOperation
Removes the resource version from the current item. If the operation context was created by name, and without an item, this will fetch the item from the api server first.- Specified by:
unlock
in interfaceNonDeletingOperation<T>
- Returns:
- NonDeletingOperation that may act on the unlocked item
-
subresource
public EditReplacePatchable<T> subresource(String subresource)
Description copied from interface:NonDeletingOperation
Provides edit, patch, and replace methods for the given subresource- Specified by:
subresource
in interfaceNonDeletingOperation<T>
-
-