use of dontweave.gson.Gson in project h2o-2 by h2oai.
the class WebAPI method listJobs.
/**
* Lists jobs currently running.
*/
static void listJobs() throws Exception {
HttpClient client = new HttpClient();
GetMethod get = new GetMethod(URL + "/Jobs.json");
int status = client.executeMethod(get);
if (status != 200)
throw new Exception(get.getStatusText());
Gson gson = new Gson();
JobsRes res = gson.fromJson(new InputStreamReader(get.getResponseBodyAsStream()), JobsRes.class);
System.out.println("Running jobs:");
for (Job job : res.jobs) System.out.println(job.description + " " + job.destination_key);
get.releaseConnection();
}
use of dontweave.gson.Gson in project h2o-2 by h2oai.
the class HttpTest method get.
public Get get(String uri, Class c) {
GetMethod get = new GetMethod("http://127.0.0.1:54321/" + uri);
Get res = new Get();
try {
res._status = _client.executeMethod(get);
if (res._status == 200) {
Gson gson = new Gson();
res._res = gson.fromJson(new InputStreamReader(get.getResponseBodyAsStream()), c);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
get.releaseConnection();
return res;
}
Aggregations