Class K8s

java.lang.Object
org.jdrupes.vmoperator.common.K8s

public class K8s extends Object
Helpers for K8s API.
  • Constructor Summary

    Constructors
    Constructor
    Description
    K8s()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T extends io.kubernetes.client.common.KubernetesObject, LT extends io.kubernetes.client.common.KubernetesListObject>
    T
    apply(io.kubernetes.client.util.generic.GenericKubernetesApi<T,LT> api, T existing, String update)
    Apply the given patch data.
    static Optional<io.kubernetes.client.Discovery.APIResource>
    context(io.kubernetes.client.openapi.ApiClient client, String group, String version, String kind)
    Lookup the specified API resource.
    static void
    createEvent(io.kubernetes.client.openapi.ApiClient client, io.kubernetes.client.common.KubernetesObject object, io.kubernetes.client.openapi.models.EventsV1Event event)
    Creates an event related to the object, adding reasonable defaults.
    static <T extends io.kubernetes.client.common.KubernetesObject, LT extends io.kubernetes.client.common.KubernetesListObject>
    Optional<T>
    get(io.kubernetes.client.util.generic.GenericKubernetesApi<T,LT> api, io.kubernetes.client.openapi.models.V1ObjectMeta meta)
    Deprecated.
    static io.kubernetes.client.openapi.models.V1ObjectReference
    objectReference(io.kubernetes.client.common.KubernetesObject object)
    Create an object reference.
    static <T extends io.kubernetes.client.common.KubernetesType>
    Optional<T>
    optional(io.kubernetes.client.util.generic.KubernetesApiResponse<T> response)
    Returns the result from an API call as Optional if the call was successful.
    static io.kubernetes.client.Discovery.APIResource
    preferred(io.kubernetes.client.Discovery.APIResource context, String version)
    Returns a new context with the given version as preferred version.
    static String
    toString(io.kubernetes.client.Discovery.APIResource context)
    Return a string representation of the context (API resource).
    static com.google.gson.JsonObject
    yamlToJson(io.kubernetes.client.openapi.ApiClient client, Reader yaml)
    Convert Yaml to Json.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • K8s

      public K8s()
  • Method Details

    • optional

      public static <T extends io.kubernetes.client.common.KubernetesType> Optional<T> optional(io.kubernetes.client.util.generic.KubernetesApiResponse<T> response) throws io.kubernetes.client.openapi.ApiException
      Returns the result from an API call as Optional if the call was successful.

      Returns an empty Optional if the status code is 404 (not found). Else throws an exception.

      Type Parameters:
      T - the generic type
      Parameters:
      response - the response
      Returns:
      the optional
      Throws:
      io.kubernetes.client.openapi.ApiException - the API exception
    • preferred

      public static io.kubernetes.client.Discovery.APIResource preferred(io.kubernetes.client.Discovery.APIResource context, String version)
      Returns a new context with the given version as preferred version.
      Parameters:
      context - the context
      version - the version
      Returns:
      the API resource
    • toString

      public static String toString(io.kubernetes.client.Discovery.APIResource context)
      Return a string representation of the context (API resource).
      Parameters:
      context - the context
      Returns:
      the string
    • yamlToJson

      public static com.google.gson.JsonObject yamlToJson(io.kubernetes.client.openapi.ApiClient client, Reader yaml)
      Convert Yaml to Json.
      Parameters:
      client - the client
      yaml - the yaml
      Returns:
      the json element
    • context

      public static Optional<io.kubernetes.client.Discovery.APIResource> context(io.kubernetes.client.openapi.ApiClient client, String group, String version, String kind) throws io.kubernetes.client.openapi.ApiException
      Lookup the specified API resource.

      If the version is null or empty, the preferred version in the result is the default returned from the server.

      Parameters:
      client - the client
      group - the group
      version - the version
      kind - the kind
      Returns:
      the optional
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception
    • get

      @Deprecated public static <T extends io.kubernetes.client.common.KubernetesObject, LT extends io.kubernetes.client.common.KubernetesListObject> Optional<T> get(io.kubernetes.client.util.generic.GenericKubernetesApi<T,LT> api, io.kubernetes.client.openapi.models.V1ObjectMeta meta)
      Deprecated.
      Get an object from its metadata.
      Type Parameters:
      T - the generic type
      LT - the generic type
      Parameters:
      api - the api
      meta - the meta
      Returns:
      the object
    • apply

      public static <T extends io.kubernetes.client.common.KubernetesObject, LT extends io.kubernetes.client.common.KubernetesListObject> T apply(io.kubernetes.client.util.generic.GenericKubernetesApi<T,LT> api, T existing, String update) throws io.kubernetes.client.openapi.ApiException
      Apply the given patch data.
      Type Parameters:
      T - the generic type
      LT - the generic type
      Parameters:
      api - the api
      existing - the existing
      update - the update
      Returns:
      the t
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception
    • objectReference

      public static io.kubernetes.client.openapi.models.V1ObjectReference objectReference(io.kubernetes.client.common.KubernetesObject object)
      Create an object reference.
      Parameters:
      object - the object
      Returns:
      the v 1 object reference
    • createEvent

      public static void createEvent(io.kubernetes.client.openapi.ApiClient client, io.kubernetes.client.common.KubernetesObject object, io.kubernetes.client.openapi.models.EventsV1Event event) throws io.kubernetes.client.openapi.ApiException
      Creates an event related to the object, adding reasonable defaults.
      • If kind is not set, it is set to “Event”.
        • If metadata.namespace is not set, it is set to the object’s namespace.
        • If neither metadata.name nor matadata.generateName are set, set generateName to the object’s name with a dash appended.
        • If reportingInstance is not set, set it to the object’s name.
        • If eventTime is not set, set it to now.
        • If type is not set, set it to “Normal”
        • If regarding is not set, set it to the given object.
      Parameters:
      client - the client
      object - the object
      event - the event
      Throws:
      io.kubernetes.client.openapi.ApiException - the api exception