Search in sources :

Example 16 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 17 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 18 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 19 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 20 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)3467 Path (javax.ws.rs.Path)2921 Produces (javax.ws.rs.Produces)2414 ApiOperation (io.swagger.annotations.ApiOperation)709 ApiResponses (io.swagger.annotations.ApiResponses)558 ArrayList (java.util.ArrayList)468 IOException (java.io.IOException)344 Response (javax.ws.rs.core.Response)342 WebApplicationException (javax.ws.rs.WebApplicationException)335 Consumes (javax.ws.rs.Consumes)267 HashMap (java.util.HashMap)242 List (java.util.List)231 URI (java.net.URI)202 Map (java.util.Map)202 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)196 Timed (com.codahale.metrics.annotation.Timed)195 TimedResource (org.killbill.commons.metrics.TimedResource)121 TenantContext (org.killbill.billing.util.callcontext.TenantContext)117 MediaType (javax.ws.rs.core.MediaType)113 ApiResponse (io.swagger.annotations.ApiResponse)111