blob: f8619e01892051d249d673894d23764a374f2711 [file] [log] [blame]
Matteo Scandoloc3ca49b2017-08-08 13:05:26 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
Murat Parlakisikb224cc92017-02-16 16:27:12 -080017from rest_framework.decorators import api_view
18from rest_framework.response import Response
19from rest_framework.reverse import reverse
20from rest_framework import serializers
21from rest_framework import generics
22from rest_framework import status
23from core.models import *
24from django.forms import widgets
25from services.progran.models import *
26from xos.apibase import XOSListCreateAPIView, XOSRetrieveUpdateDestroyAPIView, XOSPermissionDenied
27from api.xosapi_helpers import PlusModelSerializer, XOSViewSet, ReadOnlyField
28import json
29
30BASE_NAME = 'progran'
31
32
33class VProgranProfileSerializer(PlusModelSerializer):
34 id = ReadOnlyField()
35 uiid = serializers.CharField(required=False)
36 profile = serializers.CharField(required=False)
37 dlrate = serializers.CharField(required=False)
38 ulrate = serializers.CharField(required=False)
39
40
41 class Meta:
42 model = VProgranProfile
43 fields = ('uiid','id', 'profile', 'dlrate' , 'ulrate')
44
45
46
47
48class VProgranImsiSerializer(PlusModelSerializer):
49 id = ReadOnlyField()
50 uiid = serializers.CharField(required=False)
51 imsi = serializers.CharField(required=False)
52 profile = serializers.CharField(required=False)
53
54
55 class Meta:
56 model = VProgranImsi
57 fields = ('uiid','id', 'imsi', "profile")
58
59
60class ProgranProfileViewSet(XOSViewSet):
61 base_name = "progran"
62 method_name = "profile"
63 method_kind = "viewset"
64 queryset = VProgranProfile.objects.all()
65 serializer_class = VProgranProfileSerializer
66
67 @classmethod
68 def get_urlpatterns(self, api_path="^"):
69 patterns = super(ProgranProfileViewSet, self).get_urlpatterns(api_path=api_path)
70
71 return patterns
72
73 def list(self, request):
74 object_list = self.filter_queryset(self.get_queryset())
75
76 serializer = self.get_serializer(object_list, many=True)
77
78 return Response(serializer.data)
79
80
81class ProgranImsiViewSet(XOSViewSet):
82 base_name = "progran"
83 method_name = "imsi"
84 method_kind = "viewset"
85 queryset = VProgranImsi.objects.all()
86 serializer_class = VProgranImsiSerializer
87
88 @classmethod
89 def get_urlpatterns(self, api_path="^"):
90 patterns = super(ProgranImsiViewSet, self).get_urlpatterns(api_path=api_path)
91
92 return patterns
93
94 def list(self, request):
95 object_list = self.filter_queryset(self.get_queryset())
96
97 serializer = self.get_serializer(object_list, many=True)
98
99 return Response(serializer.data)