jumpserver/apps/audits/api.py

50 lines
1.2 KiB
Python
Raw Normal View History

2016-08-09 09:27:37 +00:00
# ~*~ coding: utf-8 ~*~
#
2016-10-08 16:12:18 +00:00
from rest_framework import generics
import serializers
2016-10-09 16:39:24 +00:00
from .models import ProxyLog
2016-10-18 11:28:36 +00:00
from .hands import IsSuperUserOrTerminalUser, Terminal
2016-10-08 16:12:18 +00:00
2016-10-09 16:39:24 +00:00
class ProxyLogListCreateApi(generics.ListCreateAPIView):
2016-10-18 11:28:36 +00:00
"""User proxy to backend server need call this api.
params: {
"username": "",
"name": "",
"hostname": "",
"ip": "",
"terminal", "",
"login_type": "",
"system_user": "",
"was_failed": "",
"date_start": ""
}
some params we need generate: {
"log_file", "", # No use now, may be think more about monitor and record
}
"""
2016-10-09 16:39:24 +00:00
queryset = ProxyLog.objects.all()
serializer_class = serializers.ProxyLogSerializer
2016-10-18 11:28:36 +00:00
permission_classes = (IsSuperUserOrTerminalUser,)
def perform_create(self, serializer):
# Todo: May be save log_file
super(ProxyLogListCreateApi, self).perform_create(serializer)
2016-10-09 16:39:24 +00:00
class ProxyLogDetailApi(generics.RetrieveUpdateDestroyAPIView):
queryset = ProxyLog.objects.all()
2016-10-08 16:12:18 +00:00
serializer_class = serializers.ProxyLogSerializer
2016-10-18 11:28:36 +00:00
permission_classes = (IsSuperUserOrTerminalUser,)
2016-10-08 16:12:18 +00:00
class CommandLogCreateApi(generics.CreateAPIView):
serializer_class = serializers.CommandLogSerializer