Files
jumpserver/apps/assets/api/protocol.py
fit2bot 395b868dcf perf: swagger done (#15865)
* perf: swagger upgrade

* perf: upgrade to drf-spectacular

* perf: 添加部分注解

* perf: swagger done

---------

Co-authored-by: ibuler <ibuler@qq.com>
2025-08-27 10:27:01 +08:00

26 lines
725 B
Python

from rest_framework.generics import ListAPIView
from assets import serializers
from common.permissions import IsValidUser
from assets.models import Protocol
__all__ = ['ProtocolListApi']
class ProtocolListApi(ListAPIView):
serializer_class = serializers.ProtocolSerializer
permission_classes = (IsValidUser,)
def get_queryset(self):
return list(Protocol.protocols())
def filter_queryset(self, queryset):
search = self.request.query_params.get("search", "").lower().strip()
if not search:
return queryset
queryset = [
p for p in queryset
if search in p['label'].lower() or search in p['value'].lower()
]
return queryset