Class OperationSupport

    • Constructor Detail

      • OperationSupport

        public OperationSupport​(Client client)
    • Method Detail

      • getAPIGroupName

        public String getAPIGroupName()
      • getAPIGroupVersion

        public String getAPIGroupVersion()
      • getResourceT

        public String getResourceT()
      • getNamespace

        public String getNamespace()
      • getName

        public String getName()
      • isResourceNamespaced

        public boolean isResourceNamespaced()
      • getRootUrlParts

        protected List<String> getRootUrlParts()
      • addNamespacedUrlPathParts

        protected void addNamespacedUrlPathParts​(List<String> parts,
                                                 String namespace,
                                                 String type)
      • correctNamespace

        protected <T> T correctNamespace​(T item)
      • checkNamespace

        protected <T> String checkNamespace​(T item)
      • checkName

        protected <T> String checkName​(T item)
      • handleCreate

        protected <T,​I> T handleCreate​(I resource,
                                             Class<T> outputType)
                                      throws InterruptedException,
                                             IOException
        Create a resource.
        Type Parameters:
        T - template argument for output type
        I - template argument for resource
        Parameters:
        resource - resource provided
        outputType - resource type you want as output
        Returns:
        returns de-serialized version of apiserver response in form of type provided
        Throws:
        InterruptedException - Interrupted Exception
        IOException - IOException
      • handleUpdate

        protected <T> T handleUpdate​(T updated,
                                     Class<T> type)
                              throws IOException
        Replace a resource.
        Type Parameters:
        T - template argument provided
        Parameters:
        updated - updated object
        type - type of the object provided
        Returns:
        returns de-serialized version of api server response
        Throws:
        IOException - IOException
      • handlePatch

        protected <T> T handlePatch​(PatchContext patchContext,
                                    T current,
                                    T updated,
                                    Class<T> type)
                             throws InterruptedException,
                                    IOException
        Send an http patch and handle the response. If current is not null and patchContext does not specify a patch type, then a JSON patch is assumed. Otherwise a STRATEGIC MERGE is assumed.
        Type Parameters:
        T - template argument provided
        Parameters:
        patchContext - patch options for patch request
        current - current object
        updated - updated object
        type - type of object
        Returns:
        returns de-serialized version of api server response
        Throws:
        InterruptedException - Interrupted Exception
        IOException - IOException
      • handlePatch

        protected <T> T handlePatch​(PatchContext patchContext,
                                    T current,
                                    String patchForUpdate,
                                    Class<T> type)
                             throws InterruptedException,
                                    IOException
        Send an http patch and handle the response.
        Type Parameters:
        T - template argument provided
        Parameters:
        patchContext - patch options for patch request
        current - current object
        patchForUpdate - Patch string
        type - type of object
        Returns:
        returns de-serialized version of api server response
        Throws:
        InterruptedException - Interrupted Exception
        IOException - IOException in case of network errors
      • handleScale

        protected <T> T handleScale​(String resourceUrl,
                                    T scale,
                                    Class<T> scaleType)
                             throws InterruptedException,
                                    IOException
        Replace Scale of specified Kubernetes Resource
        Parameters:
        resourceUrl - Kubernetes resource URL
        scale - Scale object which we want to inject
        Returns:
        updated Scale object
        Throws:
        InterruptedException - in case thread is interrupted
        IOException - in some other I/O problem
      • handleDeploymentRollback

        protected io.fabric8.kubernetes.api.model.Status handleDeploymentRollback​(String resourceUrl,
                                                                                  io.fabric8.kubernetes.api.model.extensions.DeploymentRollback deploymentRollback)
                                                                           throws InterruptedException,
                                                                                  IOException
        Create rollback of a Deployment
        Parameters:
        resourceUrl - resource url
        deploymentRollback - DeploymentRollback resource
        Returns:
        Status
        Throws:
        InterruptedException - in case thread is interrupted
        IOException - in some other I/O problem
      • handleGet

        protected <T> T handleGet​(URL resourceUrl,
                                  Class<T> type)
                           throws IOException
        Send an http get.
        Type Parameters:
        T - template argument provided
        Parameters:
        resourceUrl - resource URL to be processed
        type - type of resource
        Returns:
        returns a deserialized object as api server response of provided type.
        Throws:
        IOException - IOException
      • handleRawGet

        protected <T> T handleRawGet​(URL resourceUrl,
                                     Class<T> type)
                              throws IOException
        Send a raw get - where the type should be one of String, Reader, InputStream
        Throws:
        IOException
      • waitForResult

        protected <T> T waitForResult​(CompletableFuture<T> future)
                               throws IOException
        Waits for the provided CompletableFuture to complete and returns the result in case of success.
        Type Parameters:
        T - the type of the result
        Parameters:
        future - the CompletableFuture to wait for
        Returns:
        the result of the completed future
        Throws:
        IOException - in case there's an I/O problem
      • handleResponse

        protected <T> T handleResponse​(HttpRequest.Builder requestBuilder,
                                       Class<T> type)
                                throws IOException
        Send an http request and handle the response.
        Type Parameters:
        T - template argument provided
        Parameters:
        requestBuilder - Request Builder object
        type - type of resource
        Returns:
        Returns a de-serialized object as api server response of provided type.
        Throws:
        IOException - IOException
      • handleResponse

        protected <T> CompletableFuture<T> handleResponse​(HttpClient client,
                                                          HttpRequest.Builder requestBuilder,
                                                          com.fasterxml.jackson.core.type.TypeReference<T> type)
        Send an http request and handle the response, optionally performing placeholder substitution to the response.
        Type Parameters:
        T - Template argument provided
        Parameters:
        client - the client
        requestBuilder - Request builder
        type - Type of object provided
        Returns:
        Returns a de-serialized object as api server response of provided type.
      • assertResponseCode

        protected void assertResponseCode​(HttpRequest request,
                                          HttpResponse<?> response)
        Checks if the response status code is the expected and throws the appropriate KubernetesClientException if not.
        Parameters:
        request - The {#link HttpRequest} object.
        response - The HttpResponse object.
      • createStatus

        public static io.fabric8.kubernetes.api.model.Status createStatus​(int statusCode,
                                                                          String message)
      • getConfig

        public Config getConfig()
      • restCall

        public <R1> R1 restCall​(Class<R1> result,
                                String... path)
      • handleRaw

        public <R1> R1 handleRaw​(Class<R1> result,
                                 String uri,
                                 String method,
                                 Object payload)
        Send a raw request - where the type should be one of String, Reader, InputStream