Search in sources :

Example 16 with ZeppelinApi

use of org.apache.zeppelin.annotation.ZeppelinApi in project zeppelin by apache.

the class NotebookRestApi method getCronJob.

/**
   * Get cron job REST API
   *
   * @param noteId ID of Note
   * @return JSON with status.OK
   * @throws IOException, IllegalArgumentException
   */
@GET
@Path("cron/{noteId}")
@ZeppelinApi
public Response getCronJob(@PathParam("noteId") String noteId) throws IOException, IllegalArgumentException {
    LOG.info("Get cron job note {}", noteId);
    Note note = notebook.getNote(noteId);
    checkIfNoteIsNotNull(note);
    checkIfUserCanRead(noteId, "Insufficient privileges you cannot get cron information");
    return new JsonResponse<>(Status.OK, note.getConfig().get("cron")).build();
}
Also used : Note(org.apache.zeppelin.notebook.Note) Path(javax.ws.rs.Path) ZeppelinApi(org.apache.zeppelin.annotation.ZeppelinApi) GET(javax.ws.rs.GET)

Example 17 with ZeppelinApi

use of org.apache.zeppelin.annotation.ZeppelinApi 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 18 with ZeppelinApi

use of org.apache.zeppelin.annotation.ZeppelinApi 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)

Example 19 with ZeppelinApi

use of org.apache.zeppelin.annotation.ZeppelinApi in project zeppelin by apache.

the class ConfigurationsRestApi method getByPrefix.

@GET
@Path("prefix/{prefix}")
@ZeppelinApi
public Response getByPrefix(@PathParam("prefix") final String prefix) {
    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()) && key.startsWith(prefix);
        }
    });
    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)

Example 20 with ZeppelinApi

use of org.apache.zeppelin.annotation.ZeppelinApi in project zeppelin by apache.

the class InterpreterRestApi method addRepository.

/**
   * Add new repository
   *
   * @param message Repository
   */
@POST
@Path("repository")
@ZeppelinApi
public Response addRepository(String message) {
    try {
        Repository request = gson.fromJson(message, Repository.class);
        interpreterSettingManager.addRepository(request.getId(), request.getUrl(), request.isSnapshot(), request.getAuthentication(), request.getProxy());
        logger.info("New repository {} added", request.getId());
    } catch (Exception e) {
        logger.error("Exception in InterpreterRestApi while adding repository ", e);
        return new JsonResponse<>(Status.INTERNAL_SERVER_ERROR, e.getMessage(), ExceptionUtils.getStackTrace(e)).build();
    }
    return new JsonResponse(Status.OK).build();
}
Also used : Repository(org.apache.zeppelin.dep.Repository) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) IOException(java.io.IOException) JsonResponse(org.apache.zeppelin.server.JsonResponse) Path(javax.ws.rs.Path) ZeppelinApi(org.apache.zeppelin.annotation.ZeppelinApi) POST(javax.ws.rs.POST)

Aggregations

ZeppelinApi (org.apache.zeppelin.annotation.ZeppelinApi)45 Path (javax.ws.rs.Path)35 Note (org.apache.zeppelin.notebook.Note)22 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)16 JsonResponse (org.apache.zeppelin.server.JsonResponse)15 GET (javax.ws.rs.GET)13 POST (javax.ws.rs.POST)13 Paragraph (org.apache.zeppelin.notebook.Paragraph)11 DELETE (javax.ws.rs.DELETE)6 PUT (javax.ws.rs.PUT)6 InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 ResourcePool (org.apache.zeppelin.resource.ResourcePool)4 Map (java.util.Map)3 ZeppelinConfiguration (org.apache.zeppelin.conf.ZeppelinConfiguration)3 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)3 Properties (java.util.Properties)2 Subject (org.apache.shiro.subject.Subject)2 NotebookRepoWithSettings (org.apache.zeppelin.notebook.repo.NotebookRepoWithSettings)2