use of kong.unirest.JsonNode in project zeppelin by apache.
the class ZeppelinClient method submitParagraph.
/**
* Submit paragraph to execute with provided parameters and sessionId. Return at once the submission is completed.
* You need to query {@link ParagraphResult} by yourself afterwards until paragraph execution is completed.
*
* @param noteId
* @param paragraphId
* @param sessionId
* @param parameters
* @return
* @throws Exception
*/
public ParagraphResult submitParagraph(String noteId, String paragraphId, String sessionId, Map<String, String> parameters) throws Exception {
JSONObject bodyObject = new JSONObject();
bodyObject.put("params", parameters);
HttpResponse<JsonNode> response = Unirest.post("/notebook/job/{noteId}/{paragraphId}").routeParam("noteId", noteId).routeParam("paragraphId", paragraphId).queryString("sessionId", sessionId).body(bodyObject.toString()).asJson();
checkResponse(response);
JsonNode jsonNode = response.getBody();
checkJsonNodeStatus(jsonNode);
return queryParagraphResult(noteId, paragraphId);
}
use of kong.unirest.JsonNode in project zeppelin by apache.
the class ZeppelinClient method deleteNote.
/**
* Delete note with provided noteId.
*
* @param noteId
* @throws Exception
*/
public void deleteNote(String noteId) throws Exception {
HttpResponse<JsonNode> response = Unirest.delete("/notebook/{noteId}").routeParam("noteId", noteId).asJson();
checkResponse(response);
JsonNode jsonNode = response.getBody();
checkJsonNodeStatus(jsonNode);
}
use of kong.unirest.JsonNode in project zeppelin by apache.
the class ZeppelinClient method cancelParagraph.
/**
* Cancel a running paragraph.
*
* @param noteId
* @param paragraphId
* @throws Exception
*/
public void cancelParagraph(String noteId, String paragraphId) throws Exception {
HttpResponse<JsonNode> response = Unirest.delete("/notebook/job/{noteId}/{paragraphId}").routeParam("noteId", noteId).routeParam("paragraphId", paragraphId).asJson();
checkResponse(response);
JsonNode jsonNode = response.getBody();
checkJsonNodeStatus(jsonNode);
}
use of kong.unirest.JsonNode in project zeppelin by apache.
the class ZeppelinClient method stopSession.
/**
* Stop the session(interpreter process) in Zeppelin server.
*
* @param sessionId
* @throws Exception
*/
public void stopSession(String sessionId) throws Exception {
HttpResponse<JsonNode> response = Unirest.delete("/session/{sessionId}").routeParam("sessionId", sessionId).asJson();
checkResponse(response);
JsonNode jsonNode = response.getBody();
checkJsonNodeStatus(jsonNode);
}
use of kong.unirest.JsonNode in project zeppelin by apache.
the class ZeppelinClient method queryParagraphResult.
/**
* Query {@link ParagraphResult}
*
* @param noteId
* @param paragraphId
* @return
* @throws Exception
*/
public ParagraphResult queryParagraphResult(String noteId, String paragraphId) throws Exception {
HttpResponse<JsonNode> response = Unirest.get("/notebook/{noteId}/paragraph/{paragraphId}").routeParam("noteId", noteId).routeParam("paragraphId", paragraphId).asJson();
checkResponse(response);
JsonNode jsonNode = response.getBody();
checkJsonNodeStatus(jsonNode);
JSONObject paragraphJson = jsonNode.getObject().getJSONObject("body");
return new ParagraphResult(paragraphJson);
}
Aggregations