jumpserver/apps/audits/api.py

51 lines
1.4 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
2016-10-20 11:01:57 +00:00
from __future__ import absolute_import, unicode_literals
2016-10-08 16:12:18 +00:00
from rest_framework import generics
2016-10-20 11:01:57 +00:00
from . import models, serializers
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-19 16:26:53 +00:00
queryset = models.ProxyLog.objects.all()
2016-10-09 16:39:24 +00:00
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):
2016-10-19 16:26:53 +00:00
queryset = models.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
2016-10-18 17:05:28 +00:00
class CommandLogCreateApi(generics.ListCreateAPIView):
2016-10-19 16:26:53 +00:00
queryset = models.CommandLog.objects.all()
2016-10-08 16:12:18 +00:00
serializer_class = serializers.CommandLogSerializer
2016-10-18 17:05:28 +00:00
permission_classes = (IsSuperUserOrTerminalUser,)