diff --git a/authentik/events/api/event.py b/authentik/events/api/event.py index 0c59cf10b..04030fd09 100644 --- a/authentik/events/api/event.py +++ b/authentik/events/api/event.py @@ -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) diff --git a/swagger.yaml b/swagger.yaml index 1f12b29d7..df4f6e513 100755 --- a/swagger.yaml +++ b/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: