jumpserver/apps/assets/api.py

53 lines
1.3 KiB
Python
Raw Normal View History

2016-08-09 09:27:37 +00:00
# ~*~ coding: utf-8 ~*~
2016-09-11 01:50:42 +00:00
2016-09-03 11:05:50 +00:00
from rest_framework import serializers
2016-09-11 01:50:42 +00:00
from rest_framework import viewsets, serializers
from .models import AssetGroup, Asset, IDC, AssetExtend
2016-08-09 09:27:37 +00:00
2016-09-03 11:05:50 +00:00
class AssetGroupSerializer(serializers.ModelSerializer):
class Meta:
model = AssetGroup
2016-09-11 01:50:42 +00:00
# exclude = [
# 'password', 'first_name', 'last_name', 'secret_key_otp',
# 'private_key', 'public_key', 'avatar',
# ]
2016-09-03 11:05:50 +00:00
class AssetSerializer(serializers.ModelSerializer):
class Meta:
model = Asset
2016-09-11 01:50:42 +00:00
# fields = ('id', 'title', 'code', 'linenos', 'language', 'style')
2016-09-03 11:05:50 +00:00
class IDCSerializer(serializers.ModelSerializer):
class Meta:
model = IDC
2016-09-11 01:50:42 +00:00
# fields = ('id', 'title', 'code', 'linenos', 'language', 'style')
2016-09-04 09:43:03 +00:00
2016-09-03 11:05:50 +00:00
class AssetGroupViewSet(viewsets.ModelViewSet):
2016-09-11 01:50:42 +00:00
""" API endpoint that allows AssetGroup to be viewed or edited.
some other comment
2016-09-03 11:05:50 +00:00
"""
queryset = AssetGroup.objects.all()
serializer_class = AssetGroupSerializer
2016-09-04 09:43:03 +00:00
2016-09-03 11:05:50 +00:00
class AssetViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows Asset to be viewed or edited.
"""
queryset = Asset.objects.all()
serializer_class = AssetSerializer
2016-09-04 09:43:03 +00:00
2016-09-03 11:05:50 +00:00
class IDCViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows IDC to be viewed or edited.
"""
queryset = IDC.objects.all()
serializer_class = IDCSerializer