Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp @ 5364:b5f2122a1334
Added a route to delete completed jobs from history: DELETE /jobs/{id}
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 20 Jul 2023 10:51:34 +0200 |
parents | b376abae664a |
children | 62bb63346185 |
comparison
equal
deleted
inserted
replaced
5362:78aad3916da4 | 5364:b5f2122a1334 |
---|---|
727 info.Format(json); | 727 info.Format(json); |
728 call.GetOutput().AnswerJson(json); | 728 call.GetOutput().AnswerJson(json); |
729 } | 729 } |
730 } | 730 } |
731 | 731 |
732 static void DeleteJobInfo(RestApiDeleteCall& call) | |
733 { | |
734 if (call.IsDocumentation()) | |
735 { | |
736 call.GetDocumentation() | |
737 .SetTag("Jobs") | |
738 .SetSummary("Delete a job from history") | |
739 .SetDescription("Delete the job from the jobs history. Only a completed job can be deleted. " | |
740 "If the job has not run or not completed yet, you must cancel it first. " | |
741 "If the job has outputs, all outputs will be deleted as well. ") | |
742 .SetUriArgument("id", "Identifier of the job of interest"); | |
743 return; | |
744 } | |
745 | |
746 std::string job = call.GetUriComponent("id", ""); | |
747 | |
748 if (OrthancRestApi::GetContext(call).GetJobsEngine(). | |
749 GetRegistry().DeleteJobInfo(job)) | |
750 { | |
751 call.GetOutput().AnswerBuffer("", MimeType_PlainText); | |
752 } | |
753 else | |
754 { | |
755 throw OrthancException(ErrorCode_InexistentItem, | |
756 "No job found with this id: " + job); | |
757 } | |
758 } | |
759 | |
732 | 760 |
733 static void GetJobOutput(RestApiGetCall& call) | 761 static void GetJobOutput(RestApiGetCall& call) |
734 { | 762 { |
735 if (call.IsDocumentation()) | 763 if (call.IsDocumentation()) |
736 { | 764 { |
1136 Register("/plugins/{id}", GetPlugin); | 1164 Register("/plugins/{id}", GetPlugin); |
1137 Register("/plugins/explorer.js", GetOrthancExplorerPlugins); | 1165 Register("/plugins/explorer.js", GetOrthancExplorerPlugins); |
1138 | 1166 |
1139 Register("/jobs", ListJobs); | 1167 Register("/jobs", ListJobs); |
1140 Register("/jobs/{id}", GetJobInfo); | 1168 Register("/jobs/{id}", GetJobInfo); |
1169 Register("/jobs/{id}", DeleteJobInfo); | |
1141 Register("/jobs/{id}/cancel", ApplyJobAction<JobAction_Cancel>); | 1170 Register("/jobs/{id}/cancel", ApplyJobAction<JobAction_Cancel>); |
1142 Register("/jobs/{id}/pause", ApplyJobAction<JobAction_Pause>); | 1171 Register("/jobs/{id}/pause", ApplyJobAction<JobAction_Pause>); |
1143 Register("/jobs/{id}/resubmit", ApplyJobAction<JobAction_Resubmit>); | 1172 Register("/jobs/{id}/resubmit", ApplyJobAction<JobAction_Resubmit>); |
1144 Register("/jobs/{id}/resume", ApplyJobAction<JobAction_Resume>); | 1173 Register("/jobs/{id}/resume", ApplyJobAction<JobAction_Resume>); |
1145 Register("/jobs/{id}/{key}", GetJobOutput); | 1174 Register("/jobs/{id}/{key}", GetJobOutput); |