use of org.jboss.tools.openshift.core.odo.URL in project jbosstools-openshift by jbosstools.
the class AbstractODOTest method triggerDebugSession.
public static void triggerDebugSession(String eclipseProjectName, String project, String application, String component, String urlSuffix) throws IOException, InterruptedException, ExecutionException {
String path = ResourcesPlugin.getWorkspace().getRoot().getProject(eclipseProjectName).getLocation().toOSString();
List<URL> urls = OdoCliFactory.getInstance().getOdo().get().listURLs(project, application, path, component);
java.net.URL url = new java.net.URL("http://" + urls.get(0).getHost() + urlSuffix);
new Thread(new Runnable() {
public void run() {
try {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.connect();
connection.getResponseCode();
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
use of org.jboss.tools.openshift.core.odo.URL in project jbosstools-openshift by jbosstools.
the class OdoCli method parseURLs.
private static List<URL> parseURLs(String json) {
List<URL> result = new ArrayList<>();
try {
JsonNode root = JSON_MAPPER.readTree(json);
JsonNode items = root.get("items");
if (items != null) {
items.forEach(item -> {
// odo incorrecly reports urls created with the web ui without names
if (item.get("metadata").has("name")) {
result.add(URL.of(item.get("metadata").get("name").asText(), item.get("spec").has("protocol") ? item.get("spec").get("protocol").asText() : "", item.get("spec").has("host") ? item.get("spec").get("host").asText() : "", item.get("spec").has("port") ? item.get("spec").get("port").asText() : "0", item.get("status").get("state").asText(), item.get("spec").get("secure").asBoolean()));
}
});
}
} catch (IOException e) {
}
return result;
}
use of org.jboss.tools.openshift.core.odo.URL in project jbosstools-openshift by jbosstools.
the class OdoCli method loadSwagger.
private void loadSwagger() {
try {
Request req = new Request.Builder().get().url(new java.net.URL(client.getMasterUrl(), "/openapi/v2")).build();
Response response = client.adapt(OkHttpClient.class).newCall(req).execute();
if (response.isSuccessful()) {
swagger = new JSonParser(new ObjectMapper().readTree(response.body().charStream()));
}
} catch (IOException e) {
OpenShiftUIActivator.log(IStatus.ERROR, e.getLocalizedMessage(), e);
}
}
Aggregations