Search in sources :

Example 6 with JsonResponse

use of org.apache.zeppelin.server.JsonResponse in project zeppelin by apache.

the class NotebookRestApi method deleteParagraph.

/**
   * Delete paragraph REST API
   *
   * @param noteId ID of Note
   * @return JSON with status.OK
   * @throws IOException
   */
@DELETE
@Path("{noteId}/paragraph/{paragraphId}")
@ZeppelinApi
public Response deleteParagraph(@PathParam("noteId") String noteId, @PathParam("paragraphId") String paragraphId) throws IOException {
    LOG.info("delete paragraph {} {}", noteId, paragraphId);
    Note note = notebook.getNote(noteId);
    checkIfNoteIsNotNull(note);
    checkIfUserCanRead(noteId, "Insufficient privileges you cannot remove paragraph from this note");
    Paragraph p = note.getParagraph(paragraphId);
    checkIfParagraphIsNotNull(p);
    AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
    note.removeParagraph(SecurityUtils.getPrincipal(), paragraphId);
    note.persist(subject);
    notebookServer.broadcastNote(note);
    return new JsonResponse(Status.OK, "").build();
}
Also used : Note(org.apache.zeppelin.notebook.Note) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) JsonResponse(org.apache.zeppelin.server.JsonResponse) Paragraph(org.apache.zeppelin.notebook.Paragraph) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) ZeppelinApi(org.apache.zeppelin.annotation.ZeppelinApi)

Example 7 with JsonResponse

use of org.apache.zeppelin.server.JsonResponse in project zeppelin by apache.

the class CredentialRestApi method getCredentials.

/**
   * Get User Credentials list REST API
   * @param
   * @return JSON with status.OK
   * @throws IOException, IllegalArgumentException
   */
@GET
public Response getCredentials(String message) throws IOException, IllegalArgumentException {
    String user = SecurityUtils.getPrincipal();
    logger.info("getCredentials credentials for user {} ", user);
    UserCredentials uc = credentials.getUserCredentials(user);
    return new JsonResponse(Status.OK, uc).build();
}
Also used : UserCredentials(org.apache.zeppelin.user.UserCredentials) JsonResponse(org.apache.zeppelin.server.JsonResponse)

Example 8 with JsonResponse

use of org.apache.zeppelin.server.JsonResponse in project zeppelin by apache.

the class CredentialRestApi method removeCredentialEntity.

/**
   * Remove Entity of User Credential entity REST API
   * @param
   * @return JSON with status.OK
   * @throws IOException, IllegalArgumentException
   */
@DELETE
@Path("{entity}")
public Response removeCredentialEntity(@PathParam("entity") String entity) throws IOException, IllegalArgumentException {
    String user = SecurityUtils.getPrincipal();
    logger.info("removeCredentialEntity for user {} entity {}", user, entity);
    if (credentials.removeCredentialEntity(user, entity) == false) {
        return new JsonResponse(Status.NOT_FOUND).build();
    }
    return new JsonResponse(Status.OK).build();
}
Also used : JsonResponse(org.apache.zeppelin.server.JsonResponse)

Example 9 with JsonResponse

use of org.apache.zeppelin.server.JsonResponse in project zeppelin by apache.

the class HeliumRestApi method suggest.

@POST
@Path("load/{noteId}/{paragraphId}")
public Response suggest(@PathParam("noteId") String noteId, @PathParam("paragraphId") String paragraphId, String heliumPackage) {
    Note note = notebook.getNote(noteId);
    if (note == null) {
        return new JsonResponse(Response.Status.NOT_FOUND, "Note " + noteId + " not found").build();
    }
    Paragraph paragraph = note.getParagraph(paragraphId);
    if (paragraph == null) {
        return new JsonResponse(Response.Status.NOT_FOUND, "Paragraph " + paragraphId + " not found").build();
    }
    HeliumPackage pkg = gson.fromJson(heliumPackage, HeliumPackage.class);
    String appId = helium.getApplicationFactory().loadAndRun(pkg, paragraph);
    return new JsonResponse(Response.Status.OK, "", appId).build();
}
Also used : Note(org.apache.zeppelin.notebook.Note) HeliumPackage(org.apache.zeppelin.helium.HeliumPackage) JsonResponse(org.apache.zeppelin.server.JsonResponse) Paragraph(org.apache.zeppelin.notebook.Paragraph)

Example 10 with JsonResponse

use of org.apache.zeppelin.server.JsonResponse in project zeppelin by apache.

the class ConfigurationsRestApi method getAll.

@GET
@Path("all")
@ZeppelinApi
public Response getAll() {
    ZeppelinConfiguration conf = notebook.getConf();
    Map<String, String> configurations = conf.dumpConfigurations(conf, new ZeppelinConfiguration.ConfigurationKeyPredicate() {

        @Override
        public boolean apply(String key) {
            return !key.contains("password") && !key.equals(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_AZURE_CONNECTION_STRING.getVarName());
        }
    });
    return new JsonResponse(Status.OK, "", configurations).build();
}
Also used : ZeppelinConfiguration(org.apache.zeppelin.conf.ZeppelinConfiguration) JsonResponse(org.apache.zeppelin.server.JsonResponse) Path(javax.ws.rs.Path) ZeppelinApi(org.apache.zeppelin.annotation.ZeppelinApi) GET(javax.ws.rs.GET)

Aggregations

JsonResponse (org.apache.zeppelin.server.JsonResponse)21 ZeppelinApi (org.apache.zeppelin.annotation.ZeppelinApi)15 Path (javax.ws.rs.Path)13 POST (javax.ws.rs.POST)6 IOException (java.io.IOException)5 Note (org.apache.zeppelin.notebook.Note)5 PUT (javax.ws.rs.PUT)4 InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)4 GET (javax.ws.rs.GET)3 ZeppelinConfiguration (org.apache.zeppelin.conf.ZeppelinConfiguration)3 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)3 Paragraph (org.apache.zeppelin.notebook.Paragraph)3 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)3 UserCredentials (org.apache.zeppelin.user.UserCredentials)3 DELETE (javax.ws.rs.DELETE)2 Subject (org.apache.shiro.subject.Subject)2 JsonParseException (com.google.gson.JsonParseException)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 TypeToken (com.google.gson.reflect.TypeToken)1 HashMap (java.util.HashMap)1