jumpserver/apps/audits/api.py

63 lines
1.8 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-12-30 14:21:50 +00:00
2016-11-08 16:36:23 +00:00
from rest_framework import generics, viewsets
2016-10-26 11:10:14 +00:00
from rest_framework.views import APIView, Response
2016-10-08 16:12:18 +00:00
2016-10-20 11:01:57 +00:00
from . import models, serializers
2016-12-30 14:21:50 +00:00
from .hands import IsSuperUserOrAppUser, Terminal, IsAppUser
class ProxyLogReceiveView(generics.CreateAPIView):
queryset = models.ProxyLog.objects.all()
serializer_class = serializers.ProxyLogSerializer
permission_classes = (IsAppUser,)
def get_serializer(self, *args, **kwargs):
kwargs['data']['terminal'] = self.request.user.terminal.name
return super(ProxyLogReceiveView, self).get_serializer(*args, **kwargs)
2016-10-08 16:12:18 +00:00
2016-10-09 16:39:24 +00:00
2016-11-08 16:36:23 +00:00
class ProxyLogViewSet(viewsets.ModelViewSet):
2016-10-18 11:28:36 +00:00
"""User proxy to backend server need call this api.
params: {
"username": "",
"name": "",
"hostname": "",
"ip": "",
2016-12-30 14:21:50 +00:00
"terminal": "",
2016-10-18 11:28:36 +00:00
"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-12-25 05:15:28 +00:00
permission_classes = (IsSuperUserOrAppUser,)
2016-10-18 11:28:36 +00:00
2016-10-09 16:39:24 +00:00
2016-11-08 16:36:23 +00:00
class CommandLogViewSet(viewsets.ModelViewSet):
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-12-25 05:15:28 +00:00
permission_classes = (IsSuperUserOrAppUser,)
2016-10-26 11:10:14 +00:00
# class CommandLogTitleApi(APIView):
# def get(self, request):
# response = [
# {"name": "command_no", "title": "ID", "type": "number"},
# {"name": "command", "title": "Title", "visible": True, "filterable": True},
# {"name": "datetime", "title": "Datetime", "type"},
# {"name": "output", "title": "Output", "filterable": True},
# ]
#