Class ResourceAdapter<T>

    • Constructor Detail

      • ResourceAdapter

        public ResourceAdapter()
      • ResourceAdapter

        public ResourceAdapter​(Resource<T> resource)
    • Method Detail

      • getResource

        public Resource<T> getResource()
      • delete

        public List<io.fabric8.kubernetes.api.model.StatusDetails> delete()
        Description copied from interface: Deletable
        Deletes the resources at this context and returns the 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

        Specified by:
        delete in interface Deletable
      • 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.

        Specified by:
        isReady in interface Resource<T>
        Returns:
        true if the resource exists and is ready.
      • get

        public T get()
        Description copied from interface: Gettable
        Get the current state from the api server. See also Resource.item()
        Specified by:
        get in interface Gettable<T>
        Returns:
        the item or null if the item doesn't exist.
      • 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 interface DryRunable<T>
        Returns:
        write operations which are applicable for dry run
      • 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 interface GracePeriodConfigurable<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 interface CreateOrReplaceable<T>
        Returns:
        created item returned in kubernetes api response
        See Also:
        Migration FAQ
      • 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 interface PropagationPolicyConfigurable<T>
        Parameters:
        propagationPolicy - propagation policy in form of string DeletionPropagation
        Returns:
        resource
      • watch

        public Watch watch​(Watcher<T> watcher)
        Description copied from interface: Watchable
        Watch returns Watch interface that watches requested resource
        Specified by:
        watch in interface Watchable<T>
        Parameters:
        watcher - Watcher interface of Kubernetes resource
        Returns:
        watch interface Watch
      • 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) 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()

        Specified by:
        patch in interface EditReplacePatchable<T>
        Parameters:
        item - to be patched with patched values
        Returns:
        returns deserialized version of api server response
      • 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 interface EditReplacePatchable<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 general Waitable.waitUntilCondition(Predicate, long, TimeUnit) when dealing with more complex situations or other types.
        Specified by:
        waitUntilReady in interface Waitable<T,​T>
      • watch

        public Watch watch​(io.fabric8.kubernetes.api.model.ListOptions options,
                           Watcher<T> watcher)
        Description copied from interface: Watchable
        Watch returns 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.

        Specified by:
        watch in interface Watchable<T>
        Parameters:
        options - options available for watch operation
        watcher - Watcher interface of Kubernetes resource
        Returns:
        watch interface Watch
      • 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 interface Waitable<T,​T>
        Returns:
        the result that passes the given condition
      • 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 interface DryRunable<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 interface EditReplacePatchable<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 in PatchContext(defaults to strategic merge if not specified). WARNING: For a JSON patch and 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 interface EditReplacePatchable<T>
        Parameters:
        patchContext - PatchContext for patch request
        item - 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 interface Informable<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 interface EditReplacePatchable<T>
        Parameters:
        visitorType - to create a TypedVisitor
        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 returns Watch interface that watches requested resource from specified resourceVersion
        Specified by:
        watch in interface Watchable<T>
        Parameters:
        resourceVersion - resource version from where to start watch
        watcher - Watcher interface of Kubernetes resource
        Returns:
        watch interface Watch
      • 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 interface EditReplacePatchable<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 a 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.

        Specified by:
        inform in interface Informable<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 interface EditReplacePatchable<T>
        Parameters:
        patch - The patch to be applied to the resource JSON file.
        Returns:
        returns deserialized version of api server response
      • inform

        public SharedIndexInformer<T> inform​(ResourceEventHandler<? super T> handler)
        Description copied from interface: Informable
        Similar to a 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.

        Specified by:
        inform in interface Informable<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 a 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.

        Specified by:
        inform in interface Informable<T>
        Parameters:
        handler - to notify
        resync - 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 a 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.

        Specified by:
        runnableInformer in interface Informable<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 a 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.

        Specified by:
        informOnCondition in interface Informable<T>
        Parameters:
        condition - the Predicate 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 interface Updatable<T>
        Returns:
        returns deserialized version of api server response
        See Also:
        Migration FAQ
      • 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 interface ItemWritableOperation<T>
        Parameters:
        item - to create or replace
        Returns:
        created or replaced item returned in kubernetes api response
      • 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 interface ItemWritableOperation<T>
        Parameters:
        item - kubernetes object
        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) 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()

        Specified by:
        patch in interface EditReplacePatchable<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 in 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.
        WARNING: For a JSON patch and 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 interface EditReplacePatchable<T>
        Parameters:
        patchContext - PatchContext for patch request
        Returns:
        returns deserialized version of api server response
      • item

        public T item()
        Description copied from interface: Resource
        Get the item used to create the current operation context if available.
        Specified by:
        item in interface Resource<T>
        Returns:
        the current item if provided via the load, resource, or resourceList method, or null if this resource was created just from a class.
      • 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 interface Deletable
        Specified by:
        withTimeout in interface Timeoutable
        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 interface Deletable
        Specified by:
        withTimeoutInMillis in interface Timeoutable
        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.

        Specified by:
        update in interface Updatable<T>
        Returns:
        returns deserialized version of api server response
      • updateStatus

        public T updateStatus()
        Description copied from interface: Replaceable
        Similar to Updatable.update(), but only affects the status subresource
        Specified by:
        updateStatus in interface Replaceable<T>
        Returns:
        returns deserialized version of api server response
      • scale

        public io.fabric8.kubernetes.api.model.autoscaling.v1.Scale scale()
        Specified by:
        scale in interface Scalable<T>
      • scale

        public T scale​(int count)
        Description copied from interface: Scalable
        Scale the resource to given count
        Specified by:
        scale in interface Scalable<T>
        Parameters:
        count - the desired instance count
        Returns:
        the resource
      • scale

        public T scale​(int count,
                       boolean wait)
        Description copied from interface: Scalable
        Scale the resource to given count
        Specified by:
        scale in interface Scalable<T>
        Parameters:
        count - the desired instance count
        wait - if true, wait for the number of instances to exist - no guarantee is made as to readiness
        Returns:
        the resource
      • scale

        public io.fabric8.kubernetes.api.model.autoscaling.v1.Scale scale​(io.fabric8.kubernetes.api.model.autoscaling.v1.Scale scale)
        Specified by:
        scale in interface Scalable<T>
      • createOr

        public T createOr​(Function<NonDeletingOperation<T>,​T> conflictAction)
        Description copied from interface: NonDeletingOperation
        Alternative to 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.

        Specified by:
        createOr in interface NonDeletingOperation<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 interface NonDeletingOperation<T>
        Returns:
        NonDeletingOperation that may act on the unlocked item