events: make notification read/update only
This commit is contained in:
parent
812fe72e60
commit
9fe8554f28
|
@ -1,6 +1,8 @@
|
||||||
"""Notification API Views"""
|
"""Notification API Views"""
|
||||||
|
from rest_framework import mixins
|
||||||
|
from rest_framework.fields import ReadOnlyField
|
||||||
from rest_framework.serializers import ModelSerializer
|
from rest_framework.serializers import ModelSerializer
|
||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework.viewsets import GenericViewSet
|
||||||
|
|
||||||
from authentik.events.models import Notification
|
from authentik.events.models import Notification
|
||||||
|
|
||||||
|
@ -8,6 +10,11 @@ from authentik.events.models import Notification
|
||||||
class NotificationSerializer(ModelSerializer):
|
class NotificationSerializer(ModelSerializer):
|
||||||
"""Notification Serializer"""
|
"""Notification Serializer"""
|
||||||
|
|
||||||
|
body = ReadOnlyField()
|
||||||
|
severity = ReadOnlyField()
|
||||||
|
created = ReadOnlyField()
|
||||||
|
event = ReadOnlyField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
model = Notification
|
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"""
|
"""Notification Viewset"""
|
||||||
|
|
||||||
queryset = Notification.objects.all()
|
queryset = Notification.objects.all()
|
||||||
|
|
30
swagger.yaml
30
swagger.yaml
|
@ -1029,22 +1029,6 @@ paths:
|
||||||
$ref: '#/definitions/Notification'
|
$ref: '#/definitions/Notification'
|
||||||
tags:
|
tags:
|
||||||
- events
|
- 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: []
|
parameters: []
|
||||||
/events/notifications/{uuid}/:
|
/events/notifications/{uuid}/:
|
||||||
get:
|
get:
|
||||||
|
@ -7619,9 +7603,6 @@ definitions:
|
||||||
type: integer
|
type: integer
|
||||||
Notification:
|
Notification:
|
||||||
description: Notification Serializer
|
description: Notification Serializer
|
||||||
required:
|
|
||||||
- severity
|
|
||||||
- body
|
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
pk:
|
pk:
|
||||||
|
@ -7632,24 +7613,19 @@ definitions:
|
||||||
severity:
|
severity:
|
||||||
title: Severity
|
title: Severity
|
||||||
type: string
|
type: string
|
||||||
enum:
|
readOnly: true
|
||||||
- notice
|
|
||||||
- warning
|
|
||||||
- alert
|
|
||||||
body:
|
body:
|
||||||
title: Body
|
title: Body
|
||||||
type: string
|
type: string
|
||||||
minLength: 1
|
readOnly: true
|
||||||
created:
|
created:
|
||||||
title: Created
|
title: Created
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
|
||||||
readOnly: true
|
readOnly: true
|
||||||
event:
|
event:
|
||||||
title: Event
|
title: Event
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
readOnly: true
|
||||||
x-nullable: true
|
|
||||||
seen:
|
seen:
|
||||||
title: Seen
|
title: Seen
|
||||||
type: boolean
|
type: boolean
|
||||||
|
|
Reference in New Issue