io.kubernetes.client.util.Yaml类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(308)

本文整理了Java中io.kubernetes.client.util.Yaml类的一些代码示例,展示了Yaml类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Yaml类的具体详情如下:
包路径:io.kubernetes.client.util.Yaml
类名称:Yaml

Yaml介绍

暂无

代码示例

代码示例来源:origin: kubernetes-client/java

/**
 * Load an API object from a stream of data. Returns a concrete typed object (e.g. V1Pod)
 *
 * @param reader The stream to load.
 * @return An instantiation of the object.
 * @throws IOException If an error occurs while reading the YAML.
 */
public static Object load(Reader reader) throws IOException {
 Map<String, Object> data = getSnakeYaml().load(reader);
 return modelMapper(data);
}

代码示例来源:origin: kubernetes-client/java

/**
 * Load an API object from a YAML string representation. Returns a concrete typed object (e.g.
 * V1Pod)
 *
 * @param content The YAML content
 * @return An instantiation of the object.
 * @throws IOException If an error occurs while reading the YAML.
 */
public static Object load(String content) throws IOException {
 return load(new StringReader(content));
}

代码示例来源:origin: kubernetes-client/java

/**
 * Load list of instantiated API objects from a YAML string representation. Returns list of
 * concrete typed objects (e.g. { V1Pod, V1SERVICE })
 *
 * <p>Order of API objects in list will be preserved according to order of objects in YAML string.
 *
 * @param content The YAML content
 * @return List of instantiated objects.
 * @throws IOException If an error occurs while reading the YAML.
 */
public static List<Object> loadAll(String content) throws IOException {
 return loadAll(new StringReader(content));
}

代码示例来源:origin: io.kubernetes/client-java

private static void initModelMap() throws IOException {
 initApiGroupMap();
 initApiVersionList();
 ClassPath cp = ClassPath.from(Yaml.class.getClassLoader());
 Set<ClassPath.ClassInfo> allClasses = cp.getTopLevelClasses("io.kubernetes.client.models");
 for (ClassPath.ClassInfo clazz : allClasses) {
  String modelName = "";
  Pair<String, String> nameParts = getApiGroup(clazz.getSimpleName());
  modelName += nameParts.getLeft() == null ? "" : nameParts.getLeft() + "/";
  nameParts = getApiVersion(nameParts.getRight());
  modelName += nameParts.getLeft() == null ? "" : nameParts.getLeft() + "/";
  modelName += nameParts.getRight();
  classes.put(modelName, clazz.load());
 }
}

代码示例来源:origin: kubernetes-client/java

/**
 * Takes an API object and returns a YAML String representing that object.
 *
 * @param object The API object to dump.
 * @return A YAML String representing the API object.
 */
public static String dump(Object object) {
 return getSnakeYaml().dump(object);
}

代码示例来源:origin: kubernetes-client/java

+ classes.toString());
return loadAs(new StringReader(getSnakeYaml().dump(data)), clazz);

代码示例来源:origin: kubernetes-client/java

.endSpec()
    .build();
System.out.println(Yaml.dump(pod));
    .endSpec()
    .build();
System.out.println(Yaml.dump(svc));

代码示例来源:origin: kubernetes-client/java

private static void initModelMap() throws IOException {
 initApiGroupMap();
 initApiVersionList();
 ClassPath cp = ClassPath.from(Yaml.class.getClassLoader());
 Set<ClassPath.ClassInfo> allClasses = cp.getTopLevelClasses("io.kubernetes.client.models");
 for (ClassPath.ClassInfo clazz : allClasses) {
  String modelName = "";
  Pair<String, String> nameParts = getApiGroup(clazz.getSimpleName());
  modelName += nameParts.getLeft() == null ? "" : nameParts.getLeft() + "/";
  nameParts = getApiVersion(nameParts.getRight());
  modelName += nameParts.getLeft() == null ? "" : nameParts.getLeft() + "/";
  modelName += nameParts.getRight();
  classes.put(modelName, clazz.load());
 }
}

代码示例来源:origin: kubernetes-client/java

/**
 * Load an API object from a YAML stream. Returns a concrete typed object using the type
 * specified.
 *
 * @param reader The YAML stream
 * @param clazz The class of object to return.
 * @return An instantiation of the object.
 * @throws IOException If an error occurs while reading the YAML.
 */
public static <T> T loadAs(Reader reader, Class<T> clazz) {
 return getSnakeYaml().loadAs(reader, clazz);
}

代码示例来源:origin: io.kubernetes/client-java

+ classes.toString());
return loadAs(new StringReader(getSnakeYaml().dump(data)), clazz);

代码示例来源:origin: io.kubernetes/client-java

