add pep8 check
[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
20
21 class BaseServer(BaseHandler, APIView):
22
23     def get(self, request, vimid):
24         raise NotImplementedError()
25
26     def post(self, request, vimid):
27         raise NotImplementedError()
28
29     def put(self, request, vimid):
30         raise NotImplementedError()
31
32     def delete(self, request, vimid):
33         raise NotImplementedError()
34
35     def head(self, request, vimid):
36         raise NotImplementedError()
37
38     def patch(self, request, vimid):
39         raise NotImplementedError()
40
41
42 #  vio proxy handler
43 class Identity(BaseServer):
44
45     def get(self, request, vimid):
46
47         return self.send(vimid, request.get_full_path(), request.body, "GET")
48
49     def post(self, request, vimid):
50
51         return self.send(vimid, request.get_full_path(), request.body, "POST")
52
53
54 # forward  handler
55 class Forward(BaseServer):
56
57     def get(self, request, vimid):
58
59         return self.send(vimid, request.get_full_path(), request.body, "GET")
60
61     def post(self, request, vimid):
62
63         return self.send(vimid, request.get_full_path(), request.body, "POST",
64                          headers=None)
65
66     def patch(self, request, vimid):
67
68         return self.send(vimid, request.get_full_path(), request.body, "PATCH",
69                          headers=None)
70
71     def delete(self, request, vimid):
72
73         return self.send(vimid, request.get_full_path(), request.body,
74                          "DELETE", headers=None)
75
76     def head(self, request, vimid):
77
78         return self.send(vimid, request.get_full_path(), request.body, "HEAD")
79
80     def put(self, request, vimid):
81
82         return self.send(vimid, request.get_full_path(), request.body, "PUT",
83                          headers=None)