Class RawCustomResourceOperationsImpl

java.lang.Object
io.fabric8.kubernetes.client.dsl.base.OperationSupport
io.fabric8.kubernetes.client.dsl.internal.RawCustomResourceOperationsImpl

public class RawCustomResourceOperationsImpl
extends OperationSupport
This class simple does basic operations for custom defined resources without demanding the POJOs for custom resources. It is serializing/deserializing objects to plain hash map(String, Object). Right now it supports basic operations like GET, POST, PUT, DELETE.
  • Constructor Details

  • Method Details

    • load

      public Map<String,​Object> load​(InputStream fileInputStream) throws IOException
      Load a custom resource object from an inputstream into a HashMap
      Parameters:
      fileInputStream - file input stream
      Returns:
      custom resource as HashMap
      Throws:
      IOException - exception in case any read operation fails.
    • load

      public Map<String,​Object> load​(String objectAsJsonString) throws IOException
      Load a custom resource object from a JSON string into a HashMap
      Parameters:
      objectAsJsonString - object as JSON string
      Returns:
      custom resource as HashMap
      Throws:
      IOException - exception in case any problem in reading json.
    • create

      public Map<String,​Object> create​(String objectAsString) throws IOException
      Create a custom resource which is a non-namespaced object.
      Parameters:
      objectAsString - object as JSON string
      Returns:
      Object as HashMap
      Throws:
      IOException - exception in case of any network/read problems
    • create

      public Map<String,​Object> create​(Map<String,​Object> object) throws KubernetesClientException, IOException
      Create a custom resource which is non-namespaced.
      Parameters:
      object - object a HashMap
      Returns:
      Object as HashMap
      Throws:
      KubernetesClientException - in case of error from Kubernetes API
      IOException - in case of problems while reading HashMap
    • create

      public Map<String,​Object> create​(String namespace, String objectAsString) throws KubernetesClientException, IOException
      Create a custom resource which is a namespaced object.
      Parameters:
      namespace - namespace in which we want object to be created.
      objectAsString - Object as JSON string
      Returns:
      Object as HashMap
      Throws:
      KubernetesClientException - in case of error from Kubernetes API
      IOException - in case of problems while reading JSON object
    • create

      public Map<String,​Object> create​(InputStream objectAsStream) throws KubernetesClientException, IOException
      Create a custom resource which is non-namespaced object.
      Parameters:
      objectAsStream - object as a file input stream
      Returns:
      Object as HashMap
      Throws:
      KubernetesClientException - in case of error from Kubernetes API
      IOException - in case of problems while reading file
    • create

      public Map<String,​Object> create​(String namespace, InputStream objectAsStream) throws KubernetesClientException, IOException
      Create a custom resource which is a namespaced object.
      Parameters:
      namespace - namespace in which we want object to be created
      objectAsStream - object as file input stream
      Returns:
      Object as HashMap
      Throws:
      KubernetesClientException - in case of error from Kubernetes API
      IOException - in case of problems while reading file
    • create

      public Map<String,​Object> create​(String namespace, Map<String,​Object> object) throws KubernetesClientException, IOException
      Create a custom resource which is a namespaced object.
      Parameters:
      namespace - namespace in which we want object to be created.
      object - object as a HashMap
      Returns:
      Object as HashMap
      Throws:
      KubernetesClientException - in case of error from Kubernetes API
      IOException - in case of problems faced while serializing HashMap
    • createOrReplace

      public Map<String,​Object> createOrReplace​(String objectAsString) throws IOException
      Create or replace a custom resource which is a non-namespaced object.
      Parameters:
      objectAsString - object as JSON string
      Returns:
      Object as HashMap
      Throws:
      IOException - in case of network/serializiation failures or failures from Kuberntes API
    • createOrReplace

      public Map<String,​Object> createOrReplace​(Map<String,​Object> customResourceObject) throws IOException
      Create or replace a custom resource which is a non-namespced object.
      Parameters:
      customResourceObject - object as HashMap
      Returns:
      Object as HashMap
      Throws:
      IOException - in case of network/serialization failures or failures from Kubernetes API
    • createOrReplace

      public Map<String,​Object> createOrReplace​(InputStream inputStream) throws IOException
      Create or replace a custom resource which is non-namespaced object.
      Parameters:
      inputStream - object as file input stream
      Returns:
      Object as HashMap
      Throws:
      IOException - in case of network/serialization failures or failures from Kubernetes API
    • createOrReplace

      public Map<String,​Object> createOrReplace​(String namespace, String objectAsString) throws IOException
      Create or replace a custom resource which is namespaced object.
      Parameters:
      namespace - desired namespace
      objectAsString - object as JSON String
      Returns:
      Object as HashMap
      Throws:
      IOException - in case of network/serialization failures or failures from Kubernetes API
    • createOrReplace

      public Map<String,​Object> createOrReplace​(String namespace, Map<String,​Object> customResourceObject) throws IOException
      Create or replace a custom resource which is namespaced object.
      Parameters:
      namespace - desired namespace
      customResourceObject - object as HashMap
      Returns:
      Object as HashMap
      Throws:
      IOException - in case of network/serialization failures or failures from Kubernetes API
    • createOrReplace

      public Map<String,​Object> createOrReplace​(String namespace, InputStream objectAsStream) throws IOException
      Create or replace a custom resource which is namespaced object.
      Parameters:
      namespace - desired namespace
      objectAsStream - object as file input stream
      Returns:
      Object as HashMap
      Throws:
      IOException - in case of network/serialization failures or failures from Kubernetes API
    • edit

      public Map<String,​Object> edit​(String name, Map<String,​Object> object) throws IOException
      Edit a custom resource object which is a non-namespaced object.
      Parameters:
      name - name of the custom resource
      object - new object as a HashMap
      Returns:
      Object as HashMap
      Throws:
      IOException - in case of network/serialization failures or failures from Kubernetes API
    • edit

      public Map<String,​Object> edit​(String name, String objectAsString) throws IOException
      Edit a custom resource object which is a non-namespaced object.
      Parameters:
      name - name of the custom resource
      objectAsString - new object as a JSON String
      Returns:
      Object as HashMap
      Throws:
      IOException - in case of network/serialization failures or failures from Kubernetes API
    • edit

      public Map<String,​Object> edit​(String namespace, String name, Map<String,​Object> object) throws IOException
      Edit a custom resource object which is a namespaced object.
      Parameters:
      namespace - desired namespace
      name - name of the custom resource
      object - new object as a HashMap
      Returns:
      Object as HashMap
      Throws:
      IOException - in case of network/serialization failures or failures from Kubernetes API
    • edit

      public Map<String,​Object> edit​(String namespace, String name, String objectAsString) throws IOException
      Edit a custom resource object which is a namespaced object.
      Parameters:
      namespace - desired namespace
      name - name of the custom resource
      objectAsString - new object as a JSON string
      Returns:
      Object as HashMap
      Throws:
      IOException - in case of network/serialization failures or failures from Kubernetes API
    • edit

      public Map<String,​Object> edit​(String name, InputStream objectAsStream) throws IOException, KubernetesClientException
      Edit a custom resource object which is a non-namespaced object.
      Parameters:
      name - name of the custom resource
      objectAsStream - new object as a file input stream
      Returns:
      Object as HashMap
      Throws:
      IOException - in case of network/serialization failures or failures from Kubernetes API
      KubernetesClientException
    • edit

      public Map<String,​Object> edit​(String namespace, String name, InputStream objectAsStream) throws IOException, KubernetesClientException
      Edit a custom resource object which is a namespaced object.
      Parameters:
      namespace - desired namespace
      name - name of the custom resource
      objectAsStream - new object as a file input stream
      Returns:
      Object as HashMap
      Throws:
      IOException - in case of network/serialization failures or failures from Kubernetes API
      KubernetesClientException
    • updateStatus

      public Map<String,​Object> updateStatus​(String name, Map<String,​Object> objectAsMap) throws IOException, KubernetesClientException
      Update status related to a CustomResource, this method does a PUT request on /status endpoint related to the CustomResource
      Parameters:
      name - name of custom resource
      objectAsMap - custom resource as a HashMap
      Returns:
      updated CustomResource as HashMap
      Throws:
      IOException - in case any failure to parse Map
      KubernetesClientException - in case any failure from Kubernetes APIs
    • updateStatus

      public Map<String,​Object> updateStatus​(String name, String objectAsJsonString) throws IOException, KubernetesClientException
      Update status related to a CustomResource, this method does a PUT request on /status endpoint related to the CustomResource
      Parameters:
      name - name of CustomResource
      objectAsJsonString - CustomResource as a JSON string
      Returns:
      updated CustomResource as a HashMap
      Throws:
      IOException - in case any failure to parse Map
      KubernetesClientException - in case any failure from Kubernetes APIs
    • updateStatus

      public Map<String,​Object> updateStatus​(String namespace, String name, Map<String,​Object> objectAsMap) throws IOException, KubernetesClientException
      Update status related to a CustomResource, this method does a PUT request on /status endpoint related to the CustomResource
      Parameters:
      namespace - namespace of CustomResource
      name - name of CustomResource
      objectAsMap - CustomResource as a HashMap
      Returns:
      updated CustomResource as a HashMap
      Throws:
      IOException - in case any failure to parse Map
      KubernetesClientException - in case any failure from Kubernetes APIs
    • updateStatus

      public Map<String,​Object> updateStatus​(String name, InputStream objectAsStream) throws IOException, KubernetesClientException
      Update status related to a CustomResource, this method does a PUT request on /status endpoint related to the CustomResource
      Parameters:
      name - name of CustomResource
      objectAsStream - stream pointing to CustomResource
      Returns:
      updated CustomResource as a HashMap
      Throws:
      IOException - in case any failure to parse Map
      KubernetesClientException - in case any failure from Kubernetes APIs
    • updateStatus

      public Map<String,​Object> updateStatus​(String namespace, String name, InputStream objectAsStream) throws IOException, KubernetesClientException
      Update status related to a CustomResource, this method does a PUT request on /status endpoint related to the CustomResource
      Parameters:
      namespace - namespace of CustomResource
      name - name of CustomResource
      objectAsStream - CustomResource object as a stream
      Returns:
      updated CustomResource as a HashMap
      Throws:
      IOException - in case any failure to parse Map
      KubernetesClientException - in case any failure from Kubernetes APIs
    • updateStatus

      public Map<String,​Object> updateStatus​(String namespace, String name, String objectAsJsonString) throws IOException, KubernetesClientException
      Update status related to a CustomResource, this method does a PUT request on /status endpoint related to the CustomResource
      Parameters:
      namespace - namespace of CustomResource
      name - name of CustomResource
      objectAsJsonString - CustomResource object as a JSON string
      Returns:
      updated CustomResource as a HashMap
      Throws:
      IOException - in case any failure to parse Map
      KubernetesClientException - in case any failure from Kubernetes APIs
    • get

      public Map<String,​Object> get​(String name)
      Get a custom resource from the cluster which is non-namespaced.
      Parameters:
      name - name of custom resource
      Returns:
      Object as HashMap
    • get

      public Map<String,​Object> get​(String namespace, String name)
      Get a custom resource from the cluster which is namespaced.
      Parameters:
      namespace - desired namespace
      name - name of custom resource
      Returns:
      Object as HashMap
    • list

      public Map<String,​Object> list()
      List all custom resources in all namespaces
      Returns:
      list of custom resources as HashMap
    • list

      public Map<String,​Object> list​(String namespace)
      List all custom resources in a specific namespace
      Parameters:
      namespace - desired namespace
      Returns:
      list of custom resources as HashMap
    • list

      public Map<String,​Object> list​(String namespace, Map<String,​String> labels)
      List all custom resources in a specific namespace with some labels
      Parameters:
      namespace - desired namespace
      labels - labels as a HashMap
      Returns:
      list of custom resources as HashMap
    • delete

      public Map<String,​Object> delete​(String namespace)
      Delete all custom resources in a specific namespace
      Parameters:
      namespace - desired namespace
      Returns:
      deleted objects as HashMap
    • delete

      public Map<String,​Object> delete​(String namespace, boolean cascading) throws IOException
      Delete all custom resources in a specific namespace
      Parameters:
      namespace - desired namespace
      cascading - whether dependent object need to be orphaned or not. If true/false, the "orphan" finalizer will be added to/removed from the object's finalizers list.
      Returns:
      deleted objects as HashMap
      Throws:
      IOException - in case of any network/parsing exception
    • delete

      public Map<String,​Object> delete​(String namespace, io.fabric8.kubernetes.api.model.DeleteOptions deleteOptions) throws IOException
      Delete all custom resources in a specific namespace
      Parameters:
      namespace - desired namespace
      deleteOptions - object provided by Kubernetes API for more fine grained control over deletion. For more information please see https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.16/#deleteoptions-v1-meta
      Returns:
      deleted object as HashMap
      Throws:
      IOException - in case of any network/object parse problems
    • delete

      public Map<String,​Object> delete​(String namespace, String name) throws IOException
      Delete a custom resource in a specific namespace
      Parameters:
      namespace - desired namespace
      name - custom resource's name
      Returns:
      object as HashMap
      Throws:
      IOException
    • delete

      public Map<String,​Object> delete​(String namespace, String name, boolean cascading) throws IOException
      Delete a custom resource in a specific namespace
      Parameters:
      namespace - required namespace
      name - required name of custom resource
      cascading - whether dependent object need to be orphaned or not. If true/false, the "orphan" finalizer will be added to/removed from the object's finalizers list.
      Returns:
      deleted objects as HashMap
      Throws:
      IOException - exception related to network/object parsing
    • delete

      public Map<String,​Object> delete​(String namespace, String name, String propagationPolicy) throws IOException
      Delete a custom resource in a specific namespace
      Parameters:
      namespace - required namespace
      name - required name of custom resource
      propagationPolicy - 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.
      Returns:
      deleted object as HashMap
      Throws:
      IOException - in case of network/object parse exception
    • delete

      public Map<String,​Object> delete​(String namespace, String name, io.fabric8.kubernetes.api.model.DeleteOptions deleteOptions) throws IOException
      Delete a custom resource in a specific namespace
      Parameters:
      namespace - required namespace
      name - name of custom resource
      deleteOptions - object provided by Kubernetes API for more fine grained control over deletion. For more information please see https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.16/#deleteoptions-v1-meta
      Returns:
      deleted object as HashMap
      Throws:
      IOException - in case of any network/object parse exception
    • watch

      public void watch​(String namespace, Watcher<String> watcher) throws IOException
      Watch custom resources in a specific namespace. Here Watcher is provided for string type only. User has to deserialize object itself.
      Parameters:
      namespace - namespace to watch
      watcher - watcher object which reports updates with object
      Throws:
      IOException - in case of network error
    • watch

      public void watch​(String namespace, String resourceVersion, Watcher<String> watcher) throws IOException
      Watch a custom resource in a specific namespace with some resourceVersion. Here watcher is provided from string type only. User has to deserialize object itself.
      Parameters:
      namespace - namespace to watch
      resourceVersion - resource version since when to watch
      watcher - watcher object which reports updates
      Throws:
      IOException - in case of network error
    • watch

      public void watch​(String namespace, io.fabric8.kubernetes.api.model.ListOptions options, Watcher<String> watcher) throws IOException
      Watch a custom resource in a specific namespace with some resourceVersion. Here watcher is provided from string type only. User has to deserialize object itself.
      Parameters:
      namespace - namespace to watch
      options - ListOptions list options for watching
      watcher - watcher object which reports updates
      Throws:
      IOException - in case of network error
    • watch

      public void watch​(Watcher<String> watcher) throws IOException
      Watchers custom resources across all namespaces. Here watcher is provided for string type only. User has to deserialize object itself.
      Parameters:
      watcher - watcher object which reports events
      Throws:
      IOException - in case of network error
    • watch

      public Watch watch​(String namespace, String name, Map<String,​String> labels, String resourceVersion, Watcher<String> watcher) throws IOException
      Watch custom resources in the parameters specified. Most of the parameters except watcher are optional, they would be skipped if passed null. Here watcher is provided for string type only. User has to deserialize the object itself.
      Parameters:
      namespace - namespace to watch (optional
      name - name of custom resource (optional)
      labels - HashMap containing labels (optional)
      resourceVersion - resource version to start watch from
      watcher - watcher object which reports events
      Throws:
      IOException - in case of network error
    • watch

      public Watch watch​(String namespace, String name, Map<String,​String> labels, io.fabric8.kubernetes.api.model.ListOptions options, Watcher<String> watcher) throws IOException
      Watch custom resources in the parameters specified. Most of the parameters except watcher are optional, they would be skipped if passed null. Here watcher is provided for string type only. User has to deserialize the object itself.
      Parameters:
      namespace - namespace to watch (optional
      name - name of custom resource (optional)
      labels - HashMap containing labels (optional)
      options - ListOptions list options for watch
      watcher - watcher object which reports events
      Returns:
      watch object for watching resource
      Throws:
      IOException - in case of network error
    • fetchWatchUrl

      protected okhttp3.HttpUrl.Builder fetchWatchUrl​(String namespace, String name, Map<String,​String> labels, io.fabric8.kubernetes.api.model.ListOptions options) throws MalformedURLException
      Throws:
      MalformedURLException