/**
 * Load an API object from a stream of data. Returns a concrete typed object (e.g. V1Pod)
 *
 * @param reader The stream to load.
 * @return An instantiation of the object.
 * @throws IOException If an error occurs while reading the YAML.
 */
public static Object load(Reader reader) throws IOException {
 Map<String, Object> data = getSnakeYaml().load(reader);
 return modelMapper(data);
}

代码示例来源:origin: io.kubernetes/client-java

/**
 * Takes an API object and returns a YAML String representing that object.
 *
 * @param object The API object to dump.
 * @return A YAML String representing the API object.
 */
public static String dump(Object object) {
 return getSnakeYaml().dump(object);
}

代码示例来源:origin: io.kubernetes/client-java

/**
 * Load an API object from a YAML file. Returns a concrete typed object (e.g. V1Pod)
 *
 * @param f The file to load.
 * @return An instantiation of the object.
 * @throws IOException If an error occurs while reading the YAML.
 */
public static Object load(File f) throws IOException {
 return load(new FileReader(f));
}

代码示例来源:origin: kubernetes-client/java

/**
 * Load list of instantiated API objects from a YAML file. Returns list of concrete typed objects
 * (e.g. { V1Pod, V1SERVICE })
 *
 * <p>Order of API objects in list will be preserved according to order of objects in YAML file.
 *
 * @param f The file to load.
 * @return List of instantiated of the objects.
 * @throws IOException If an error occurs while reading the YAML.
 */
public static List<Object> loadAll(File f) throws IOException {
 return loadAll(new FileReader(f));
}

代码示例来源:origin: kubernetes-client/java

/**
 * Load list of instantiated API objects from a stream of data. Returns list of concrete typed
 * objects (e.g. { V1Pod, V1SERVICE })
 *
 * <p>Order of API objects in list will be preserved according to order of objects in stream of
 * data.
 *
 * @param reader The stream to load.
 * @return List of instantiated of the objects.
 * @throws IOException If an error occurs while reading the YAML.
 */
public static List<Object> loadAll(Reader reader) throws IOException {
 Iterable<Object> iterable = getSnakeYaml().loadAll(reader);
 List<Object> list = new ArrayList<Object>();
 for (Object object : iterable) {
  if (object != null) {
   try {
    list.add(modelMapper((Map<String, Object>) object));
   } catch (ClassCastException ex) {
    logger.error("Unexpected exception while casting: " + ex);
   }
  }
 }
 return list;
}

代码示例来源:origin: io.kubernetes/client-java

/**
 * Takes an API object and writes a YAML string representing that object to the writer.
 *
 * @param object The API object to dump
 * @param writer The writer to write the YAML to.
 */
public static void dump(Object object, Writer writer) {
 getSnakeYaml().dump(object, writer);
}

代码示例来源:origin: kubernetes-client/java

/**
 * Load an API object from a YAML file. Returns a concrete typed object (e.g. V1Pod)
 *
 * @param f The file to load.
 * @return An instantiation of the object.
 * @throws IOException If an error occurs while reading the YAML.
 */
public static Object load(File f) throws IOException {
 return load(new FileReader(f));
}

代码示例来源:origin: io.kubernetes/client-java

/**
 * Load list of instantiated API objects from a YAML string representation. Returns list of
 * concrete typed objects (e.g. { V1Pod, V1SERVICE })
 *
 * <p>Order of API objects in list will be preserved according to order of objects in YAML string.
 *
 * @param content The YAML content
 * @return List of instantiated objects.
 * @throws IOException If an error occurs while reading the YAML.
 */
public static List<Object> loadAll(String content) throws IOException {
 return loadAll(new StringReader(content));
}

代码示例来源:origin: io.kubernetes/client-java

/**
 * Load list of instantiated API objects from a stream of data. Returns list of concrete typed
 * objects (e.g. { V1Pod, V1SERVICE })
 *
 * <p>Order of API objects in list will be preserved according to order of objects in stream of
 * data.
 *
 * @param reader The stream to load.
 * @return List of instantiated of the objects.
 * @throws IOException If an error occurs while reading the YAML.
 */
public static List<Object> loadAll(Reader reader) throws IOException {
 Iterable<Object> iterable = getSnakeYaml().loadAll(reader);
 List<Object> list = new ArrayList<Object>();
 for (Object object : iterable) {
  if (object != null) {
   try {
    list.add(modelMapper((Map<String, Object>) object));
   } catch (ClassCastException ex) {
    logger.error("Unexpected exception while casting: " + ex);
   }
  }
 }
 return list;
}

代码示例来源:origin: kubernetes-client/java

/**
 * Takes an API object and writes a YAML string representing that object to the writer.
 *
 * @param object The API object to dump
 * @param writer The writer to write the YAML to.
 */
public static void dump(Object object, Writer writer) {
 getSnakeYaml().dump(object, writer);
}

相关文章