82759e56b21af44d85cae415d2c806fe95e1e85c
[multicloud/framework.git] / multivimbroker / multivimbroker / forwarder / views.py
1 # Copyright 2017 Wind River Systems, Inc.
2 #
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
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 from rest_framework.views import  APIView
16 from multivimbroker.forwarder.base import BaseHandler
17
18 #
19 class BaseServer(BaseHandler,APIView):
20
21
22     def get(self,request,vimid):
23         raise NotImplementedError()
24
25     def post(self,request,vimid):
26         raise NotImplementedError()
27
28     def put(self,request,vimid):
29         raise NotImplementedError()
30
31     def delete(self,request,vimid):
32         raise NotImplementedError()
33
34     def head(self,request,vimid):
35         raise NotImplementedError()
36
37     def patch(self,request,vimid):
38         raise NotImplementedError()
39
40
41 #  vio proxy handler
42 class Identity(BaseServer):
43
44     def get(self,request,vimid):
45
46         return self.send(vimid,request.get_full_path(),request.body,"GET")
47
48     def post(self,request,vimid):
49
50         return self.send(vimid,request.get_full_path(),request.body,"POST")
51
52
53 # forward  handler
54 class Forward(BaseServer):
55
56     def get(self,request,vimid):
57
58         return self.send(vimid,request.get_full_path(),request.body,"GET")
59
60     def post(self,request,vimid):
61
62         return self.send(vimid,request.get_full_path(),request.body,"POST",headers=None)
63
64     def patch(self,request,vimid):
65
66         return self.send(vimid,request.get_full_path(),request.body,"PATCH",headers=None)
67
68     def delete(self,request,vimid):
69
70         return self.send(vimid,request.get_full_path(),request.body,"DELETE",headers=None)
71
72     def head(self,request,vimid):
73
74         return self.send(vimid,request.get_full_path(),request.body,"HEAD")
75
76     def put(self,request,vimid):
77
78         return self.send(vimid,request.get_full_path(),request.body,"PUT",headers=None)
79