mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Add rename method to rest api
This commit is contained in:
parent
ad880ed31d
commit
4df7c6dbae
3 changed files with 32 additions and 8 deletions
|
|
@ -45,7 +45,11 @@ import org.apache.zeppelin.notebook.Paragraph;
|
|||
import org.apache.zeppelin.rest.exception.BadRequestException;
|
||||
import org.apache.zeppelin.rest.exception.NotFoundException;
|
||||
import org.apache.zeppelin.rest.exception.ForbiddenException;
|
||||
import org.apache.zeppelin.rest.message.*;
|
||||
import org.apache.zeppelin.rest.message.CronRequest;
|
||||
import org.apache.zeppelin.rest.message.NewNoteRequest;
|
||||
import org.apache.zeppelin.rest.message.RenameNoteRequest;
|
||||
import org.apache.zeppelin.rest.message.NewParagraphRequest;
|
||||
import org.apache.zeppelin.rest.message.RunParagraphWithParametersRequest;
|
||||
import org.apache.zeppelin.search.SearchService;
|
||||
import org.apache.zeppelin.server.JsonResponse;
|
||||
import org.apache.zeppelin.socket.NotebookServer;
|
||||
|
|
@ -420,7 +424,8 @@ public class NotebookRestApi {
|
|||
@PUT
|
||||
@Path("{noteId}/rename")
|
||||
@ZeppelinApi
|
||||
public Response renameNote(@PathParam("noteId") String noteId, String message) throws IOException {
|
||||
public Response renameNote(@PathParam("noteId") String noteId,
|
||||
String message) throws IOException {
|
||||
LOG.info("rename note by JSON {}", message);
|
||||
RenameNoteRequest request = gson.fromJson(message, RenameNoteRequest.class);
|
||||
AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
|
||||
|
|
|
|||
|
|
@ -26,14 +26,15 @@ import org.apache.zeppelin.interpreter.InterpreterOption;
|
|||
* RenameNoteRequest rest api request message
|
||||
*
|
||||
*/
|
||||
|
||||
public class RenameNoteRequest {
|
||||
String name;
|
||||
String name;
|
||||
|
||||
public RenameNoteRequest (){
|
||||
public RenameNoteRequest (){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,6 +146,24 @@ public class NotebookRestApiTest extends AbstractTestRestApi {
|
|||
ZeppelinServer.notebook.removeNote(clonedNoteId, anonymous);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRenameNote() throws IOException {
|
||||
Note note = ZeppelinServer.notebook.createNote(anonymous);
|
||||
String noteId = note.getId();
|
||||
|
||||
final String newName = "testName";
|
||||
String jsonRequest = "{\"name\": " + newName + "}";
|
||||
|
||||
PutMethod put = httpPut("/notebook/" + noteId + "/rename/", jsonRequest);
|
||||
assertThat("test testRenameNote:", put, isAllowed());
|
||||
put.releaseConnection();
|
||||
|
||||
assertEquals(note.getName(), newName);
|
||||
|
||||
//cleanup
|
||||
ZeppelinServer.notebook.removeNote(noteId, anonymous);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateParagraphConfig() throws IOException {
|
||||
Note note = ZeppelinServer.notebook.createNote(anonymous);
|
||||
|
|
|
|||
Loading…
Reference in a new issue