events: make notification read/update only

This commit is contained in:
Jens Langhammer 2021-01-14 16:51:24 +01:00
parent 812fe72e60
commit 9fe8554f28
2 changed files with 18 additions and 29 deletions

View File

@ -1,6 +1,8 @@
"""Notification API Views"""
from rest_framework import mixins
from rest_framework.fields import ReadOnlyField
from rest_framework.serializers import ModelSerializer
from rest_framework.viewsets import ModelViewSet
from rest_framework.viewsets import GenericViewSet
from authentik.events.models import Notification
@ -8,6 +10,11 @@ from authentik.events.models import Notification
class NotificationSerializer(ModelSerializer):
"""Notification Serializer"""
body = ReadOnlyField()
severity = ReadOnlyField()
created = ReadOnlyField()
event = ReadOnlyField()
class Meta:
model = Notification
@ -21,7 +28,13 @@ class NotificationSerializer(ModelSerializer):
]
class NotificationViewSet(ModelViewSet):
class NotificationViewSet(
mixins.RetrieveModelMixin,
mixins.UpdateModelMixin,
mixins.DestroyModelMixin,
mixins.ListModelMixin,
GenericViewSet,
):
"""Notification Viewset"""
queryset = Notification.objects.all()

View File

@ -1029,22 +1029,6 @@ paths:
$ref: '#/definitions/Notification'
tags:
- events
post:
operationId: events_notifications_create
description: Notification Viewset
parameters:
- name: data
in: body
required: true
schema:
$ref: '#/definitions/Notification'
responses:
'201':
description: ''
schema:
$ref: '#/definitions/Notification'
tags:
- events
parameters: []
/events/notifications/{uuid}/:
get:
@ -7619,9 +7603,6 @@ definitions:
type: integer
Notification:
description: Notification Serializer
required:
- severity
- body
type: object
properties:
pk:
@ -7632,24 +7613,19 @@ definitions:
severity:
title: Severity
type: string
enum:
- notice
- warning
- alert
readOnly: true
body:
title: Body
type: string
minLength: 1
readOnly: true
created:
title: Created
type: string
format: date-time
readOnly: true
event:
title: Event
type: string
format: uuid
x-nullable: true
readOnly: true
seen:
title: Seen
type: boolean