Search in sources :

Example 11 with JsonNode

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);
}
Also used : JSONObject(kong.unirest.json.JSONObject) JsonNode(kong.unirest.JsonNode)

Example 12 with JsonNode

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);
}
Also used : JsonNode(kong.unirest.JsonNode)

Example 13 with 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);
}
Also used : JsonNode(kong.unirest.JsonNode)

Example 14 with 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);
}
Also used : JsonNode(kong.unirest.JsonNode)

Example 15 with 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);
}
Also used : JSONObject(kong.unirest.json.JSONObject) JsonNode(kong.unirest.JsonNode)

Aggregations

JsonNode (kong.unirest.JsonNode)20 JSONObject (kong.unirest.json.JSONObject)13 ArrayList (java.util.ArrayList)2 JSONArray (kong.unirest.json.JSONArray)2 GetRequest (kong.unirest.GetRequest)1 SessionInfo (org.apache.zeppelin.common.SessionInfo)1