From dcc873b88baa42dd041ae16938fba03b7f82e85e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 5 Apr 2021 20:40:22 +0200 Subject: [PATCH] admin: add API to get info for a single task Signed-off-by: Jens Langhammer --- authentik/admin/api/tasks.py | 11 ++++++++++- swagger.yaml | 28 +++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/authentik/admin/api/tasks.py b/authentik/admin/api/tasks.py index 08d2e91a4..68f5e1b4d 100644 --- a/authentik/admin/api/tasks.py +++ b/authentik/admin/api/tasks.py @@ -35,9 +35,18 @@ class TaskViewSet(ViewSet): permission_classes = [IsAdminUser] + @swagger_auto_schema(responses={200: TaskSerializer(many=False)}) + # pylint: disable=invalid-name + def retrieve(self, request: Request, pk=None) -> Response: + """Get a single system task""" + task = TaskInfo.by_name(pk) + if not task: + raise Http404 + return Response(TaskSerializer(task, many=False).data) + @swagger_auto_schema(responses={200: TaskSerializer(many=True)}) def list(self, request: Request) -> Response: - """List current messages and pass into Serializer""" + """List system tasks""" tasks = sorted(TaskInfo.all().values(), key=lambda task: task.task_name) return Response(TaskSerializer(tasks, many=True).data) diff --git a/swagger.yaml b/swagger.yaml index bf0ad9a2a..7bee8f57b 100755 --- a/swagger.yaml +++ b/swagger.yaml @@ -59,7 +59,7 @@ paths: /admin/system_tasks/: get: operationId: admin_system_tasks_list - description: List current messages and pass into Serializer + description: List system tasks parameters: [] responses: '200': @@ -75,6 +75,32 @@ paths: tags: - admin parameters: [] + /admin/system_tasks/{id}/: + get: + operationId: admin_system_tasks_read + description: Get a single system task + parameters: [] + responses: + '200': + description: '' + schema: + $ref: '#/definitions/Task' + '403': + description: Authentication credentials were invalid, absent or insufficient. + schema: + $ref: '#/definitions/GenericError' + '404': + description: Object does not exist or caller has insufficient permissions + to access it. + schema: + $ref: '#/definitions/APIException' + tags: + - admin + parameters: + - name: id + in: path + required: true + type: string /admin/system_tasks/{id}/retry/: post: operationId: admin_system_tasks_retry