use of kong.unirest.GetRequest in project zeppelin by apache.
the class ZeppelinClient method listSessions.
/**
* List all the sessions for the provided interpreter.
*
* @param interpreter
* @return
* @throws Exception
*/
public List<SessionInfo> listSessions(String interpreter) throws Exception {
GetRequest getRequest = Unirest.get("/session");
if (interpreter != null) {
getRequest.queryString("interpreter", interpreter);
}
HttpResponse<JsonNode> response = getRequest.asJson();
checkResponse(response);
JsonNode jsonNode = response.getBody();
checkJsonNodeStatus(jsonNode);
JSONArray sessionJsonArray = jsonNode.getObject().getJSONArray("body");
List<SessionInfo> sessionInfos = new ArrayList<>();
for (int i = 0; i < sessionJsonArray.length(); ++i) {
sessionInfos.add(createSessionInfoFromJson(sessionJsonArray.getJSONObject(i)));
}
return sessionInfos;
}
Aggregations