Search in sources :

Example 1 with NewInterpreterSettingRequest

use of org.apache.zeppelin.rest.message.NewInterpreterSettingRequest in project zeppelin by apache.

the class InterpreterRestApi method newSettings.

/**
   * Add new interpreter setting
   *
   * @param message NewInterpreterSettingRequest
   */
@POST
@Path("setting")
@ZeppelinApi
public Response newSettings(String message) {
    try {
        NewInterpreterSettingRequest request = gson.fromJson(message, NewInterpreterSettingRequest.class);
        if (request == null) {
            return new JsonResponse<>(Status.BAD_REQUEST).build();
        }
        Properties p = new Properties();
        p.putAll(request.getProperties());
        InterpreterSetting interpreterSetting = interpreterSettingManager.createNewSetting(request.getName(), request.getGroup(), request.getDependencies(), request.getOption(), p);
        logger.info("new setting created with {}", interpreterSetting.getId());
        return new JsonResponse<>(Status.OK, "", interpreterSetting).build();
    } catch (InterpreterException | IOException e) {
        logger.error("Exception in InterpreterRestApi while creating ", e);
        return new JsonResponse<>(Status.NOT_FOUND, e.getMessage(), ExceptionUtils.getStackTrace(e)).build();
    }
}
Also used : InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) NewInterpreterSettingRequest(org.apache.zeppelin.rest.message.NewInterpreterSettingRequest) IOException(java.io.IOException) Properties(java.util.Properties) JsonResponse(org.apache.zeppelin.server.JsonResponse) Path(javax.ws.rs.Path) ZeppelinApi(org.apache.zeppelin.annotation.ZeppelinApi) POST(javax.ws.rs.POST)

Aggregations

IOException (java.io.IOException)1 Properties (java.util.Properties)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 ZeppelinApi (org.apache.zeppelin.annotation.ZeppelinApi)1 InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)1 InterpreterSetting (org.apache.zeppelin.interpreter.InterpreterSetting)1 NewInterpreterSettingRequest (org.apache.zeppelin.rest.message.NewInterpreterSettingRequest)1 JsonResponse (org.apache.zeppelin.server.JsonResponse)1