api: remove legacy messages API as its WS only
This commit is contained in:
parent
9e3d1f0baa
commit
f4580a1097
|
@ -1,37 +0,0 @@
|
|||
"""core messages API"""
|
||||
from django.contrib.messages import get_messages
|
||||
from django.db.models import Model
|
||||
from drf_yasg2.utils import swagger_auto_schema
|
||||
from rest_framework.permissions import AllowAny
|
||||
from rest_framework.request import Request
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.serializers import ReadOnlyField, Serializer
|
||||
from rest_framework.viewsets import ViewSet
|
||||
|
||||
|
||||
class MessageSerializer(Serializer):
|
||||
"""Serialize Django Message into DRF Object"""
|
||||
|
||||
message = ReadOnlyField()
|
||||
level = ReadOnlyField()
|
||||
tags = ReadOnlyField()
|
||||
extra_tags = ReadOnlyField()
|
||||
level_tag = ReadOnlyField()
|
||||
|
||||
def create(self, validated_data: dict) -> Model:
|
||||
raise NotImplementedError
|
||||
|
||||
def update(self, instance: Model, validated_data: dict) -> Model:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class MessagesViewSet(ViewSet):
|
||||
"""Read-only view set that returns the current session's messages"""
|
||||
|
||||
permission_classes = [AllowAny]
|
||||
|
||||
@swagger_auto_schema(responses={200: MessageSerializer(many=True)})
|
||||
def list(self, request: Request) -> Response:
|
||||
"""List current messages and pass into Serializer"""
|
||||
all_messages = list(get_messages(request))
|
||||
return Response(MessageSerializer(all_messages, many=True).data)
|
|
@ -10,7 +10,6 @@ from authentik.admin.api.tasks import TaskViewSet
|
|||
from authentik.admin.api.version import VersionViewSet
|
||||
from authentik.admin.api.workers import WorkerViewSet
|
||||
from authentik.api.v2.config import ConfigsViewSet
|
||||
from authentik.api.v2.messages import MessagesViewSet
|
||||
from authentik.core.api.applications import ApplicationViewSet
|
||||
from authentik.core.api.groups import GroupViewSet
|
||||
from authentik.core.api.propertymappings import PropertyMappingViewSet
|
||||
|
@ -77,7 +76,6 @@ from authentik.stages.user_write.api import UserWriteStageViewSet
|
|||
|
||||
router = routers.DefaultRouter()
|
||||
|
||||
router.register("root/messages", MessagesViewSet, basename="messages")
|
||||
router.register("root/config", ConfigsViewSet, basename="configs")
|
||||
|
||||
router.register("admin/version", VersionViewSet, basename="admin_version")
|
||||
|
|
40
swagger.yaml
40
swagger.yaml
|
@ -5851,22 +5851,6 @@ paths:
|
|||
tags:
|
||||
- root
|
||||
parameters: []
|
||||
/root/messages/:
|
||||
get:
|
||||
operationId: root_messages_list
|
||||
description: List current messages and pass into Serializer
|
||||
parameters: []
|
||||
responses:
|
||||
'200':
|
||||
description: Serialize Django Message into DRF Object
|
||||
schema:
|
||||
description: ''
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/Message'
|
||||
tags:
|
||||
- root
|
||||
parameters: []
|
||||
/sources/all/:
|
||||
get:
|
||||
operationId: sources_all_list
|
||||
|
@ -11846,30 +11830,6 @@ definitions:
|
|||
title: Error reporting send pii
|
||||
type: string
|
||||
readOnly: true
|
||||
Message:
|
||||
description: Serialize Django Message into DRF Object
|
||||
type: object
|
||||
properties:
|
||||
message:
|
||||
title: Message
|
||||
type: string
|
||||
readOnly: true
|
||||
level:
|
||||
title: Level
|
||||
type: string
|
||||
readOnly: true
|
||||
tags:
|
||||
title: Tags
|
||||
type: string
|
||||
readOnly: true
|
||||
extra_tags:
|
||||
title: Extra tags
|
||||
type: string
|
||||
readOnly: true
|
||||
level_tag:
|
||||
title: Level tag
|
||||
type: string
|
||||
readOnly: true
|
||||
Source:
|
||||
description: Source Serializer
|
||||
required:
|
||||
|
|
Reference in New Issue