Search in sources :

Example 11 with JSONObject

use of kong.unirest.json.JSONObject in project zeppelin by apache.

the class ZeppelinClient method addParagraph.

/**
 * Add paragraph to note with provided title and text.
 *
 * @param noteId
 * @param title
 * @param text
 * @return
 * @throws Exception
 */
public String addParagraph(String noteId, String title, String text) throws Exception {
    JSONObject bodyObject = new JSONObject();
    bodyObject.put("title", title);
    bodyObject.put("text", text);
    HttpResponse<JsonNode> response = Unirest.post("/notebook/{noteId}/paragraph").routeParam("noteId", noteId).body(bodyObject.toString()).asJson();
    checkResponse(response);
    JsonNode jsonNode = response.getBody();
    checkJsonNodeStatus(jsonNode);
    return jsonNode.getObject().getString("body");
}
Also used : JSONObject(kong.unirest.json.JSONObject) JsonNode(kong.unirest.JsonNode)

Example 12 with JSONObject

use of kong.unirest.json.JSONObject in project zeppelin by apache.

the class ZeppelinClient method stopInterpreter.

/**
 * This is equal to the restart operation in note page.
 *
 * @param noteId
 * @param interpreter
 */
public void stopInterpreter(String noteId, String interpreter) throws Exception {
    JSONObject bodyObject = new JSONObject();
    bodyObject.put("noteId", noteId);
    HttpResponse<JsonNode> response = Unirest.put("/interpreter/setting/restart/{interpreter}").routeParam("interpreter", interpreter).body(bodyObject.toString()).asJson();
    checkResponse(response);
    JsonNode jsonNode = response.getBody();
    checkJsonNodeStatus(jsonNode);
}
Also used : JSONObject(kong.unirest.json.JSONObject) JsonNode(kong.unirest.JsonNode)

Example 13 with JSONObject

use of kong.unirest.json.JSONObject in project zeppelin by apache.

the class ZeppelinClient method renameNote.

public void renameNote(String noteId, String newNotePath) throws Exception {
    JSONObject bodyObject = new JSONObject();
    bodyObject.put("name", newNotePath);
    HttpResponse<JsonNode> response = Unirest.put("/notebook/{noteId}/rename").routeParam("noteId", noteId).body(bodyObject.toString()).asJson();
    checkResponse(response);
    JsonNode jsonNode = response.getBody();
    checkJsonNodeStatus(jsonNode);
}
Also used : JSONObject(kong.unirest.json.JSONObject) JsonNode(kong.unirest.JsonNode)

Aggregations

JsonNode (kong.unirest.JsonNode)13 JSONObject (kong.unirest.json.JSONObject)13 ArrayList (java.util.ArrayList)1 JSONArray (kong.unirest.json.JSONArray)1