Search in sources :

Example 56 with GET

use of javax.ws.rs.GET in project zeppelin by apache.

the class SecurityRestApi method ticket.

/**
   * Get ticket
   * Returns username & ticket
   * for anonymous access, username is always anonymous.
   * After getting this ticket, access through websockets become safe
   *
   * @return 200 response
   */
@GET
@Path("ticket")
@ZeppelinApi
public Response ticket() {
    ZeppelinConfiguration conf = ZeppelinConfiguration.create();
    String principal = SecurityUtils.getPrincipal();
    HashSet<String> roles = SecurityUtils.getRoles();
    JsonResponse response;
    // ticket set to anonymous for anonymous user. Simplify testing.
    String ticket;
    if ("anonymous".equals(principal))
        ticket = "anonymous";
    else
        ticket = TicketContainer.instance.getTicket(principal);
    Map<String, String> data = new HashMap<>();
    data.put("principal", principal);
    data.put("roles", roles.toString());
    data.put("ticket", ticket);
    response = new JsonResponse(Response.Status.OK, "", data);
    LOG.warn(response.toString());
    return response.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 57 with GET

use of javax.ws.rs.GET in project zeppelin by apache.

the class NotebookRestApi method getJobListforNote.

/**
   * Get note jobs for job manager
   *
   * @return JSON with status.OK
   * @throws IOException, IllegalArgumentException
   */
@GET
@Path("jobmanager/")
@ZeppelinApi
public Response getJobListforNote() throws IOException, IllegalArgumentException {
    LOG.info("Get note jobs for job manager");
    AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
    List<Map<String, Object>> noteJobs = notebook.getJobListByUnixTime(false, 0, subject);
    Map<String, Object> response = new HashMap<>();
    response.put("lastResponseUnixTime", System.currentTimeMillis());
    response.put("jobs", noteJobs);
    return new JsonResponse<>(Status.OK, response).build();
}
Also used : HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) Path(javax.ws.rs.Path) ZeppelinApi(org.apache.zeppelin.annotation.ZeppelinApi) GET(javax.ws.rs.GET)

Example 58 with GET

use of javax.ws.rs.GET in project zeppelin by apache.

the class NotebookRestApi method getNoteList.

@GET
@Path("/")
@ZeppelinApi
public Response getNoteList() throws IOException {
    AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
    HashSet<String> userAndRoles = SecurityUtils.getRoles();
    userAndRoles.add(subject.getUser());
    List<Map<String, String>> notesInfo = notebookServer.generateNotesInfo(false, subject, userAndRoles);
    return new JsonResponse<>(Status.OK, "", notesInfo).build();
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) Path(javax.ws.rs.Path) ZeppelinApi(org.apache.zeppelin.annotation.ZeppelinApi) GET(javax.ws.rs.GET)

Example 59 with GET

use of javax.ws.rs.GET in project zeppelin by apache.

the class NotebookRestApi method getNoteJobStatus.

/**
   * Get note job status REST API
   *
   * @param noteId ID of Note
   * @return JSON with status.OK
   * @throws IOException, IllegalArgumentException
   */
@GET
@Path("job/{noteId}")
@ZeppelinApi
public Response getNoteJobStatus(@PathParam("noteId") String noteId) throws IOException, IllegalArgumentException {
    LOG.info("get note job status.");
    Note note = notebook.getNote(noteId);
    checkIfNoteIsNotNull(note);
    checkIfUserCanRead(noteId, "Insufficient privileges you cannot get job status");
    return new JsonResponse<>(Status.OK, null, note.generateParagraphsInfo()).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 60 with GET

use of javax.ws.rs.GET in project zeppelin by apache.

the class NotebookRestApi method getNote.

@GET
@Path("{noteId}")
@ZeppelinApi
public Response getNote(@PathParam("noteId") String noteId) throws IOException {
    Note note = notebook.getNote(noteId);
    checkIfNoteIsNotNull(note);
    checkIfUserCanRead(noteId, "Insufficient privileges you cannot get this note");
    return new JsonResponse<>(Status.OK, "", note).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)

Aggregations

GET (javax.ws.rs.GET)1140 Path (javax.ws.rs.Path)902 Produces (javax.ws.rs.Produces)734 ApiOperation (io.swagger.annotations.ApiOperation)230 ApiResponses (io.swagger.annotations.ApiResponses)163 IOException (java.io.IOException)139 Response (javax.ws.rs.core.Response)116 WebApplicationException (javax.ws.rs.WebApplicationException)113 Timed (com.codahale.metrics.annotation.Timed)103 ArrayList (java.util.ArrayList)100 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)91 List (java.util.List)83 Map (java.util.Map)80 HashMap (java.util.HashMap)78 URI (java.net.URI)70 TimedResource (org.killbill.commons.metrics.TimedResource)58 TenantContext (org.killbill.billing.util.callcontext.TenantContext)57 ApiResponse (io.swagger.annotations.ApiResponse)52 NotFoundException (org.apache.hadoop.yarn.webapp.NotFoundException)39 Consumes (javax.ws.rs.Consumes)36