From 9fe8554f28a87e075046c7f21ca8b51bb798f40f Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 14 Jan 2021 16:51:24 +0100 Subject: [PATCH] events: make notification read/update only --- authentik/events/api/notification.py | 17 ++++++++++++++-- swagger.yaml | 30 +++------------------------- 2 files changed, 18 insertions(+), 29 deletions(-) diff --git a/authentik/events/api/notification.py b/authentik/events/api/notification.py index 39c38dd70..054db3a62 100644 --- a/authentik/events/api/notification.py +++ b/authentik/events/api/notification.py @@ -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() diff --git a/swagger.yaml b/swagger.yaml index 7792ccdaf..7f0b28359 100755 --- a/swagger.yaml +++ b/swagger.yaml @@ -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