Search in sources :

Example 1 with NotebookRepoWithSettings

use of org.apache.zeppelin.notebook.repo.NotebookRepoWithSettings in project zeppelin by apache.

the class NotebookRepoRestApi method updateRepoSetting.

/**
   * Update a specific note repo.
   *
   * @param message
   * @param settingId
   * @return
   */
@PUT
@ZeppelinApi
public Response updateRepoSetting(String payload) {
    if (StringUtils.isBlank(payload)) {
        return new JsonResponse<>(Status.NOT_FOUND, "", Collections.emptyMap()).build();
    }
    AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
    NotebookRepoSettingsRequest newSettings = NotebookRepoSettingsRequest.EMPTY;
    try {
        newSettings = gson.fromJson(payload, NotebookRepoSettingsRequest.class);
    } catch (JsonSyntaxException e) {
        LOG.error("Cannot update notebook repo settings", e);
        return new JsonResponse<>(Status.NOT_ACCEPTABLE, "", ImmutableMap.of("error", "Invalid payload structure")).build();
    }
    if (NotebookRepoSettingsRequest.isEmpty(newSettings)) {
        LOG.error("Invalid property");
        return new JsonResponse<>(Status.NOT_ACCEPTABLE, "", ImmutableMap.of("error", "Invalid payload")).build();
    }
    LOG.info("User {} is going to change repo setting", subject.getUser());
    NotebookRepoWithSettings updatedSettings = noteRepos.updateNotebookRepo(newSettings.name, newSettings.settings, subject);
    if (!updatedSettings.isEmpty()) {
        LOG.info("Broadcasting note list to user {}", subject.getUser());
        notebookWsServer.broadcastReloadedNoteList(subject, null);
    }
    return new JsonResponse<>(Status.OK, "", updatedSettings).build();
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) NotebookRepoWithSettings(org.apache.zeppelin.notebook.repo.NotebookRepoWithSettings) NotebookRepoSettingsRequest(org.apache.zeppelin.rest.message.NotebookRepoSettingsRequest) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) JsonResponse(org.apache.zeppelin.server.JsonResponse) ZeppelinApi(org.apache.zeppelin.annotation.ZeppelinApi) PUT(javax.ws.rs.PUT)

Example 2 with NotebookRepoWithSettings

use of org.apache.zeppelin.notebook.repo.NotebookRepoWithSettings in project zeppelin by apache.

the class NotebookRepoRestApi method listRepoSettings.

/**
   * List all notebook repository
   */
@GET
@ZeppelinApi
public Response listRepoSettings() {
    AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
    LOG.info("Getting list of NoteRepo with Settings for user {}", subject.getUser());
    List<NotebookRepoWithSettings> settings = noteRepos.getNotebookRepos(subject);
    return new JsonResponse<>(Status.OK, "", settings).build();
}
Also used : NotebookRepoWithSettings(org.apache.zeppelin.notebook.repo.NotebookRepoWithSettings) AuthenticationInfo(org.apache.zeppelin.user.AuthenticationInfo) ZeppelinApi(org.apache.zeppelin.annotation.ZeppelinApi) GET(javax.ws.rs.GET)

Aggregations

ZeppelinApi (org.apache.zeppelin.annotation.ZeppelinApi)2 NotebookRepoWithSettings (org.apache.zeppelin.notebook.repo.NotebookRepoWithSettings)2 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 GET (javax.ws.rs.GET)1 PUT (javax.ws.rs.PUT)1 NotebookRepoSettingsRequest (org.apache.zeppelin.rest.message.NotebookRepoSettingsRequest)1 JsonResponse (org.apache.zeppelin.server.JsonResponse)1