authentik.providers.rac.api.property_mappings
RAC Provider API Views
1"""RAC Provider API Views""" 2 3from django_filters.filters import AllValuesMultipleFilter 4from django_filters.filterset import FilterSet 5from drf_spectacular.types import OpenApiTypes 6from drf_spectacular.utils import extend_schema_field 7from rest_framework.fields import CharField 8from rest_framework.viewsets import ModelViewSet 9 10from authentik.core.api.property_mappings import PropertyMappingSerializer 11from authentik.core.api.used_by import UsedByMixin 12from authentik.core.api.utils import JSONDictField 13from authentik.providers.rac.models import RACPropertyMapping 14 15 16class RACPropertyMappingSerializer(PropertyMappingSerializer): 17 """RACPropertyMapping Serializer""" 18 19 static_settings = JSONDictField() 20 expression = CharField(allow_blank=True, required=False) 21 22 def validate_expression(self, expression: str) -> str: 23 """Test Syntax""" 24 if expression == "": 25 return expression 26 return super().validate_expression(expression) 27 28 class Meta: 29 model = RACPropertyMapping 30 fields = PropertyMappingSerializer.Meta.fields + ["static_settings"] 31 32 33class RACPropertyMappingFilter(FilterSet): 34 """Filter for RACPropertyMapping""" 35 36 managed = extend_schema_field(OpenApiTypes.STR)(AllValuesMultipleFilter(field_name="managed")) 37 38 class Meta: 39 model = RACPropertyMapping 40 fields = ["name", "managed"] 41 42 43class RACPropertyMappingViewSet(UsedByMixin, ModelViewSet): 44 """RACPropertyMapping Viewset""" 45 46 queryset = RACPropertyMapping.objects.all() 47 serializer_class = RACPropertyMappingSerializer 48 search_fields = ["name"] 49 ordering = ["name"] 50 filterset_class = RACPropertyMappingFilter
17class RACPropertyMappingSerializer(PropertyMappingSerializer): 18 """RACPropertyMapping Serializer""" 19 20 static_settings = JSONDictField() 21 expression = CharField(allow_blank=True, required=False) 22 23 def validate_expression(self, expression: str) -> str: 24 """Test Syntax""" 25 if expression == "": 26 return expression 27 return super().validate_expression(expression) 28 29 class Meta: 30 model = RACPropertyMapping 31 fields = PropertyMappingSerializer.Meta.fields + ["static_settings"]
RACPropertyMapping Serializer
def
validate_expression(self, expression: str) -> str:
23 def validate_expression(self, expression: str) -> str: 24 """Test Syntax""" 25 if expression == "": 26 return expression 27 return super().validate_expression(expression)
Test Syntax
Inherited Members
class
RACPropertyMappingSerializer.Meta:
29 class Meta: 30 model = RACPropertyMapping 31 fields = PropertyMappingSerializer.Meta.fields + ["static_settings"]
model =
<class 'authentik.providers.rac.models.RACPropertyMapping'>
class
RACPropertyMappingFilter(django_filters.filterset.FilterSet):
34class RACPropertyMappingFilter(FilterSet): 35 """Filter for RACPropertyMapping""" 36 37 managed = extend_schema_field(OpenApiTypes.STR)(AllValuesMultipleFilter(field_name="managed")) 38 39 class Meta: 40 model = RACPropertyMapping 41 fields = ["name", "managed"]
Filter for RACPropertyMapping
class
RACPropertyMappingFilter.Meta:
model =
<class 'authentik.providers.rac.models.RACPropertyMapping'>
class
RACPropertyMappingViewSet(authentik.core.api.used_by.UsedByMixin, rest_framework.viewsets.ModelViewSet):
44class RACPropertyMappingViewSet(UsedByMixin, ModelViewSet): 45 """RACPropertyMapping Viewset""" 46 47 queryset = RACPropertyMapping.objects.all() 48 serializer_class = RACPropertyMappingSerializer 49 search_fields = ["name"] 50 ordering = ["name"] 51 filterset_class = RACPropertyMappingFilter
RACPropertyMapping Viewset
serializer_class =
<class 'RACPropertyMappingSerializer'>
filterset_class =
<class 'RACPropertyMappingFilter'>