*: 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"""
|
"""PropertyMapping API Views"""
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from drf_yasg2.utils import swagger_auto_schema
|
from drf_yasg2.utils import swagger_auto_schema
|
||||||
|
from rest_framework import mixins
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.request import Request
|
from rest_framework.request import Request
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.serializers import ModelSerializer, SerializerMethodField
|
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.api.utils import MetaNameSerializer, TypeCreateSerializer
|
||||||
from authentik.core.models import PropertyMapping
|
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"""
|
"""PropertyMapping Viewset"""
|
||||||
|
|
||||||
queryset = PropertyMapping.objects.none()
|
queryset = PropertyMapping.objects.none()
|
||||||
|
|
|
@ -3,11 +3,12 @@ from typing import Iterable
|
||||||
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from drf_yasg2.utils import swagger_auto_schema
|
from drf_yasg2.utils import swagger_auto_schema
|
||||||
|
from rest_framework import mixins
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.request import Request
|
from rest_framework.request import Request
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.serializers import ModelSerializer, SerializerMethodField
|
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 structlog.stdlib import get_logger
|
||||||
|
|
||||||
from authentik.core.api.utils import MetaNameSerializer, TypeCreateSerializer
|
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"""
|
"""Source Viewset"""
|
||||||
|
|
||||||
queryset = Source.objects.none()
|
queryset = Source.objects.none()
|
||||||
|
|
|
@ -3,11 +3,12 @@ from typing import Iterable
|
||||||
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from drf_yasg2.utils import swagger_auto_schema
|
from drf_yasg2.utils import swagger_auto_schema
|
||||||
|
from rest_framework import mixins
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.request import Request
|
from rest_framework.request import Request
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.serializers import ModelSerializer, SerializerMethodField
|
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 structlog.stdlib import get_logger
|
||||||
|
|
||||||
from authentik.core.api.utils import MetaNameSerializer, TypeCreateSerializer
|
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"""
|
"""Stage Viewset"""
|
||||||
|
|
||||||
queryset = Stage.objects.all().select_related("flow_set")
|
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.core.exceptions import ObjectDoesNotExist
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from drf_yasg2.utils import swagger_auto_schema
|
from drf_yasg2.utils import swagger_auto_schema
|
||||||
|
from rest_framework import mixins
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.request import Request
|
from rest_framework.request import Request
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
@ -11,7 +12,7 @@ from rest_framework.serializers import (
|
||||||
PrimaryKeyRelatedField,
|
PrimaryKeyRelatedField,
|
||||||
SerializerMethodField,
|
SerializerMethodField,
|
||||||
)
|
)
|
||||||
from rest_framework.viewsets import ModelViewSet, ReadOnlyModelViewSet
|
from rest_framework.viewsets import GenericViewSet, ModelViewSet
|
||||||
|
|
||||||
from authentik.core.api.utils import (
|
from authentik.core.api.utils import (
|
||||||
CacheSerializer,
|
CacheSerializer,
|
||||||
|
@ -98,7 +99,12 @@ class PolicySerializer(ModelSerializer, MetaNameSerializer):
|
||||||
depth = 3
|
depth = 3
|
||||||
|
|
||||||
|
|
||||||
class PolicyViewSet(ReadOnlyModelViewSet):
|
class PolicyViewSet(
|
||||||
|
mixins.RetrieveModelMixin,
|
||||||
|
mixins.DestroyModelMixin,
|
||||||
|
mixins.ListModelMixin,
|
||||||
|
GenericViewSet,
|
||||||
|
):
|
||||||
"""Policy Viewset"""
|
"""Policy Viewset"""
|
||||||
|
|
||||||
queryset = Policy.objects.all()
|
queryset = Policy.objects.all()
|
||||||
|
|
36
swagger.yaml
36
swagger.yaml
|
@ -3778,6 +3778,15 @@ paths:
|
||||||
$ref: '#/definitions/Policy'
|
$ref: '#/definitions/Policy'
|
||||||
tags:
|
tags:
|
||||||
- policies
|
- policies
|
||||||
|
delete:
|
||||||
|
operationId: policies_all_delete
|
||||||
|
description: Policy Viewset
|
||||||
|
parameters: []
|
||||||
|
responses:
|
||||||
|
'204':
|
||||||
|
description: ''
|
||||||
|
tags:
|
||||||
|
- policies
|
||||||
parameters:
|
parameters:
|
||||||
- name: policy_uuid
|
- name: policy_uuid
|
||||||
in: path
|
in: path
|
||||||
|
@ -5494,6 +5503,15 @@ paths:
|
||||||
$ref: '#/definitions/PropertyMapping'
|
$ref: '#/definitions/PropertyMapping'
|
||||||
tags:
|
tags:
|
||||||
- propertymappings
|
- propertymappings
|
||||||
|
delete:
|
||||||
|
operationId: propertymappings_all_delete
|
||||||
|
description: PropertyMapping Viewset
|
||||||
|
parameters: []
|
||||||
|
responses:
|
||||||
|
'204':
|
||||||
|
description: ''
|
||||||
|
tags:
|
||||||
|
- propertymappings
|
||||||
parameters:
|
parameters:
|
||||||
- name: pm_uuid
|
- name: pm_uuid
|
||||||
in: path
|
in: path
|
||||||
|
@ -6737,6 +6755,15 @@ paths:
|
||||||
$ref: '#/definitions/Source'
|
$ref: '#/definitions/Source'
|
||||||
tags:
|
tags:
|
||||||
- sources
|
- sources
|
||||||
|
delete:
|
||||||
|
operationId: sources_all_delete
|
||||||
|
description: Source Viewset
|
||||||
|
parameters: []
|
||||||
|
responses:
|
||||||
|
'204':
|
||||||
|
description: ''
|
||||||
|
tags:
|
||||||
|
- sources
|
||||||
parameters:
|
parameters:
|
||||||
- name: slug
|
- name: slug
|
||||||
in: path
|
in: path
|
||||||
|
@ -7380,6 +7407,15 @@ paths:
|
||||||
$ref: '#/definitions/Stage'
|
$ref: '#/definitions/Stage'
|
||||||
tags:
|
tags:
|
||||||
- stages
|
- stages
|
||||||
|
delete:
|
||||||
|
operationId: stages_all_delete
|
||||||
|
description: Stage Viewset
|
||||||
|
parameters: []
|
||||||
|
responses:
|
||||||
|
'204':
|
||||||
|
description: ''
|
||||||
|
tags:
|
||||||
|
- stages
|
||||||
parameters:
|
parameters:
|
||||||
- name: stage_uuid
|
- name: stage_uuid
|
||||||
in: path
|
in: path
|
||||||
|
|
Reference in New Issue