mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Add releaseResource param to cron api methods
This commit is contained in:
parent
6beb1bb3c3
commit
fdaaa166b9
3 changed files with 28 additions and 7 deletions
|
|
@ -1180,7 +1180,8 @@ Notebooks REST API supports the following operations: List, Create, Get, Delete,
|
|||
<col width="200">
|
||||
<tr>
|
||||
<td>Description</td>
|
||||
<td>This ```POST``` method adds cron job by the given note id.
|
||||
<td>This ```POST``` method adds cron job by the given note id.
|
||||
Default value of ```releaseResource``` is ```false```.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -1197,7 +1198,7 @@ Notebooks REST API supports the following operations: List, Create, Get, Delete,
|
|||
</tr>
|
||||
<tr>
|
||||
<td> sample JSON input </td>
|
||||
<td><pre>{"cron": "cron expression of note"}</pre></td>
|
||||
<td><pre>{"cron": "cron expression of note", "releaseResource": "false"}</pre></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> sample JSON response </td>
|
||||
|
|
@ -1241,7 +1242,7 @@ Notebooks REST API supports the following operations: List, Create, Get, Delete,
|
|||
<tr>
|
||||
<td>Description</td>
|
||||
<td>This ```GET``` method gets cron job expression of given note id.
|
||||
The body field of the returned JSON contains the cron expression.
|
||||
The body field of the returned JSON contains the cron expression and ```releaseResource``` flag.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -1258,7 +1259,14 @@ Notebooks REST API supports the following operations: List, Create, Get, Delete,
|
|||
</tr>
|
||||
<tr>
|
||||
<td> sample JSON response </td>
|
||||
<td><pre>{"status": "OK", "body": "* * * * * ?"}</pre></td>
|
||||
<td><pre>
|
||||
{
|
||||
"status": "OK",
|
||||
"body": {
|
||||
"cron": "0 0/1 * * * ?",
|
||||
"releaseResource": true
|
||||
}
|
||||
}</pre></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
|
|||
|
|
@ -878,6 +878,7 @@ public class NotebookRestApi {
|
|||
|
||||
Map<String, Object> config = note.getConfig();
|
||||
config.put("cron", request.getCronString());
|
||||
config.put("releaseresource", request.getReleaseResource());
|
||||
note.setConfig(config);
|
||||
notebook.refreshCron(note.getId());
|
||||
|
||||
|
|
@ -906,7 +907,8 @@ public class NotebookRestApi {
|
|||
checkIfNoteSupportsCron(note);
|
||||
|
||||
Map<String, Object> config = note.getConfig();
|
||||
config.put("cron", null);
|
||||
config.remove("cron");
|
||||
config.remove("releaseresource");
|
||||
note.setConfig(config);
|
||||
notebook.refreshCron(note.getId());
|
||||
|
||||
|
|
@ -932,8 +934,11 @@ public class NotebookRestApi {
|
|||
checkIfNoteIsNotNull(note);
|
||||
checkIfUserCanRead(noteId, "Insufficient privileges you cannot get cron information");
|
||||
checkIfNoteSupportsCron(note);
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("cron", note.getConfig().get("cron"));
|
||||
response.put("releaseResource", note.getConfig().get("releaseresource"));
|
||||
|
||||
return new JsonResponse<>(Status.OK, note.getConfig().get("cron")).build();
|
||||
return new JsonResponse<>(Status.OK, response).build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ import org.apache.zeppelin.common.JsonSerializable;
|
|||
public class CronRequest implements JsonSerializable {
|
||||
private static final Gson gson = new Gson();
|
||||
|
||||
String cron;
|
||||
private String cron;
|
||||
private Boolean releaseResource;
|
||||
|
||||
public CronRequest (){
|
||||
}
|
||||
|
|
@ -35,6 +36,13 @@ public class CronRequest implements JsonSerializable {
|
|||
return cron;
|
||||
}
|
||||
|
||||
public Boolean getReleaseResource() {
|
||||
if (releaseResource == null) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
return releaseResource;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return gson.toJson(this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue