/** * Unmarshals a stream. * @param is The {@link InputStream}. * @param <T> The target type. * @return * @throws KubernetesClientException */ public static <T> T unmarshal(InputStream is) throws KubernetesClientException { return unmarshal(is, JSON_MAPPER); }
protected static <T> T unmarshal(InputStream is, final Class<T> type) throws KubernetesClientException { return Serialization.unmarshal(is, type); }
protected static <T> T unmarshal(InputStream is, TypeReference<T> type) throws KubernetesClientException { return Serialization.unmarshal(is, type); }
protected static <T> T unmarshal(InputStream is) throws KubernetesClientException { return Serialization.unmarshal(is); }
/** * Unmarshals an {@link InputStream} optionally performing placeholder substitution to the stream. * @param is The {@link InputStream}. * @param type The type. * @param parameters A {@link Map} with parameters for placeholder substitution. * @param <T> * @return * @throws KubernetesClientException */ public static <T> T unmarshal(InputStream is, final Class<T> type, Map<String, String> parameters) throws KubernetesClientException { return unmarshal(is, new TypeReference<T>() { @Override public Type getType() { return type; } }, parameters); }
/** * Unmarshals a {@link String} * @param str The {@link String}. * @param type The target type. * @param <T> * @return * @throws KubernetesClientException */ public static <T> T unmarshal(String str, final Class<T> type) throws KubernetesClientException { return unmarshal(str, type, Collections.<String, String>emptyMap()); }
/** * Unmarshals an {@link InputStream}. * @param is The {@link InputStream}. * @param type The {@link TypeReference}. * @param <T> * @return * @throws KubernetesClientException */ public static <T> T unmarshal(InputStream is, TypeReference<T> type) throws KubernetesClientException { return unmarshal(is, type, Collections.<String, String>emptyMap()); }
/** * Unmarshals a stream. * @param is The {@link InputStream}. * @param mapper The {@link ObjectMapper} to use. * @param <T> The target type. * @return * @throws KubernetesClientException */ public static <T> T unmarshal(InputStream is, ObjectMapper mapper) { return unmarshal(is, mapper, Collections.<String, String>emptyMap()); }
/** * Unmarshals an {@link InputStream}. * @param is The {@link InputStream}. * @param type The type. * @param <T> * @return * @throws KubernetesClientException */ public static <T> T unmarshal(InputStream is, final Class<T> type) throws KubernetesClientException { return unmarshal(is, type, Collections.<String, String>emptyMap()); }
private static HasMetadata toKubernetesResource(String s) { try (InputStream stream = new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8.name()))) { return Serialization.unmarshal(stream); } catch (Exception e) { return null; } } }
public static DefaultKubernetesClient fromConfig(String config) { return new DefaultKubernetesClient(Serialization.unmarshal(config, Config.class)); }
public static DefaultOpenShiftClient fromConfig(String config) { return new DefaultOpenShiftClient(Serialization.unmarshal(config, OpenShiftConfig.class)); }
public static DefaultKubernetesClient fromConfig(InputStream is) { return new DefaultKubernetesClient(Serialization.unmarshal(is, Config.class)); }
public static DefaultOpenShiftClient fromConfig(InputStream is) { return new DefaultOpenShiftClient(Serialization.unmarshal(is, OpenShiftConfig.class)); }
private static List<KubernetesResource> getKubernetesResourceList(Map<String, String> parameters, String specFile) { List<KubernetesResource> documentList = new ArrayList<>(); String[] documents = splitSpecFile(specFile); for (String document : documents) { if (validate(document)) { ByteArrayInputStream documentInputStream = new ByteArrayInputStream(document.getBytes()); Object resource = Serialization.unmarshal(documentInputStream, parameters); documentList.add((KubernetesResource) resource); } } return documentList; }
public NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl(OkHttpClient client, Config config, String namespace, String explicitNamespace, Boolean fromServer, Boolean deletingExisting, List<Visitor> visitors, Object item, InputStream inputStream, Map<String, String> parameters, long gracePeriodSeconds, Boolean cascading) { super(client, config, null, null, null, null, null); this.fallbackNamespace = namespace; this.explicitNamespace = explicitNamespace; this.fromServer = fromServer; this.deletingExisting = deletingExisting; this.visitors = visitors != null ? new ArrayList<>(visitors) : new ArrayList<Visitor>(); if (item != null) { this.item = item; } else if (inputStream != null) { this.item = Serialization.unmarshal(inputStream, parameters); } else { throw new IllegalArgumentException("Need to either specify an Object or an InputStream."); } this.inputStream = inputStream; this.cascading = cascading; this.gracePeriodSeconds = gracePeriodSeconds; this.visitors.add(new ChangeNamespace(explicitNamespace, fallbackNamespace)); }
/** * Unmarshals a {@link String} optionally performing placeholder substitution to the String. * @param str The {@link String}. * @param type The target type. * @param <T> * @return * @throws KubernetesClientException */ public static <T> T unmarshal(String str, final Class<T> type, Map<String, String> parameters) throws KubernetesClientException { try (InputStream is = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));) { return unmarshal(is, new TypeReference<T>() { @Override public Type getType() { return type; } }, parameters); } catch (IOException e) { throw KubernetesClientException.launderThrowable(e); } }
/** * Unmarshals a stream optionally performing placeholder substitution to the stream. * @param is The {@link InputStream}. * @param parameters A {@link Map} with parameters for placeholder substitution. * @param <T> The target type. * @return * @throws KubernetesClientException */ public static <T> T unmarshal(InputStream is, Map<String, String> parameters) throws KubernetesClientException { String specFile = readSpecFileFromInputStream(is); if (containsMultipleDocuments(specFile)) { return (T) getKubernetesResourceList(parameters, specFile); } return unmarshal(new ByteArrayInputStream(specFile.getBytes()), JSON_MAPPER, parameters); }
if (request.body() != null && !request.method().equalsIgnoreCase(PATCH)) { request.body().writeTo(buffer); Object object = Serialization.unmarshal(buffer.inputStream()); if (object instanceof HasMetadata) { HasMetadata h = (HasMetadata) object;
if (type != null) { try (InputStream bodyInputStream = body.byteStream()) { return Serialization.unmarshal(bodyInputStream, type, parameters);