*: replace ReadOnlyModelViewSet with List/Retrieve/Delete viewsets
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
013a192485
commit
dae60b5a08
|
@ -1,11 +1,12 @@
|
|||
"""PropertyMapping API Views"""
|
||||
from django.urls import reverse
|
||||
from drf_yasg2.utils import swagger_auto_schema
|
||||
from rest_framework import mixins
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.request import Request
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.serializers import ModelSerializer, SerializerMethodField
|
||||
from rest_framework.viewsets import ReadOnlyModelViewSet
|
||||
from rest_framework.viewsets import GenericViewSet
|
||||
|
||||
from authentik.core.api.utils import MetaNameSerializer, TypeCreateSerializer
|
||||
from authentik.core.models import PropertyMapping
|
||||
|
@ -41,7 +42,12 @@ class PropertyMappingSerializer(ModelSerializer, MetaNameSerializer):
|
|||
]
|
||||
|
||||
|
||||
class PropertyMappingViewSet(ReadOnlyModelViewSet):
|
||||
class PropertyMappingViewSet(
|
||||
mixins.RetrieveModelMixin,
|
||||
mixins.DestroyModelMixin,
|
||||
mixins.ListModelMixin,
|
||||
GenericViewSet,
|
||||
):
|
||||
"""PropertyMapping Viewset"""
|
||||
|
||||
queryset = PropertyMapping.objects.none()
|
||||
|
|
|
@ -3,11 +3,12 @@ from typing import Iterable
|
|||
|
||||
from django.urls import reverse
|
||||
from drf_yasg2.utils import swagger_auto_schema
|
||||
from rest_framework import mixins
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.request import Request
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.serializers import ModelSerializer, SerializerMethodField
|
||||
from rest_framework.viewsets import ReadOnlyModelViewSet
|
||||
from rest_framework.viewsets import GenericViewSet
|
||||
from structlog.stdlib import get_logger
|
||||
|
||||
from authentik.core.api.utils import MetaNameSerializer, TypeCreateSerializer
|
||||
|
@ -45,7 +46,12 @@ class SourceSerializer(ModelSerializer, MetaNameSerializer):
|
|||
]
|
||||
|
||||
|
||||
class SourceViewSet(ReadOnlyModelViewSet):
|
||||
class SourceViewSet(
|
||||
mixins.RetrieveModelMixin,
|
||||
mixins.DestroyModelMixin,
|
||||
mixins.ListModelMixin,
|
||||
GenericViewSet,
|
||||
):
|
||||
"""Source Viewset"""
|
||||
|
||||
queryset = Source.objects.none()
|
||||
|
|
|
@ -3,11 +3,12 @@ from typing import Iterable
|
|||
|
||||
from django.urls import reverse
|
||||
from drf_yasg2.utils import swagger_auto_schema
|
||||
from rest_framework import mixins
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.request import Request
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.serializers import ModelSerializer, SerializerMethodField
|
||||
from rest_framework.viewsets import ReadOnlyModelViewSet
|
||||
from rest_framework.viewsets import GenericViewSet
|
||||
from structlog.stdlib import get_logger
|
||||
|
||||
from authentik.core.api.utils import MetaNameSerializer, TypeCreateSerializer
|
||||
|
@ -43,7 +44,12 @@ class StageSerializer(ModelSerializer, MetaNameSerializer):
|
|||
]
|
||||
|
||||
|
||||
class StageViewSet(ReadOnlyModelViewSet):
|
||||
class StageViewSet(
|
||||
mixins.RetrieveModelMixin,
|
||||
mixins.DestroyModelMixin,
|
||||
mixins.ListModelMixin,
|
||||
GenericViewSet,
|
||||
):
|
||||
"""Stage Viewset"""
|
||||
|
||||
queryset = Stage.objects.all().select_related("flow_set")
|
||||
|
|
|
@ -3,6 +3,7 @@ from django.core.cache import cache
|
|||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.urls import reverse
|
||||
from drf_yasg2.utils import swagger_auto_schema
|
||||
from rest_framework import mixins
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.request import Request
|
||||
from rest_framework.response import Response
|
||||
|
@ -11,7 +12,7 @@ from rest_framework.serializers import (
|
|||
PrimaryKeyRelatedField,
|
||||
SerializerMethodField,
|
||||
)
|
||||
from rest_framework.viewsets import ModelViewSet, ReadOnlyModelViewSet
|
||||
from rest_framework.viewsets import GenericViewSet, ModelViewSet
|
||||
|
||||
from authentik.core.api.utils import (
|
||||
CacheSerializer,
|
||||
|
@ -98,7 +99,12 @@ class PolicySerializer(ModelSerializer, MetaNameSerializer):
|
|||
depth = 3
|
||||
|
||||
|
||||
class PolicyViewSet(ReadOnlyModelViewSet):
|
||||
class PolicyViewSet(
|
||||
mixins.RetrieveModelMixin,
|
||||
mixins.DestroyModelMixin,
|
||||
mixins.ListModelMixin,
|
||||
GenericViewSet,
|
||||
):
|
||||
"""Policy Viewset"""
|
||||
|
||||
queryset = Policy.objects.all()
|
||||
|
|
36
swagger.yaml
36
swagger.yaml
|
@ -3778,6 +3778,15 @@ paths:
|
|||
$ref: '#/definitions/Policy'
|
||||
tags:
|
||||
- policies
|
||||
delete:
|
||||
operationId: policies_all_delete
|
||||
description: Policy Viewset
|
||||
parameters: []
|
||||
responses:
|
||||
'204':
|
||||
description: ''
|
||||
tags:
|
||||
- policies
|
||||
parameters:
|
||||
- name: policy_uuid
|
||||
in: path
|
||||
|
@ -5494,6 +5503,15 @@ paths:
|
|||
$ref: '#/definitions/PropertyMapping'
|
||||
tags:
|
||||
- propertymappings
|
||||
delete:
|
||||
operationId: propertymappings_all_delete
|
||||
description: PropertyMapping Viewset
|
||||
parameters: []
|
||||
responses:
|
||||
'204':
|
||||
description: ''
|
||||
tags:
|
||||
- propertymappings
|
||||
parameters:
|
||||
- name: pm_uuid
|
||||
in: path
|
||||
|
@ -6737,6 +6755,15 @@ paths:
|
|||
$ref: '#/definitions/Source'
|
||||
tags:
|
||||
- sources
|
||||
delete:
|
||||
operationId: sources_all_delete
|
||||
description: Source Viewset
|
||||
parameters: []
|
||||
responses:
|
||||
'204':
|
||||
description: ''
|
||||
tags:
|
||||
- sources
|
||||
parameters:
|
||||
- name: slug
|
||||
in: path
|
||||
|
@ -7380,6 +7407,15 @@ paths:
|
|||
$ref: '#/definitions/Stage'
|
||||
tags:
|
||||
- stages
|
||||
delete:
|
||||
operationId: stages_all_delete
|
||||
description: Stage Viewset
|
||||
parameters: []
|
||||
responses:
|
||||
'204':
|
||||
description: ''
|
||||
tags:
|
||||
- stages
|
||||
parameters:
|
||||
- name: stage_uuid
|
||||
in: path
|
||||
|
|
Reference in New Issue