admin: make tasks's retry api not ask for a body
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
d38fd603dd
commit
d0f1daf025
|
@ -4,6 +4,7 @@ from importlib import import_module
|
|||
from django.contrib import messages
|
||||
from django.http.response import Http404
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from drf_spectacular.types import OpenApiTypes
|
||||
from drf_spectacular.utils import OpenApiResponse, extend_schema
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.fields import CharField, ChoiceField, DateTimeField, ListField
|
||||
|
@ -57,11 +58,12 @@ class TaskViewSet(ViewSet):
|
|||
return Response(TaskSerializer(tasks, many=True).data)
|
||||
|
||||
@extend_schema(
|
||||
request=OpenApiTypes.NONE,
|
||||
responses={
|
||||
204: OpenApiResponse(description="Task retried successfully"),
|
||||
404: OpenApiResponse(description="Task not found"),
|
||||
500: OpenApiResponse(description="Failed to retry task"),
|
||||
}
|
||||
},
|
||||
)
|
||||
@action(detail=True, methods=["post"])
|
||||
# pylint: disable=invalid-name
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
"""authentik administration overview"""
|
||||
from drf_spectacular.utils import extend_schema, inline_serializer
|
||||
from rest_framework.fields import IntegerField
|
||||
from rest_framework.permissions import IsAdminUser
|
||||
from rest_framework.request import Request
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.fields import IntegerField
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from authentik.root.celery import CELERY_APP
|
||||
|
@ -15,12 +15,8 @@ class WorkerView(APIView):
|
|||
permission_classes = [IsAdminUser]
|
||||
|
||||
@extend_schema(
|
||||
responses=inline_serializer("Workers", fields={
|
||||
"count": IntegerField()
|
||||
})
|
||||
responses=inline_serializer("Workers", fields={"count": IntegerField()})
|
||||
)
|
||||
def get(self, request: Request) -> Response:
|
||||
"""Get currently connected worker count."""
|
||||
return Response(
|
||||
{"count": len(CELERY_APP.control.ping(timeout=0.5))}
|
||||
)
|
||||
return Response({"count": len(CELERY_APP.control.ping(timeout=0.5))})
|
||||
|
|
|
@ -194,7 +194,11 @@ urlpatterns = (
|
|||
]
|
||||
+ router.urls
|
||||
+ [
|
||||
path("admin/metrics/", AdministrationMetricsViewSet.as_view(), name="admin_metrics"),
|
||||
path(
|
||||
"admin/metrics/",
|
||||
AdministrationMetricsViewSet.as_view(),
|
||||
name="admin_metrics",
|
||||
),
|
||||
path("admin/version/", VersionView.as_view(), name="admin_version"),
|
||||
path("admin/workers/", WorkerView.as_view(), name="admin_workers"),
|
||||
path("root/config/", ConfigView.as_view(), name="config"),
|
||||
|
|
34
schema.yml
34
schema.yml
|
@ -97,18 +97,6 @@ paths:
|
|||
required: true
|
||||
tags:
|
||||
- admin
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TaskRequest'
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TaskRequest'
|
||||
multipart/form-data:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TaskRequest'
|
||||
required: true
|
||||
security:
|
||||
- authentik: []
|
||||
- cookieAuth: []
|
||||
|
@ -21666,28 +21654,6 @@ components:
|
|||
- task_description
|
||||
- task_finish_timestamp
|
||||
- task_name
|
||||
TaskRequest:
|
||||
type: object
|
||||
description: Serialize TaskInfo and TaskResult
|
||||
properties:
|
||||
task_name:
|
||||
type: string
|
||||
task_description:
|
||||
type: string
|
||||
task_finish_timestamp:
|
||||
type: string
|
||||
format: date-time
|
||||
status:
|
||||
$ref: '#/components/schemas/StatusEnum'
|
||||
messages:
|
||||
type: array
|
||||
items: {}
|
||||
required:
|
||||
- messages
|
||||
- status
|
||||
- task_description
|
||||
- task_finish_timestamp
|
||||
- task_name
|
||||
Token:
|
||||
type: object
|
||||
description: Token Serializer
|
||||
|
|
|
@ -105,8 +105,8 @@ export class SystemTaskListPage extends TablePage<Task> {
|
|||
this.taskStatus(item),
|
||||
html`<ak-action-button
|
||||
.apiRequest=${() => {
|
||||
return new AdminApi(DEFAULT_CONFIG).adminSystemTasksRetry({
|
||||
id: item.taskName
|
||||
return new AdminApi(DEFAULT_CONFIG).adminSystemTasksRetryCreate({
|
||||
id: item.taskName,
|
||||
});
|
||||
}}>
|
||||
${t`Retry Task`}
|
||||
|
|
Reference in New Issue