events: add API to get all event actions
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
7fad2b6563
commit
66d342880c
|
@ -11,6 +11,7 @@ from rest_framework.response import Response
|
|||
from rest_framework.serializers import ModelSerializer, Serializer
|
||||
from rest_framework.viewsets import ReadOnlyModelViewSet
|
||||
|
||||
from authentik.core.api.utils import TypeCreateSerializer
|
||||
from authentik.events.models import Event, EventAction
|
||||
|
||||
|
||||
|
@ -144,3 +145,18 @@ class EventViewSet(ReadOnlyModelViewSet):
|
|||
.values("unique_users", "application", "counted_events")
|
||||
.order_by("-counted_events")[:top_n]
|
||||
)
|
||||
|
||||
@swagger_auto_schema(responses={200: TypeCreateSerializer(many=True)})
|
||||
@action(detail=False, pagination_class=None, filter_backends=[])
|
||||
def actions(self, request: Request) -> Response:
|
||||
"""Get all actions"""
|
||||
data = []
|
||||
for value, name in EventAction.choices:
|
||||
data.append(
|
||||
{
|
||||
"name": name,
|
||||
"description": "",
|
||||
"link": value,
|
||||
}
|
||||
)
|
||||
return Response(TypeCreateSerializer(data, many=True).data)
|
||||
|
|
57
swagger.yaml
57
swagger.yaml
|
@ -2610,6 +2610,25 @@ paths:
|
|||
tags:
|
||||
- events
|
||||
parameters: []
|
||||
/events/events/actions/:
|
||||
get:
|
||||
operationId: events_events_actions
|
||||
description: Get all actions
|
||||
parameters: []
|
||||
responses:
|
||||
'200':
|
||||
description: ''
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/TypeCreate'
|
||||
'403':
|
||||
description: Authentication credentials were invalid, absent or insufficient.
|
||||
schema:
|
||||
$ref: '#/definitions/GenericError'
|
||||
tags:
|
||||
- events
|
||||
parameters: []
|
||||
/events/events/top_per_user/:
|
||||
get:
|
||||
operationId: events_events_top_per_user
|
||||
|
@ -14765,6 +14784,25 @@ definitions:
|
|||
title: Expires
|
||||
type: string
|
||||
format: date-time
|
||||
TypeCreate:
|
||||
required:
|
||||
- name
|
||||
- description
|
||||
- link
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
title: Name
|
||||
type: string
|
||||
minLength: 1
|
||||
description:
|
||||
title: Description
|
||||
type: string
|
||||
minLength: 1
|
||||
link:
|
||||
title: Link
|
||||
type: string
|
||||
minLength: 1
|
||||
EventTopPerUser:
|
||||
required:
|
||||
- application
|
||||
|
@ -15547,25 +15585,6 @@ definitions:
|
|||
title: Verbose name plural
|
||||
type: string
|
||||
readOnly: true
|
||||
TypeCreate:
|
||||
required:
|
||||
- name
|
||||
- description
|
||||
- link
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
title: Name
|
||||
type: string
|
||||
minLength: 1
|
||||
description:
|
||||
title: Description
|
||||
type: string
|
||||
minLength: 1
|
||||
link:
|
||||
title: Link
|
||||
type: string
|
||||
minLength: 1
|
||||
ServiceConnectionState:
|
||||
type: object
|
||||
properties:
|
||||
|
|
Reference in New Issue