MCPcopy Create free account
hub / github.com/intelowlproject/IntelOwl / kill

Method kill

api_app/views.py:1106–1134  ·  view source on GitHub ↗

Kills a specific report by terminating its Celery task and marking it as killed. This endpoint handles the patch request to kill a report if its status is running or pending. Args: request (HttpRequest): The request object containing the HTTP PATCH requ

(self, request, job_id, report_id)

Source from the content-addressed store, hash-verified

1104
1105 @action(detail=False, methods=["patch"])
1106 def kill(self, request, job_id, report_id):
1107 """
1108 Kills a specific report by terminating its Celery task and marking it as killed.
1109
1110 This endpoint handles the patch request to kill a report if its status is
1111 running or pending.
1112
1113 Args:
1114 request (HttpRequest): The request object containing the HTTP PATCH request.
1115 job_id (int): The ID of the job associated with the report.
1116 report_id (int): The ID of the report.
1117
1118 Returns:
1119 Response: HTTP 204 No Content if successful.
1120
1121 Raises:
1122 ValidationError: If the report is not in a valid state for killing.
1123 """
1124 logger.info(f"kill request from user {request.user} for job_id {job_id}, pk {report_id}")
1125 # get report object or raise 404
1126 report = self.get_object(job_id, report_id)
1127 if report.status not in [
1128 AbstractReport.STATUSES.RUNNING,
1129 AbstractReport.STATUSES.PENDING,
1130 ]:
1131 raise ValidationError({"detail": "Plugin is not running or pending"})
1132
1133 self.perform_kill(report)
1134 return Response(status=status.HTTP_204_NO_CONTENT)
1135
1136 @action(detail=False, methods=["patch"])
1137 def retry(self, request, job_id, report_id):

Callers

nothing calls this directly

Calls 2

get_objectMethod · 0.95
perform_killMethod · 0.95

Tested by

no test coverage detected