def put(self, request): notebookId = request.data["notebookId"] if "crontabScheduleId" in request.data: crontabScheduleId = request.data["crontabScheduleId"] res = NotebookJobServices.updateNotebookJob( notebookId=notebookId, crontabScheduleId=crontabScheduleId) elif "enabled" in request.data: enabled = request.data["enabled"] res = NotebookJobServices.toggleNotebookJob(notebookId=notebookId, enabled=enabled) return Response(res.json())
def getNotebookObject(request: HttpRequest, notebookObjId: int) -> Response: """ Method to get details of Notebook Object with given id :param notebookObjId: ID of the notebook object """ if request.method == "GET": res = NotebookJobServices.getNotebookObject(notebookObjId) return Response(res.json()) if request.method == "PUT": res = NotebookJobServices.editNotebook(notebookObjId, request.data) return Response(res.json())
def schedule(request: HttpRequest, scheduleId: int) -> Response: """ Method for crud operations on a single connection :param request: HttpRequest :param connection_id: Connection Id """ if request.method == "GET": res = NotebookJobServices.getSingleSchedule(scheduleId) return Response(res.json()) if request.method == "DELETE": res = NotebookJobServices.deleteSchedule(scheduleId) return Response(res.json())
def stopWorkflow(workflowId: int): """ Stops given workflow """ res = ApiResponse(message="Error in stopping workflow") notebookIds = list( NotebookJob.objects.filter(workflow_id=workflowId).values_list( "notebookId", flat=True)) workflowRuns = WorkflowRun.objects.filter( workflow_id=workflowId).order_by("-startTimestamp") if workflowRuns.count(): workflowRun = workflowRuns[0] workflowRun.status = STATUS_ABORTED workflowRun.save() notebookIds = Workflow.objects.get( id=workflowId).notebookjob_set.all().values_list("notebookId", flat=True) responses = [ NotebookJobServices.stopNotebookJob(notebookId) for notebookId in notebookIds ] res.update(True, "Stopped workflow successfully") return res
def get(self, request, offset: int): limit = request.GET.get('limit', 25) searchQuery = request.GET.get('searchText', '') sorter = json.loads(request.GET.get('sorter', '{}')) _filter = json.loads(request.GET.get('filter', '{}')) res = NotebookJobServices.getNotebooks(offset, limit, searchQuery, sorter, _filter) return Response(res.json())
def post(self, request): name = request.data["name"] cron = request.data["crontab"] timezone = request.data["timezone"] res = NotebookJobServices.addSchedule(cron=cron, timezone=timezone, name=name) return Response(res.json())
def put(self, request): id = request.data["id"] name = request.data["name"] cron = request.data["crontab"] timezone = request.data["timezone"] res = NotebookJobServices.updateSchedule(id=id, cron=cron, timezone=timezone, name=name) return Response(res.json())
def post(self, request, notebookId): res = NotebookJobServices.runNotebookJob(notebookId) return Response(res.json())
def get(self, request): res = NotebookJobServices.getSchedules() return Response(res.json())
def delete(self, request, notebookId=None): res = NotebookJobServices.deleteNotebookJob(notebookId=notebookId) return Response(res.json())
def get(self, request, notebookId, notebookName): res = NotebookJobServices.unarchiveNotebook(notebookId, notebookName) return Response(res.json())
def post(self, request): notebookId = request.data["notebookId"] crontabScheduleId = request.data["crontabScheduleId"] res = NotebookJobServices.addNotebookJob( notebookId=notebookId, crontabScheduleId=crontabScheduleId) return Response(res.json())
def get(self, request, notebookId=None): offset = int(request.GET.get("offset", 0)) res = NotebookJobServices.getNotebookJobDetails(notebookId=notebookId, runStatusOffset=offset) return Response(res.json())
def post(self, request): res = NotebookJobServices.addNotebook(request.data) return Response(res.json())
def get(self, request, offset: int): res = NotebookJobServices.getNotebooks(offset) return Response(res.json())
def put(self, request, notebookId): res = NotebookJobServices.clearNotebookResults(notebookId) return Response(res.json())
def get(self, request): res = NotebookJobServices.archivedNotebooks() return Response(res.json())
def post(self, request, notebookId): res = NotebookJobServices.cloneNotebook(notebookId, request.data) return Response(res.json())
def get(self, request): res = NotebookJobServices.getTimezones() return Response(res.json())
def get(self, request): res = NotebookJobServices.getNotebooksLight() return Response(res.json())