1 # Copyright 2017 Wind River Systems, Inc.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 from rest_framework.views import APIView
16 from multivimbroker.forwarder.base import BaseHandler
19 class BaseServer(BaseHandler,APIView):
22 def get(self,request,vimid):
23 raise NotImplementedError()
25 def post(self,request,vimid):
26 raise NotImplementedError()
28 def put(self,request,vimid):
29 raise NotImplementedError()
31 def delete(self,request,vimid):
32 raise NotImplementedError()
34 def head(self,request,vimid):
35 raise NotImplementedError()
37 def patch(self,request,vimid):
38 raise NotImplementedError()
42 class Identity(BaseServer):
44 def get(self,request,vimid):
46 return self.send(vimid,request.get_full_path(),request.body,"GET")
48 def post(self,request,vimid):
50 return self.send(vimid,request.get_full_path(),request.body,"POST")
54 class Forward(BaseServer):
56 def get(self,request,vimid):
58 return self.send(vimid,request.get_full_path(),request.body,"GET")
60 def post(self,request,vimid):
62 return self.send(vimid,request.get_full_path(),request.body,"POST",headers=None)
64 def patch(self,request,vimid):
66 return self.send(vimid,request.get_full_path(),request.body,"PATCH",headers=None)
68 def delete(self,request,vimid):
70 return self.send(vimid,request.get_full_path(),request.body,"DELETE",headers=None)
72 def head(self,request,vimid):
74 return self.send(vimid,request.get_full_path(),request.body,"HEAD")
76 def put(self,request,vimid):
78 return self.send(vimid,request.get_full_path(),request.body,"PUT",headers=None)