admin: add API to get info for a single task
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
d48badbca3
commit
dcc873b88b
|
@ -35,9 +35,18 @@ class TaskViewSet(ViewSet):
|
||||||
|
|
||||||
permission_classes = [IsAdminUser]
|
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)})
|
@swagger_auto_schema(responses={200: TaskSerializer(many=True)})
|
||||||
def list(self, request: Request) -> Response:
|
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)
|
tasks = sorted(TaskInfo.all().values(), key=lambda task: task.task_name)
|
||||||
return Response(TaskSerializer(tasks, many=True).data)
|
return Response(TaskSerializer(tasks, many=True).data)
|
||||||
|
|
||||||
|
|
28
swagger.yaml
28
swagger.yaml
|
@ -59,7 +59,7 @@ paths:
|
||||||
/admin/system_tasks/:
|
/admin/system_tasks/:
|
||||||
get:
|
get:
|
||||||
operationId: admin_system_tasks_list
|
operationId: admin_system_tasks_list
|
||||||
description: List current messages and pass into Serializer
|
description: List system tasks
|
||||||
parameters: []
|
parameters: []
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
|
@ -75,6 +75,32 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- admin
|
- admin
|
||||||
parameters: []
|
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/:
|
/admin/system_tasks/{id}/retry/:
|
||||||
post:
|
post:
|
||||||
operationId: admin_system_tasks_retry
|
operationId: admin_system_tasks_retry
|
||||||
|
|
Reference in New Issue