Class Yaml

java.lang.Object
io.kubernetes.client.util.Yaml

public class Yaml extends Object
The type Yaml.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Defines constructor logic for custom types in this library.
    static class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addModelMap(String apiGroupVersion, String kind, Class<?> clazz)
    Deprecated.
    static String
    dump(Object object)
    Takes an API object and returns a YAML String representing that object.
    static void
    dump(Object object, Writer writer)
    Takes an API object and writes a YAML string representing that object to the writer.
    static String
    dumpAll(Iterator<? extends io.kubernetes.client.common.KubernetesType> data)
    Takes an Iterator of YAML API objects and returns a YAML string representing all of them
    static void
    dumpAll(Iterator<? extends io.kubernetes.client.common.KubernetesType> data, Writer output)
    Takes an Iterator of YAML API objects and writes a YAML String representing all of them.
    static org.yaml.snakeyaml.Yaml
    Deprecated.
    static org.yaml.snakeyaml.Yaml
    getSnakeYaml(Class<?> type, org.yaml.snakeyaml.DumperOptions dumperOptions, org.yaml.snakeyaml.LoaderOptions loaderOptions, org.yaml.snakeyaml.TypeDescription... typeDescriptions)
    Instantiate a snake yaml with the target model type, and the dump/load option specified..
    static org.yaml.snakeyaml.Yaml
    getSnakeYaml(Class<?> type, org.yaml.snakeyaml.TypeDescription... typeDescriptions)
    Instantiate a snake yaml with the target model type specified..
    static Object
    Load an API object from a YAML file.
    static Object
    load(Reader reader)
    Load an API object from a stream of data.
    static Object
    load(String content)
    Load an API object from a YAML string representation.
    static List<Object>
    Load list of instantiated API objects from a YAML file.
    static List<Object>
    loadAll(Reader reader)
    Load list of instantiated API objects from a stream of data.
    static List<Object>
    loadAll(String content)
    Load list of instantiated API objects from a YAML string representation.
    static <T> T
    loadAs(File f, Class<T> clazz)
    Load an API object from a YAML file.
    static <T> T
    loadAs(Reader reader, Class<T> clazz)
    Load an API object from a YAML stream.
    static <T> T
    loadAs(String content, Class<T> clazz)
    Load an API object from a YAML string representation.
    static org.yaml.snakeyaml.TypeDescription
    newGsonCompatibleTypeDescription(Class modelClass, String... gsonTaggedFields)
    Instantiate a new TypeDescription which will load the SerializedName via reflection so that yaml serialization can work for the custom gson serialized name.

    Methods inherited from class java.lang.Object

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

    • Yaml

      public Yaml()
  • Method Details

    • load

      public static Object load(String content) throws IOException
      Load an API object from a YAML string representation. Returns a concrete typed object (e.g. V1Pod)
      Parameters:
      content - The YAML content
      Returns:
      An instantiation of the object.
      Throws:
      IOException - If an error occurs while reading the YAML.
    • load

      public static Object load(File f) throws IOException
      Load an API object from a YAML file. Returns a concrete typed object (e.g. V1Pod)
      Parameters:
      f - The file to load.
      Returns:
      An instantiation of the object.
      Throws:
      IOException - If an error occurs while reading the YAML.
    • load

      public static Object load(Reader reader) throws IOException
      Load an API object from a stream of data. Returns a concrete typed object (e.g. V1Pod)
      Parameters:
      reader - The stream to load.
      Returns:
      An instantiation of the object.
      Throws:
      IOException - If an error occurs while reading the YAML.
    • loadAs

      public static <T> T loadAs(String content, Class<T> clazz)
      Load an API object from a YAML string representation. Returns a concrete typed object using the type specified.
      Parameters:
      content - The YAML content
      clazz - The class of object to return.
      Returns:
      An instantiation of the object.
      Throws:
      IOException - If an error occurs while reading the YAML.
    • loadAs

      public static <T> T loadAs(File f, Class<T> clazz) throws IOException
      Load an API object from a YAML file. Returns a concrete typed object using the type specified.
      Parameters:
      f - The YAML file
      clazz - The class of object to return.
      Returns:
      An instantiation of the object.
      Throws:
      IOException - If an error occurs while reading the YAML.
    • loadAs

      public static <T> T loadAs(Reader reader, Class<T> clazz)
      Load an API object from a YAML stream. Returns a concrete typed object using the type specified.
      Parameters:
      reader - The YAML stream
      clazz - The class of object to return.
      Returns:
      An instantiation of the object.
      Throws:
      IOException - If an error occurs while reading the YAML.
    • loadAll

      public static List<Object> loadAll(String content) throws IOException
      Load list of instantiated API objects from a YAML string representation. Returns list of concrete typed objects (e.g. { V1Pod, V1SERVICE })

      Order of API objects in list will be preserved according to order of objects in YAML string.

      Parameters:
      content - The YAML content
      Returns:
      List of instantiated objects.
      Throws:
      IOException - If an error occurs while reading the YAML.
    • loadAll

      public static List<Object> loadAll(File f) throws IOException
      Load list of instantiated API objects from a YAML file. Returns list of concrete typed objects (e.g. { V1Pod, V1SERVICE })

      Order of API objects in list will be preserved according to order of objects in YAML file.

      Parameters:
      f - The file to load.
      Returns:
      List of instantiated of the objects.
      Throws:
      IOException - If an error occurs while reading the YAML.
    • loadAll

      public static List<Object> loadAll(Reader reader) throws IOException
      Load list of instantiated API objects from a stream of data. Returns list of concrete typed objects (e.g. { V1Pod, V1SERVICE })

      Order of API objects in list will be preserved according to order of objects in stream of data.

      Parameters:
      reader - The stream to load.
      Returns:
      List of instantiated of the objects.
      Throws:
      IOException - If an error occurs while reading the YAML.
    • dump

      public static String dump(Object object)
      Takes an API object and returns a YAML String representing that object.
      Parameters:
      object - The API object to dump.
      Returns:
      A YAML String representing the API object.
    • dump

      public static void dump(Object object, Writer writer)
      Takes an API object and writes a YAML string representing that object to the writer.
      Parameters:
      object - The API object to dump
      writer - The writer to write the YAML to.
    • dumpAll

      public static String dumpAll(Iterator<? extends io.kubernetes.client.common.KubernetesType> data)
      Takes an Iterator of YAML API objects and returns a YAML string representing all of them
      Parameters:
      data - The list of YAML API objects
      Returns:
      A String representing the list of YAML API objects.
    • dumpAll

      public static void dumpAll(Iterator<? extends io.kubernetes.client.common.KubernetesType> data, Writer output)
      Takes an Iterator of YAML API objects and writes a YAML String representing all of them.
      Parameters:
      data - The list of YAML API objects.
      output - The writer to output the YAML String to.
    • getSnakeYaml

      @Deprecated public static org.yaml.snakeyaml.Yaml getSnakeYaml()
      Deprecated.
      Instantiate a snake yaml with a default SafeConstructor.

      DEPRECATED: Use the parameterized "getSnakeYaml" constructing method below to get rid of vulnerability from dynamic type serialization.

      Returns:
      the snake yaml
    • getSnakeYaml

      public static org.yaml.snakeyaml.Yaml getSnakeYaml(Class<?> type, org.yaml.snakeyaml.TypeDescription... typeDescriptions)
      Instantiate a snake yaml with the target model type specified.. Optionally, passing custom type descriptions if the target serialized name differs from the actual field name.
      Parameters:
      type - the target model type
      typeDescriptions - additional type descriptions for customizing the serializer
      Returns:
      the new snake yaml instance
    • getSnakeYaml

      public static org.yaml.snakeyaml.Yaml getSnakeYaml(Class<?> type, org.yaml.snakeyaml.DumperOptions dumperOptions, org.yaml.snakeyaml.LoaderOptions loaderOptions, org.yaml.snakeyaml.TypeDescription... typeDescriptions)
      Instantiate a snake yaml with the target model type, and the dump/load option specified.. Optionally, passing custom type descriptions if the target serialized name differs from the actual field name.
      Parameters:
      type - the target model type
      dumperOptions - the dumper options
      loaderOptions - the loader options
      typeDescriptions - additional type descriptions for customizing the serializer
      Returns:
      the new snake yaml instance
    • newGsonCompatibleTypeDescription

      public static org.yaml.snakeyaml.TypeDescription newGsonCompatibleTypeDescription(Class modelClass, String... gsonTaggedFields)
      Instantiate a new TypeDescription which will load the SerializedName via reflection so that yaml serialization can work for the custom gson serialized name.
      Parameters:
      modelClass - the kubenretes api model class
      gsonTaggedFields - the custom serialized names tagged by gson
      Returns:
      the type description
    • addModelMap

      @Deprecated public static void addModelMap(String apiGroupVersion, String kind, Class<?> clazz)
      Deprecated.