add pep8 check
[multicloud/framework.git] / multivimbroker / multivimbroker / swagger / views.py
1 # Copyright (c) 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 #       http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
12 import json
13 import logging
14 import os
15 # import traceback
16
17 # from rest_framework import status
18 from rest_framework.response import Response
19 from rest_framework.views import APIView
20
21 # from multivimbroker.pub.exceptions import VimBrokerException
22
23 logger = logging.getLogger(__name__)
24
25
26 class SwaggerJsonView(APIView):
27     def get(self, request):
28         json_file = os.path.join(os.path.dirname(__file__),
29                                  'multivim.flavor.swagger.json')
30         f = open(json_file)
31         json_data = json.JSONDecoder().decode(f.read())
32         f.close()
33         json_file = os.path.join(os.path.dirname(__file__),
34                                  'multivim.image.swagger.json')
35         f = open(json_file)
36         json_data_temp = json.JSONDecoder().decode(f.read())
37         f.close()
38         json_data["paths"].update(json_data_temp["paths"])
39         json_data["definitions"].update(json_data_temp["definitions"])
40         json_file = os.path.join(os.path.dirname(__file__),
41                                  'multivim.network.swagger.json')
42         f = open(json_file)
43         json_data_temp = json.JSONDecoder().decode(f.read())
44         f.close()
45         json_data["paths"].update(json_data_temp["paths"])
46         json_data["definitions"].update(json_data_temp["definitions"])
47         json_file = os.path.join(os.path.dirname(__file__),
48                                  'multivim.subnet.swagger.json')
49         f = open(json_file)
50         json_data_temp = json.JSONDecoder().decode(f.read())
51         f.close()
52         json_data["paths"].update(json_data_temp["paths"])
53         json_data["definitions"].update(json_data_temp["definitions"])
54         json_file = os.path.join(os.path.dirname(__file__),
55                                  'multivim.server.swagger.json')
56         f = open(json_file)
57         json_data_temp = json.JSONDecoder().decode(f.read())
58         f.close()
59         json_data["paths"].update(json_data_temp["paths"])
60         json_data["definitions"].update(json_data_temp["definitions"])
61         json_file = os.path.join(os.path.dirname(__file__),
62                                  'multivim.volume.swagger.json')
63         f = open(json_file)
64         json_data_temp = json.JSONDecoder().decode(f.read())
65         f.close()
66         json_data["paths"].update(json_data_temp["paths"])
67         json_data["definitions"].update(json_data_temp["definitions"])
68         json_file = os.path.join(os.path.dirname(__file__),
69                                  'multivim.vport.swagger.json')
70         f = open(json_file)
71         json_data_temp = json.JSONDecoder().decode(f.read())
72         f.close()
73         json_data["paths"].update(json_data_temp["paths"])
74         json_data["definitions"].update(json_data_temp["definitions"])
75         json_file = os.path.join(os.path.dirname(__file__),
76                                  'multivim.tenant.swagger.json')
77         f = open(json_file)
78         json_data_temp = json.JSONDecoder().decode(f.read())
79         f.close()
80         json_data["paths"].update(json_data_temp["paths"])
81         json_data["definitions"].update(json_data_temp["definitions"])
82         json_file = os.path.join(os.path.dirname(__file__),
83                                  'multivim.host.swagger.json')
84         f = open(json_file)
85         json_data_temp = json.JSONDecoder().decode(f.read())
86         f.close()
87         json_data["paths"].update(json_data_temp["paths"])
88         json_data["definitions"].update(json_data_temp["definitions"])
89         json_file = os.path.join(os.path.dirname(__file__),
90                                  'multivim.limit.swagger.json')
91         f = open(json_file)
92         json_data_temp = json.JSONDecoder().decode(f.read())
93         f.close()
94         json_data["paths"].update(json_data_temp["paths"])
95         json_data["definitions"].update(json_data_temp["definitions"])
96         #
97         json_file = os.path.join(os.path.dirname(__file__),
98                                  'multivim.identity.swagger.json')
99         f = open(json_file)
100         json_data_temp = json.JSONDecoder().decode(f.read())
101         f.close()
102         json_data["paths"].update(json_data_temp["paths"])
103         json_data["definitions"].update(json_data_temp["definitions"])
104         return Response(json_data)